diff --git a/include/scrimmage/Hash.h b/include/scrimmage/Hash.h index 2aefb4db90..fcea37a06d 100644 --- a/include/scrimmage/Hash.h +++ b/include/scrimmage/Hash.h @@ -37,15 +37,14 @@ // custom specialization of std::hash can be injected in namespace std // see http://en.cppreference.com/w/cpp/utility/hash namespace std { -template<> struct hash { +template <> +struct hash { size_t operator()(scrimmage::ID const& id) const { // assume up to 16 teams and 64 subswarms // for a 32-bit int this leaves 16 bits (up to 65000 ids) - return id.team_id() & - (id.sub_swarm_id() << 4) & - (id.id() << 12); + return id.team_id() & (id.sub_swarm_id() << 4) & (id.id() << 12); } }; -} // namespace std +} // namespace std -#endif // INCLUDE_SCRIMMAGE_HASH_H_ +#endif // INCLUDE_SCRIMMAGE_HASH_H_ diff --git a/include/scrimmage/autonomy/Autonomy.h b/include/scrimmage/autonomy/Autonomy.h index 8760bfe45f..76d3dfd826 100644 --- a/include/scrimmage/autonomy/Autonomy.h +++ b/include/scrimmage/autonomy/Autonomy.h @@ -33,8 +33,8 @@ #ifndef INCLUDE_SCRIMMAGE_AUTONOMY_AUTONOMY_H_ #define INCLUDE_SCRIMMAGE_AUTONOMY_AUTONOMY_H_ -#include #include +#include #include #include @@ -51,28 +51,30 @@ class Autonomy : public EntityPlugin { virtual bool step_autonomy(double t, double dt); virtual bool posthumous(double t); virtual void init(); - bool ready() override { return true; } - virtual void init(std::map ¶ms); + bool ready() override { + return true; + } + virtual void init(std::map& params); void close(double t) override; bool need_reset(); // getters/setters - StatePtr &desired_state(); + StatePtr& desired_state(); void set_desired_state(StatePtr desired_state); - ContactMapPtr &get_contacts(); - ContactMap &get_contacts_raw(); - virtual void set_contacts(ContactMapPtr &contacts); - virtual void set_contacts_from_plugin(AutonomyPtr &ptr); - virtual void set_projection(std::shared_ptr &proj); + ContactMapPtr& get_contacts(); + ContactMap& get_contacts_raw(); + virtual void set_contacts(ContactMapPtr& contacts); + virtual void set_contacts_from_plugin(AutonomyPtr& ptr); + virtual void set_projection(std::shared_ptr& proj); - scrimmage::RTreePtr &rtree(); - void set_rtree(scrimmage::RTreePtr &rtree); + scrimmage::RTreePtr& rtree(); + void set_rtree(scrimmage::RTreePtr& rtree); - StatePtr &state(); - virtual void set_state(StatePtr &state); + StatePtr& state(); + virtual void set_state(StatePtr& state); - std::string &logging_msg(); + std::string& logging_msg(); bool get_is_controlling(); void set_is_controlling(bool is_controlling); @@ -90,5 +92,5 @@ class Autonomy : public EntityPlugin { bool is_controlling_; }; -} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_AUTONOMY_AUTONOMY_H_ +} // namespace scrimmage +#endif // INCLUDE_SCRIMMAGE_AUTONOMY_AUTONOMY_H_ diff --git a/include/scrimmage/common/Algorithm.h b/include/scrimmage/common/Algorithm.h index 15ecd5b645..00acc1cb82 100644 --- a/include/scrimmage/common/Algorithm.h +++ b/include/scrimmage/common/Algorithm.h @@ -33,8 +33,8 @@ #ifndef INCLUDE_SCRIMMAGE_COMMON_ALGORITHM_H_ #define INCLUDE_SCRIMMAGE_COMMON_ALGORITHM_H_ -#include #include +#include #include namespace scrimmage { @@ -43,7 +43,7 @@ namespace scrimmage { * This implementation assumes the first argument has an erase method. */ template -void remove_if(ContainerType &container, Predicate pred) { +void remove_if(ContainerType& container, Predicate pred) { auto it = container.begin(); while (it != container.end()) { it = pred(*it) ? container.erase(it) : std::next(it); @@ -55,29 +55,29 @@ void remove_if(ContainerType &container, Predicate pred) { * std::set_difference does not work on unordered_sets */ template > -std::unordered_set -set_difference(const std::unordered_set &container1, const std::unordered_set &container2) { +std::unordered_set set_difference(const std::unordered_set& container1, + const std::unordered_set& container2) { std::unordered_set out; std::copy_if(container1.begin(), container1.end(), std::inserter(out, out.end()), - [&](const T &val) {return container2.count(val) == 0;}); + [&](const T& val) { return container2.count(val) == 0; }); return out; } template > -std::unordered_set -set_union(const std::unordered_set &container1, const std::unordered_set &container2) { +std::unordered_set set_union(const std::unordered_set& container1, + const std::unordered_set& container2) { std::unordered_set out = container1; out.insert(container2.begin(), container2.end()); return out; } template > -std::unordered_set -set_intersection(const std::unordered_set &container1, const std::unordered_set &container2) { +std::unordered_set set_intersection(const std::unordered_set& container1, + const std::unordered_set& container2) { std::unordered_set out; std::copy_if(container1.begin(), container1.end(), std::inserter(out, out.end()), - [&](const T &val) {return container2.count(val) != 0;}); + [&](const T& val) { return container2.count(val) != 0; }); return out; } -} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_ALGORITHM_H_ +} // namespace scrimmage +#endif // INCLUDE_SCRIMMAGE_COMMON_ALGORITHM_H_ diff --git a/include/scrimmage/common/Battery.h b/include/scrimmage/common/Battery.h index 3dda06d120..c77afc067e 100644 --- a/include/scrimmage/common/Battery.h +++ b/include/scrimmage/common/Battery.h @@ -36,13 +36,14 @@ namespace scrimmage { class Battery { public: - Battery() {} - Battery(const double &min, const double &max, const double ¤t); - void add_charge(const double &amount); - bool deplete(const double &amount); + Battery() { + } + Battery(const double& min, const double& max, const double& current); + void add_charge(const double& amount); + bool deplete(const double& amount); bool is_full(); bool has_charge(); - const double ¤t_charge(); + const double& current_charge(); double charge_percentage(); protected: @@ -50,5 +51,5 @@ class Battery { double max_charge_ = 1; double current_charge_ = 1; }; -} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_BATTERY_H_ +} // namespace scrimmage +#endif // INCLUDE_SCRIMMAGE_COMMON_BATTERY_H_ diff --git a/include/scrimmage/common/CSV.h b/include/scrimmage/common/CSV.h index d9a44d611c..13a522c9b0 100644 --- a/include/scrimmage/common/CSV.h +++ b/include/scrimmage/common/CSV.h @@ -34,11 +34,11 @@ #define INCLUDE_SCRIMMAGE_COMMON_CSV_H_ #include -#include #include +#include +#include #include #include -#include namespace scrimmage { @@ -49,45 +49,50 @@ class CSV { ~CSV(); - void set_column_headers(const Headers &headers, bool write = true); + void set_column_headers(const Headers& headers, bool write = true); - void set_column_headers(const std::string &headers, bool write = true); + void set_column_headers(const std::string& headers, bool write = true); - bool append(const Pairs &pairs, bool write = true, bool keep_in_memory = false); + bool append(const Pairs& pairs, bool write = true, bool keep_in_memory = false); - bool open_output(const std::string &filename, - std::ios_base::openmode mode = (std::ios_base::out | - std::ios_base::trunc)); + bool open_output(const std::string& filename, + std::ios_base::openmode mode = (std::ios_base::out | std::ios_base::trunc)); bool output_is_open(); bool close_output(); - bool to_csv(const std::string &filename); + bool to_csv(const std::string& filename); - bool read_csv(const std::string &filename, const bool& contains_header = true); + bool read_csv(const std::string& filename, const bool& contains_header = true); - bool read_csv_from_string(const std::string &str, const bool& contains_header = true); + bool read_csv_from_string(const std::string& str, const bool& contains_header = true); - void set_no_value_string(const std::string &str); + void set_no_value_string(const std::string& str); std::string to_string() const; size_t rows(); - double at(int row, const std::string &header); + double at(int row, const std::string& header); friend std::ostream& operator<<(std::ostream& os, const CSV& csv); bool equals(const CSV& other); // double parameters - void set_double_precision(int precision) { double_precision_ = precision; } - void set_double_fixed(bool is_fixed) { double_is_fixed_ = is_fixed; } - void set_double_scientific(bool is_scientific) { double_is_scientific_ = is_scientific; } + void set_double_precision(int precision) { + double_precision_ = precision; + } + void set_double_fixed(bool is_fixed) { + double_is_fixed_ = is_fixed; + } + void set_double_scientific(bool is_scientific) { + double_is_scientific_ = is_scientific; + } protected: - std::list get_csv_line_elements(const std::string &str); + std::list get_csv_line_elements(const std::string& str); void write_headers(); @@ -115,6 +120,6 @@ class CSV { std::string rows_to_string() const; std::string row_to_string(const int& i) const; }; -} // namespace scrimmage +} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_CSV_H_ +#endif // INCLUDE_SCRIMMAGE_COMMON_CSV_H_ diff --git a/include/scrimmage/common/ColorMaps.h b/include/scrimmage/common/ColorMaps.h index 80801e6653..b023b413c1 100644 --- a/include/scrimmage/common/ColorMaps.h +++ b/include/scrimmage/common/ColorMaps.h @@ -51,6 +51,6 @@ Color_t GetColor(double v, double vmin, double vmax); int GetGray(Color_t c, double vmin, double vmax); -} // namespace scrimmage +} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_COLORMAPS_H_ +#endif // INCLUDE_SCRIMMAGE_COMMON_COLORMAPS_H_ diff --git a/include/scrimmage/common/DelayedTask.h b/include/scrimmage/common/DelayedTask.h index 114431fb52..a126d057bc 100644 --- a/include/scrimmage/common/DelayedTask.h +++ b/include/scrimmage/common/DelayedTask.h @@ -32,8 +32,8 @@ #ifndef INCLUDE_SCRIMMAGE_COMMON_DELAYEDTASK_H_ #define INCLUDE_SCRIMMAGE_COMMON_DELAYEDTASK_H_ -#include #include +#include namespace scrimmage { @@ -64,5 +64,5 @@ class DelayedTask { bool repeat_infinitely_; int repeats_left_; }; -} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_DELAYEDTASK_H_ +} // namespace scrimmage +#endif // INCLUDE_SCRIMMAGE_COMMON_DELAYEDTASK_H_ diff --git a/include/scrimmage/common/ExponentialFilter.h b/include/scrimmage/common/ExponentialFilter.h index 4590746259..f343a96a1b 100644 --- a/include/scrimmage/common/ExponentialFilter.h +++ b/include/scrimmage/common/ExponentialFilter.h @@ -37,17 +37,17 @@ namespace scrimmage { class ExponentialFilter { public: - ExponentialFilter(); - explicit ExponentialFilter(double time_constant); - void set_time_constant(double time_constant); - double add_estimate(double estimate, double t); - double get_estimate() const; + ExponentialFilter(); + explicit ExponentialFilter(double time_constant); + void set_time_constant(double time_constant); + double add_estimate(double estimate, double t); + double get_estimate() const; protected: - double estimate_; - double time_last_estimate_; - double time_constant_; + double estimate_; + double time_last_estimate_; + double time_constant_; }; -} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_EXPONENTIALFILTER_H_ +} // namespace scrimmage +#endif // INCLUDE_SCRIMMAGE_COMMON_EXPONENTIALFILTER_H_ diff --git a/include/scrimmage/common/FSMBehavior.h b/include/scrimmage/common/FSMBehavior.h index 9a34c4ec78..c174e45cf0 100644 --- a/include/scrimmage/common/FSMBehavior.h +++ b/include/scrimmage/common/FSMBehavior.h @@ -36,20 +36,24 @@ #include #include -#include #include +#include namespace scrimmage { namespace common { class FSMBehavior : public scrimmage::Autonomy { public: - virtual void entered() {} - virtual void step_inactive() {} - virtual void exited() {} + virtual void entered() { + } + virtual void step_inactive() { + } + virtual void exited() { + } + protected: }; using FSMBehaviorPtr = std::shared_ptr; -} // namespace common -} // namespace scrimmage +} // namespace common +} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_FSMBEHAVIOR_H_ +#endif // INCLUDE_SCRIMMAGE_COMMON_FSMBEHAVIOR_H_ diff --git a/include/scrimmage/common/FileSearch.h b/include/scrimmage/common/FileSearch.h index 6707c8411c..2b47a9936a 100644 --- a/include/scrimmage/common/FileSearch.h +++ b/include/scrimmage/common/FileSearch.h @@ -33,13 +33,14 @@ #ifndef INCLUDE_SCRIMMAGE_COMMON_FILESEARCH_H_ #define INCLUDE_SCRIMMAGE_COMMON_FILESEARCH_H_ -#include #include #include #include +#include namespace boost { -template class optional; +template +class optional; } namespace scrimmage { @@ -57,20 +58,21 @@ class FileSearch { */ boost::optional find_mission(std::string mission, bool verbose = false); - bool find_file(const std::string &filename, std::string ext, - const std::string &env_var, std::string &result, bool verbose = false); - void find_files(std::string env_var, const std::string &ext, - std::unordered_map> &out, - bool verbose = false); + bool find_file(const std::string& filename, std::string ext, const std::string& env_var, + std::string& result, bool verbose = false); + void find_files(std::string env_var, const std::string& ext, + std::unordered_map>& out, + bool verbose = false); protected: // cache_[env_var][ext][filename] = list of full paths to files with that filename - std::unordered_map>>> cache_; + std::unordered_map< + std::string, + std::unordered_map>>> + cache_; }; using FileSearchPtr = std::shared_ptr; -} // namespace scrimmage +} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_FILESEARCH_H_ +#endif // INCLUDE_SCRIMMAGE_COMMON_FILESEARCH_H_ diff --git a/include/scrimmage/common/GlobalService.h b/include/scrimmage/common/GlobalService.h index b0ea7833b1..b470863fda 100644 --- a/include/scrimmage/common/GlobalService.h +++ b/include/scrimmage/common/GlobalService.h @@ -33,19 +33,20 @@ #define INCLUDE_SCRIMMAGE_COMMON_GLOBALSERVICE_H_ #include + +#include +#include +#include #include +#include #include +#include #include -#include #include -#include -#include -#include -#include namespace scrimmage { -using Service = std::function; +using Service = std::function; class GlobalService { public: @@ -54,22 +55,23 @@ class GlobalService { ///////////////////////////// // All service call functions - std::unordered_map &services(); + std::unordered_map& services(); - bool call_service(MessageBasePtr req, MessageBasePtr &res, const std::string &service_name); + bool call_service(MessageBasePtr req, MessageBasePtr& res, const std::string& service_name); - bool call_service(MessageBasePtr &res, const std::string &service_name) { + bool call_service(MessageBasePtr& res, const std::string& service_name) { return call_service(std::make_shared(), res, service_name); } template ::value, void>::type> - bool call_service(MessageBasePtr req, T &res, const std::string &service_name) { + bool call_service(MessageBasePtr req, T& res, const std::string& service_name) { MessageBasePtr res_base; if (call_service(req, res_base, service_name)) { res = std::dynamic_pointer_cast(res_base); if (res == nullptr) { - std::cout << "could not cast for global service " << service_name.c_str() << std::endl; + std::cout << "could not cast for global service " << service_name.c_str() + << std::endl; return false; } else { return true; @@ -81,7 +83,7 @@ class GlobalService { template ::value, void>::type> - bool call_service(T &res, const std::string &service_name) { + bool call_service(T& res, const std::string& service_name) { return call_service(std::make_shared(), res, service_name); } diff --git a/include/scrimmage/common/ID.h b/include/scrimmage/common/ID.h index 2dff5818eb..ef3745207b 100644 --- a/include/scrimmage/common/ID.h +++ b/include/scrimmage/common/ID.h @@ -50,8 +50,8 @@ class ID { int sub_swarm_id() const; int team_id() const; - bool operator==(const ID &other) const; - bool operator<(const ID &other) const; + bool operator==(const ID& other) const; + bool operator<(const ID& other) const; friend std::ostream& operator<<(std::ostream& os, const scrimmage::ID& id); @@ -60,6 +60,6 @@ class ID { int sub_swarm_id_; int team_id_; }; -} // namespace scrimmage +} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_ID_H_ +#endif // INCLUDE_SCRIMMAGE_COMMON_ID_H_ diff --git a/include/scrimmage/common/PID.h b/include/scrimmage/common/PID.h index d6e0701a93..fcfb1278c7 100644 --- a/include/scrimmage/common/PID.h +++ b/include/scrimmage/common/PID.h @@ -39,26 +39,25 @@ namespace scrimmage { class PID { public: PID(); - void set_parameters(const double &kp, const double &ki, const double &kd); - void set_setpoint(const double &setpoint); - void set_integral_band(const double &integral_band); - void set_is_angle(const bool &is_angle); - void set_output_limits(const double &min, const double &max, - const double &enable); + void set_parameters(const double& kp, const double& ki, const double& kd); + void set_setpoint(const double& setpoint); + void set_integral_band(const double& integral_band); + void set_is_angle(const bool& is_angle); + void set_output_limits(const double& min, const double& max, const double& enable); void reset(); - const double &setpoint(); - const double &kp(); - const double &ki(); - const double &kd(); - const double &integral_band(); - const double &integral(); - const double &error(); - const double &previous_error(); - const double &derivative(); + const double& setpoint(); + const double& kp(); + const double& ki(); + const double& kd(); + const double& integral_band(); + const double& integral(); + const double& error(); + const double& previous_error(); + const double& derivative(); - bool init(const std::string &str, const bool &is_angle); - double step(const double &dt, const double &measurement); + bool init(const std::string& str, const bool& is_angle); + double step(const double& dt, const double& measurement); protected: double kp_; @@ -79,6 +78,6 @@ class PID { double output_max_; bool enable_output_limits_; }; -} // namespace scrimmage +} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_PID_H_ +#endif // INCLUDE_SCRIMMAGE_COMMON_PID_H_ diff --git a/include/scrimmage/common/Parameter.h b/include/scrimmage/common/Parameter.h index 1ff8535f69..c906a25eca 100644 --- a/include/scrimmage/common/Parameter.h +++ b/include/scrimmage/common/Parameter.h @@ -33,9 +33,9 @@ #ifndef INCLUDE_SCRIMMAGE_COMMON_PARAMETER_H_ #define INCLUDE_SCRIMMAGE_COMMON_PARAMETER_H_ -#include -#include #include +#include +#include namespace scrimmage { @@ -44,9 +44,14 @@ using PluginPtr = std::shared_ptr; class ParameterBase { public: - explicit ParameterBase(PluginPtr &owner) : owner_(owner) {} - virtual ~ParameterBase() {} - const PluginPtr &owner() { return owner_; } + explicit ParameterBase(PluginPtr& owner) : owner_(owner) { + } + virtual ~ParameterBase() { + } + const PluginPtr& owner() { + return owner_; + } + protected: PluginPtr owner_ = nullptr; }; @@ -54,19 +59,20 @@ class ParameterBase { template class Parameter : public ParameterBase { public: - Parameter(T &variable, std::function callback, - PluginPtr &owner) : ParameterBase(owner), value_(variable), - callback_(callback) {} - void set_value(const T &value) { + Parameter(T& variable, std::function callback, PluginPtr& owner) + : ParameterBase(owner), value_(variable), callback_(callback) { + } + void set_value(const T& value) { value_ = value; callback_(value_); } + protected: - T &value_; - std::function callback_; + T& value_; + std::function callback_; }; typedef std::shared_ptr ParameterBasePtr; -} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_PARAMETER_H_ +} // namespace scrimmage +#endif // INCLUDE_SCRIMMAGE_COMMON_PARAMETER_H_ diff --git a/include/scrimmage/common/ParameterServer.h b/include/scrimmage/common/ParameterServer.h index cadc2b7aa8..4b47a32f26 100644 --- a/include/scrimmage/common/ParameterServer.h +++ b/include/scrimmage/common/ParameterServer.h @@ -35,16 +35,15 @@ #include -#include -#include -#include -#include -#include -#include #include -#include - #include +#include +#include +#include +#include +#include +#include +#include class Plugin; using PluginPtr = std::shared_ptr; @@ -55,16 +54,15 @@ class ParameterServer { void unregister_params(PluginPtr owner); template - bool register_param(const std::string &name, T &variable, - std::function callback, - PluginPtr owner) { + bool register_param(const std::string& name, T& variable, + std::function callback, PluginPtr owner) { auto it = params_[name][typeid(T).name()].emplace( std::make_shared>(variable, callback, owner)); - return it.second; // return false if the param already exists + return it.second; // return false if the param already exists } template - bool set_param(const std::string &name, const T &value) { + bool set_param(const std::string& name, const T& value) { auto param_set = find_name_type(name, typeid(T).name()); if (param_set) { for (ParameterBasePtr param : *param_set) { @@ -77,7 +75,7 @@ class ParameterServer { } template - bool unregister_param(const std::string &name, PluginPtr owner) { + bool unregister_param(const std::string& name, PluginPtr owner) { auto param_set = find_name_type(name, typeid(T).name()); if (param_set) { // Remove the parameter if this is the owner @@ -88,19 +86,17 @@ class ParameterServer { } protected: - bool remove_if_owner(std::set ¶m_set, - PluginPtr owner); + bool remove_if_owner(std::set& param_set, PluginPtr owner); - inline boost::optional&> - find_name_type(const std::string &name, const std::string &type) { + inline boost::optional&> find_name_type(const std::string& name, + const std::string& type) { // Search for the parameter name auto it_name = params_.find(name); if (it_name != params_.end()) { // Search for the parameter type auto it_type = it_name->second.find(type); if (it_type != it_name->second.end()) { - return boost::optional&> - (it_type->second); + return boost::optional&>(it_type->second); } } return boost::none; @@ -109,9 +105,9 @@ class ParameterServer { // Key 1: parameter name (string) // Key 2: parameter type (as a string) // Value: Set of ParameterBasePtr - std::unordered_map>> params_; + std::unordered_map>> + params_; }; using ParameterServerPtr = std::shared_ptr; -} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_PARAMETERSERVER_H_ +} // namespace scrimmage +#endif // INCLUDE_SCRIMMAGE_COMMON_PARAMETERSERVER_H_ diff --git a/include/scrimmage/common/Random.h b/include/scrimmage/common/Random.h index 0928cdd60c..51f5169390 100644 --- a/include/scrimmage/common/Random.h +++ b/include/scrimmage/common/Random.h @@ -52,15 +52,15 @@ class Random { double rng_uniform(double low, double high); double rng_normal(); double rng_normal(double mean, double sigma); - int rng_uniform_int(int low, int high); // inclusive of low and high + int rng_uniform_int(int low, int high); // inclusive of low and high - std::shared_ptr> - make_rng_normal(double mean, double sigma); + std::shared_ptr> make_rng_normal(double mean, double sigma); - int rng_discrete_int(std::vector &weights); + int rng_discrete_int(std::vector& weights); - std::shared_ptr gener() - { return gener_; } + std::shared_ptr gener() { + return gener_; + } protected: uint32_t seed_; @@ -70,6 +70,6 @@ class Random { }; typedef std::shared_ptr RandomPtr; -} // namespace scrimmage +} // namespace scrimmage -#endif // INCLUDE_SCRIMMAGE_COMMON_RANDOM_H_ +#endif // INCLUDE_SCRIMMAGE_COMMON_RANDOM_H_ diff --git a/include/scrimmage/common/Shape.h b/include/scrimmage/common/Shape.h index f12634700c..4c99bf2e74 100644 --- a/include/scrimmage/common/Shape.h +++ b/include/scrimmage/common/Shape.h @@ -33,129 +33,121 @@ #ifndef INCLUDE_SCRIMMAGE_COMMON_SHAPE_H_ #define INCLUDE_SCRIMMAGE_COMMON_SHAPE_H_ -#include -#include #include +#include +#include #include - +#include #include #include -#include namespace scrimmage { namespace shape { using ShapePtr = std::shared_ptr; -ShapePtr make_shape(const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_arc(const Eigen::Vector3d ¢er = Eigen::Vector3d(0, 0, 0), - const scrimmage::Quaternion &quat = scrimmage::Quaternion(0, 0, 0), - const double &radius = 1.0, - const double &angle = M_PI / 2.0, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_arrow(const Eigen::Vector3d &pos = Eigen::Vector3d(0, 0, 0), - const scrimmage::Quaternion &quat = scrimmage::Quaternion(0, 0, 0), - const double &length = 10.0, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_circle(const Eigen::Vector3d ¢er = Eigen::Vector3d(0, 0, 0), - const scrimmage::Quaternion &quat = scrimmage::Quaternion(0, 0, 0), - const double &radius = 1.0, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_cone(const Eigen::Vector3d &direction = Eigen::Vector3d(0, 0, 1), - const Eigen::Vector3d &apex = Eigen::Vector3d(0, 0, 1), - const double &height = 1.0, - const double &base_radius = 1.0, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_cuboid(const Eigen::Vector3d ¢er = Eigen::Vector3d(0, 0, 0), - const scrimmage::Quaternion &quat = scrimmage::Quaternion(0, 0, 0), - const double &x_length = 1.0, - const double &y_length = 1.0, - const double &z_length = 1.0, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_ellipse(const Eigen::Vector3d ¢er = Eigen::Vector3d(0, 0, 0), - const scrimmage::Quaternion &quat = scrimmage::Quaternion(0, 0, 0), - const double &x_radius = 2.0, - const double &y_radius = 1.0, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_line(const Eigen::Vector3d &start = Eigen::Vector3d(0, 0, 0), - const Eigen::Vector3d &stop = Eigen::Vector3d(1, 0, 0), - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_mesh(const std::string &name = "volkswagen", - const Eigen::Vector3d ¢er = Eigen::Vector3d(0, 0, 0), - const scrimmage::Quaternion &quat = scrimmage::Quaternion(0, 0, 0), - const double &scale = 1.0, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_plane(const Eigen::Vector3d ¢er = Eigen::Vector3d(0, 0, 0), - const scrimmage::Quaternion &quat = scrimmage::Quaternion(0, 0, 0), - const double &x_length = 10.0, - const double &y_length = 10.0, - const std::string &texture = "", - const bool &diffuse_lighting = false, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_pointcloud(const std::list &points, - const std::list &point_colors, - const double &size = 1.0, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_polydata(const std::list &points, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_polygon(const std::list &points, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_polyhedron(const std::list &points, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_polyline(const std::list &points, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_sphere(const Eigen::Vector3d ¢er = Eigen::Vector3d(0, 0, 0), - const double &radius = 1.0, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_spline(const std::list &points, - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_text(const std::string &text, - const Eigen::Vector3d ¢er = Eigen::Vector3d(0, 0, 0), - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -ShapePtr make_triangle(const Eigen::Vector3d &point0 = Eigen::Vector3d(1, 0, 0), - const Eigen::Vector3d &point1 = Eigen::Vector3d(0, 1, 0), - const Eigen::Vector3d &point2 = Eigen::Vector3d(-1, 0, 0), - const Eigen::Vector3d &color = Eigen::Vector3d(0, 0, 255), - const double &opacity = 1.0); - -} // namespace shape -} // namespace scrimmage - -#endif // INCLUDE_SCRIMMAGE_COMMON_SHAPE_H_ +ShapePtr make_shape(const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_arc(const Eigen::Vector3d& center = Eigen::Vector3d(0, 0, 0), + const scrimmage::Quaternion& quat = scrimmage::Quaternion(0, 0, 0), + const double& radius = 1.0, const double& angle = M_PI / 2.0, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_arrow(const Eigen::Vector3d& pos = Eigen::Vector3d(0, 0, 0), + const scrimmage::Quaternion& quat = scrimmage::Quaternion(0, 0, 0), + const double& length = 10.0, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_circle(const Eigen::Vector3d& center = Eigen::Vector3d(0, 0, 0), + const scrimmage::Quaternion& quat = scrimmage::Quaternion(0, 0, 0), + const double& radius = 1.0, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_cone(const Eigen::Vector3d& direction = Eigen::Vector3d(0, 0, 1), + const Eigen::Vector3d& apex = Eigen::Vector3d(0, 0, 1), + const double& height = 1.0, const double& base_radius = 1.0, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_cuboid(const Eigen::Vector3d& center = Eigen::Vector3d(0, 0, 0), + const scrimmage::Quaternion& quat = scrimmage::Quaternion(0, 0, 0), + const double& x_length = 1.0, const double& y_length = 1.0, + const double& z_length = 1.0, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_ellipse(const Eigen::Vector3d& center = Eigen::Vector3d(0, 0, 0), + const scrimmage::Quaternion& quat = scrimmage::Quaternion(0, 0, 0), + const double& x_radius = 2.0, const double& y_radius = 1.0, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_line(const Eigen::Vector3d& start = Eigen::Vector3d(0, 0, 0), + const Eigen::Vector3d& stop = Eigen::Vector3d(1, 0, 0), + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_mesh(const std::string& name = "volkswagen", + const Eigen::Vector3d& center = Eigen::Vector3d(0, 0, 0), + const scrimmage::Quaternion& quat = scrimmage::Quaternion(0, 0, 0), + const double& scale = 1.0, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_plane(const Eigen::Vector3d& center = Eigen::Vector3d(0, 0, 0), + const scrimmage::Quaternion& quat = scrimmage::Quaternion(0, 0, 0), + const double& x_length = 10.0, const double& y_length = 10.0, + const std::string& texture = "", const bool& diffuse_lighting = false, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_pointcloud(const std::list& points, + const std::list& point_colors, const double& size = 1.0, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_polydata(const std::list& points, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_polygon(const std::list& points, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_polyhedron(const std::list& points, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_polyline(const std::list& points, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_sphere(const Eigen::Vector3d& center = Eigen::Vector3d(0, 0, 0), + const double& radius = 1.0, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_spline(const std::list& points, + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_text(const std::string& text, + const Eigen::Vector3d& center = Eigen::Vector3d(0, 0, 0), + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +ShapePtr make_triangle(const Eigen::Vector3d& point0 = Eigen::Vector3d(1, 0, 0), + const Eigen::Vector3d& point1 = Eigen::Vector3d(0, 1, 0), + const Eigen::Vector3d& point2 = Eigen::Vector3d(-1, 0, 0), + const Eigen::Vector3d& color = Eigen::Vector3d(0, 0, 255), + const double& opacity = 1.0); + +} // namespace shape +} // namespace scrimmage + +#endif // INCLUDE_SCRIMMAGE_COMMON_SHAPE_H_ diff --git a/include/scrimmage/common/Time.h b/include/scrimmage/common/Time.h index f608ee5ffb..c022001484 100644 --- a/include/scrimmage/common/Time.h +++ b/include/scrimmage/common/Time.h @@ -68,5 +68,5 @@ class Time { double time_warp_; }; using TimePtr = std::shared_ptr