diff --git a/tesseract_command_language/include/tesseract_command_language/profile_dictionary.h b/tesseract_command_language/include/tesseract_command_language/profile_dictionary.h index 4973bd039fc..01f0fab6d5e 100644 --- a/tesseract_command_language/include/tesseract_command_language/profile_dictionary.h +++ b/tesseract_command_language/include/tesseract_command_language/profile_dictionary.h @@ -29,6 +29,7 @@ #include TESSERACT_COMMON_IGNORE_WARNINGS_PUSH #include +#include #include #include #include @@ -40,15 +41,107 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP %shared_ptr(tesseract_planning::ProfileDictionary) #endif // SWIG +namespace tesseract_environment +{ +class Environment; +} + namespace tesseract_planning { +class Instruction; +class CompositeInstruction; + +/** + * @brief Struct to produce a planner-specific planning profile to apply to a single waypoint. + * @details Examples of waypoint profiles might include costs/constraints for a waypoint or a waypoint sampler + */ +class WaypointProfile +{ +public: + using Ptr = std::shared_ptr; + using ConstPtr = std::shared_ptr; + + WaypointProfile() = default; + WaypointProfile(const WaypointProfile&) = delete; + WaypointProfile& operator=(const WaypointProfile&) = delete; + WaypointProfile(WaypointProfile&&) = delete; + WaypointProfile&& operator=(WaypointProfile&&) = delete; + + virtual ~WaypointProfile() = default; + + virtual std::any create(const Instruction& instruction, const tesseract_environment::Environment& env) const = 0; + +private: + friend class boost::serialization::access; + template + void serialize(Archive&, const unsigned int) // NOLINT + { + } +}; + +/** + * @brief Struct to produce a planner-specific planning profile to apply to a collection of waypoints defined in a + * composite instruction. + * @details Examples of composite profiles include costs/constraints that apply collectively to a group of waypoints + */ +class CompositeProfile +{ +public: + using Ptr = std::shared_ptr; + using ConstPtr = std::shared_ptr; + + CompositeProfile() = default; + CompositeProfile(const CompositeProfile&) = delete; + CompositeProfile& operator=(const CompositeProfile&) = delete; + CompositeProfile(CompositeProfile&&) = delete; + CompositeProfile&& operator=(CompositeProfile&&) = delete; + + virtual ~CompositeProfile() = default; + virtual std::any create(const CompositeInstruction& instruction, + const tesseract_environment::Environment& env) const = 0; + +private: + friend class boost::serialization::access; + template + void serialize(Archive&, const unsigned int) // NOLINT + { + } +}; + +/** + * @brief Struct to produce configuration parameters for the motion planner + */ +struct PlannerProfile +{ +public: + using Ptr = std::shared_ptr; + using ConstPtr = std::shared_ptr; + + PlannerProfile() = default; + PlannerProfile(const PlannerProfile&) = delete; + PlannerProfile& operator=(const PlannerProfile&) = delete; + PlannerProfile(PlannerProfile&&) = delete; + PlannerProfile&& operator=(PlannerProfile&&) = delete; + + virtual ~PlannerProfile() = default; + + virtual std::any create() const = 0; + +private: + friend class boost::serialization::access; + template + void serialize(Archive&, const unsigned int) // NOLINT + { + } +}; + /** * @brief This class is used to store profiles for motion planning and process planning * @details This is a thread safe class * A ProfileEntry is a std::unordered_map> * - The key is the profile name * - Where std::shared_ptr is the profile - * The ProfleEntry is also stored in std::unordered_map where the key here is the std::type_index(typeid(T)) + * The ProfileEntry is also stored in std::unordered_map where the key here is the std::type_index(typeid(T)) * @note When adding a profile entry the T should be the base class type. */ class ProfileDictionary @@ -210,10 +303,18 @@ class ProfileDictionary .erase(profile_name); } + std::unordered_map> waypoint_profiles; + std::unordered_map> composite_profiles; + std::unordered_map> planner_profiles; + protected: std::unordered_map> profiles_; mutable std::shared_mutex mutex_; }; } // namespace tesseract_planning +BOOST_SERIALIZATION_ASSUME_ABSTRACT(tesseract_planning::WaypointProfile); +BOOST_SERIALIZATION_ASSUME_ABSTRACT(tesseract_planning::CompositeProfile); +BOOST_SERIALIZATION_ASSUME_ABSTRACT(tesseract_planning::PlannerProfile); + #endif // TESSERACT_MOTION_PLANNERS_PROFILE_DICTIONARY_H diff --git a/tesseract_motion_planners/test/profile_dictionary_tests.cpp b/tesseract_motion_planners/test/profile_dictionary_tests.cpp index 5159c79055e..1ee93399384 100644 --- a/tesseract_motion_planners/test/profile_dictionary_tests.cpp +++ b/tesseract_motion_planners/test/profile_dictionary_tests.cpp @@ -28,6 +28,8 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH #include TESSERACT_COMMON_IGNORE_WARNINGS_POP +#include +#include #include struct ProfileBase