4040
4141#include < moveit/task_constructor/solvers/planner_interface.h>
4242#include < moveit/planning_pipeline_interfaces/planning_pipeline_interfaces.hpp>
43+ #include < moveit/planning_pipeline_interfaces/solution_selection_functions.hpp>
44+ #include < moveit/planning_pipeline_interfaces/stopping_criterion_functions.hpp>
4345#include < rclcpp/node.hpp>
4446#include < moveit/macros/class_forward.h>
4547
@@ -57,23 +59,34 @@ MOVEIT_CLASS_FORWARD(PipelinePlanner);
5759class PipelinePlanner : public PlannerInterface
5860{
5961public:
60- // TODO: Deprecate
62+ /* * Simple Constructor to use only a single pipeline
63+ * \param [in] node ROS 2 node
64+ * \param [in] pipeline_name Name of the planning pipeline to be used. This is also the assumed namespace where the
65+ * parameters of this pipeline can be found \param [in] planner_id Planner id to be used for planning
66+ */
6167 PipelinePlanner (const rclcpp::Node::SharedPtr& node, const std::string& pipeline_name = " ompl" ,
6268 const std::string& planner_id = " " );
6369
70+ [[deprecated(" Deprecated: Use new constructor implementations." )]] // clang-format off
71+ PipelinePlanner (const planning_pipeline::PlanningPipelinePtr& planning_pipeline){};
72+
6473 /* * \brief Constructor
65- * \param [in] node ROS 2 node handle
74+ * \param [in] node ROS 2 node
6675 * \param [in] pipeline_id_planner_id_map A map containing pairs of planning pipeline name and planner plugin name
6776 * for the planning requests
6877 * \param [in] planning_pipelines Optional: A map with the pipeline names and initialized corresponding planning
6978 * pipelines
79+ * \param [in] stopping_criterion_callback Callback function to stop parallel planning pipeline according to a user defined criteria
80+ * \param [in] solution_selection_function Callback function to choose the best solution when multiple pipelines are used
7081 */
7182 PipelinePlanner (const rclcpp::Node::SharedPtr& node,
7283 const std::unordered_map<std::string, std::string>& pipeline_id_planner_id_map,
7384 const std::unordered_map<std::string, planning_pipeline::PlanningPipelinePtr> planning_pipelines =
74- std::unordered_map<std::string, planning_pipeline::PlanningPipelinePtr>());
85+ std::unordered_map<std::string, planning_pipeline::PlanningPipelinePtr>(),
86+ const moveit::planning_pipeline_interfaces::StoppingCriterionFunction& stopping_criterion_callback = &moveit::planning_pipeline_interfaces::stopAtFirstSolution,
87+ const moveit::planning_pipeline_interfaces::SolutionSelectionFunction& solution_selection_function = &moveit::planning_pipeline_interfaces::getShortestSolution);
7588
76- // TODO: Deprecate
89+ [[deprecated( " Replaced with setPlannerId(pipeline_name, planner_id) " )]] // clang-format off
7790 void setPlannerId (const std::string& /* planner*/ ) { /* Do nothing */
7891 }
7992
@@ -84,9 +97,20 @@ class PipelinePlanner : public PlannerInterface
8497 */
8598 bool setPlannerId (const std::string& pipeline_name, const std::string& planner_id);
8699
100+ /* * \brief Set stopping criterion function for parallel planning
101+ * \param [in] stopping_criterion_callback New stopping criterion function that will be used
102+ */
103+ void setStoppingCriterionFunction (const moveit::planning_pipeline_interfaces::StoppingCriterionFunction& stopping_criterion_callback);
104+
105+ /* * \brief Set solution selection function for parallel planning
106+ * \param [in] solution_selection_function New solution selection that will be used
107+ */
108+ void setSolutionSelectionFunction (const moveit::planning_pipeline_interfaces::SolutionSelectionFunction& solution_selection_function);
109+
87110 /* * \brief This function is called when an MTC task that uses this solver is initialized. If no pipelines are
88111 * configured when this function is invoked, the planning pipelines named in the 'pipeline_id_planner_id_map' are
89- * initialized with the given robot model. \param [in] robot_model A robot model that is used to initialize the
112+ * initialized with the given robot model.
113+ * \param [in] robot_model A robot model that is used to initialize the
90114 * planning pipelines of this solver
91115 */
92116 void init (const moveit::core::RobotModelConstPtr& robot_model) override ;
@@ -156,6 +180,10 @@ class PipelinePlanner : public PlannerInterface
156180 /* * \brief Map of pipelines names and planning pipelines. This map is used to quickly search for a requested motion
157181 * planning pipeline when during plan(..) */
158182 std::unordered_map<std::string, planning_pipeline::PlanningPipelinePtr> planning_pipelines_;
183+
184+ moveit::planning_pipeline_interfaces::StoppingCriterionFunction stopping_criterion_callback_;
185+ moveit::planning_pipeline_interfaces::SolutionSelectionFunction solution_selection_function_;
186+
159187};
160188} // namespace solvers
161189} // namespace task_constructor
0 commit comments