@@ -61,30 +61,35 @@ class PipelinePlanner : public PlannerInterface
61
61
public:
62
62
/* * Simple Constructor to use only a single pipeline
63
63
* \param [in] node ROS 2 node
64
- * \param [in] pipeline_name Name of the planning pipeline to be used.
65
- * This is also the assumed namespace where the parameters of this pipeline can be found
66
- * \param [in] planner_id Planner id to be used for planning. Empty string means default.
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
67
66
*/
68
67
PipelinePlanner (const rclcpp::Node::SharedPtr& node, const std::string& pipeline_name = " ompl" ,
69
- const std::string& planner_id = " " )
70
- : PipelinePlanner(node, { { pipeline_name, planner_id } }) {}
68
+ const std::string& planner_id = " " );
71
69
72
70
/* * \brief Constructor
73
71
* \param [in] node ROS 2 node
74
- * \param [in] pipeline_id_planner_id_map map containing pairs of pipeline and plugin names to be used for planning
75
- * \param [in] stopping_criterion_callback callback to decide when to stop parallel planning
76
- * \param [in] solution_selection_function callback to choose the best solution from multiple ran pipelines
72
+ * \param [in] pipeline_id_planner_id_map A map containing pairs of planning pipeline name and planner plugin name
73
+ * for the planning requests
74
+ * \param [in] planning_pipelines Optional: A map with the pipeline names and initialized corresponding planning
75
+ * pipelines
76
+ * \param [in] stopping_criterion_callback Callback function to stop parallel planning pipeline according to a user
77
+ * defined criteria
78
+ * \param [in] solution_selection_function Callback function to choose the best solution when
79
+ * multiple pipelines are used
77
80
*/
78
81
PipelinePlanner (
79
82
const rclcpp::Node::SharedPtr& node,
80
83
const std::unordered_map<std::string, std::string>& pipeline_id_planner_id_map,
84
+ const std::unordered_map<std::string, planning_pipeline::PlanningPipelinePtr>& planning_pipelines =
85
+ std::unordered_map<std::string, planning_pipeline::PlanningPipelinePtr>(),
81
86
const moveit::planning_pipeline_interfaces::StoppingCriterionFunction& stopping_criterion_callback = nullptr ,
82
87
const moveit::planning_pipeline_interfaces::SolutionSelectionFunction& solution_selection_function =
83
88
&moveit::planning_pipeline_interfaces::getShortestSolution);
84
89
85
- /* * \brief Set the planner id for a specific planning pipeline
86
- * \param [in] pipeline_name Name of the to-be-used planning pipeline
87
- * \param [in] planner_id Name of the to-be- used planner ID
90
+ /* * \brief Set the planner id for a specific planning pipeline for the planning requests
91
+ * \param [in] pipeline_name Name of the planning pipeline for which the planner id is set
92
+ * \param [in] planner_id Name of the planner ID that should be used by the planning pipeline
88
93
* \return true if the pipeline exists and the corresponding ID is set successfully
89
94
*/
90
95
bool setPlannerId (const std::string& pipeline_name, const std::string& planner_id);
@@ -101,26 +106,31 @@ class PipelinePlanner : public PlannerInterface
101
106
void setSolutionSelectionFunction (
102
107
const moveit::planning_pipeline_interfaces::SolutionSelectionFunction& solution_selection_function);
103
108
104
- /* * \brief If not yet done, initialize pipelines from pipeline_id_planner_id_map
105
- * \param [in] robot_model robot model used to initialize the planning pipelines of this solver
109
+ /* * \brief This function is called when an MTC task that uses this solver is initialized. If no pipelines are
110
+ * configured when this function is invoked, the planning pipelines named in the 'pipeline_id_planner_id_map' are
111
+ * initialized with the given robot model.
112
+ * \param [in] robot_model A robot model that is used to initialize the
113
+ * planning pipelines of this solver
106
114
*/
107
115
void init (const moveit::core::RobotModelConstPtr& robot_model) override ;
108
116
109
- /* * \brief Plan a trajectory from a planning scene 'from' to scene 'to'
117
+ /* *
118
+ * \brief Plan a trajectory from a planning scene 'from' to scene 'to'
110
119
* \param [in] from Start planning scene
111
120
* \param [in] to Goal planning scene (used to create goal constraints)
112
121
* \param [in] joint_model_group Group of joints for which this trajectory is created
113
122
* \param [in] timeout Maximum planning timeout for an individual stage that is using the pipeline planner in seconds
114
123
* \param [in] result Reference to the location where the created trajectory is stored if planning is successful
115
124
* \param [in] path_constraints Path contraints for the planning problem
116
- * \return true If the solver found a successful solution for the given planning problem
125
+ * \return MoveItErrorCode - Return MoveItErrorCodes::SUCCESS if solver found a successful solution. Otherwise,
126
+ * return an appropriate error type and message explaining why it failed.
117
127
*/
118
- Result plan ( const planning_scene::PlanningSceneConstPtr& from, const planning_scene::PlanningSceneConstPtr& to,
119
- const core::JointModelGroup* joint_model_group, double timeout ,
120
- robot_trajectory::RobotTrajectoryPtr& result,
121
- const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override ;
128
+ MoveItErrorCode
129
+ plan ( const planning_scene::PlanningSceneConstPtr& from, const planning_scene::PlanningSceneConstPtr& to ,
130
+ const core::JointModelGroup* joint_model_group, double timeout, robot_trajectory::RobotTrajectoryPtr& result,
131
+ const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override ;
122
132
123
- /* * \brief Plan a trajectory from a planning scene 'from' to a Cartesian target pose with an offset
133
+ /* * \brief Plan a trajectory from a planning scene 'from' to a target pose with an offset
124
134
* \param [in] from Start planning scene
125
135
* \param [in] link Link for which a target pose is given
126
136
* \param [in] offset Offset to be applied to a given target pose
@@ -129,37 +139,55 @@ class PipelinePlanner : public PlannerInterface
129
139
* \param [in] timeout Maximum planning timeout for an individual stage that is using the pipeline planner in seconds
130
140
* \param [in] result Reference to the location where the created trajectory is stored if planning is successful
131
141
* \param [in] path_constraints Path contraints for the planning problem
132
- * \return true If the solver found a successful solution for the given planning problem
142
+ * \return MoveItErrorCode - Return MoveItErrorCodes::SUCCESS if solver found a successful solution. Otherwise,
143
+ * return an appropriate error type and message explaining why it failed.
133
144
*/
134
- Result plan (const planning_scene::PlanningSceneConstPtr& from, const moveit::core::LinkModel& link,
135
- const Eigen::Isometry3d& offset, const Eigen::Isometry3d& target,
136
- const moveit::core::JointModelGroup* joint_model_group, double timeout,
137
- robot_trajectory::RobotTrajectoryPtr& result,
138
- const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override ;
139
-
140
- std::string getPlannerId () const override { return last_successful_planner_; }
145
+ MoveItErrorCode
146
+ plan (const planning_scene::PlanningSceneConstPtr& from, const moveit::core::LinkModel& link,
147
+ const Eigen::Isometry3d& offset, const Eigen::Isometry3d& target,
148
+ const moveit::core::JointModelGroup* joint_model_group, double timeout,
149
+ robot_trajectory::RobotTrajectoryPtr& result,
150
+ const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override ;
151
+
152
+ /* *
153
+ * \brief Get planner name
154
+ * \return Name of the last successful planner
155
+ */
156
+ std::string getPlannerId () const override ;
141
157
142
158
protected:
143
- /* * \brief Actual plan() implementation, targeting the given goal_constraints.
159
+ /* * \brief Function that actually uses the planning pipelines to solve the given planning problem. It is called by
160
+ * the public plan function after the goal constraints are generated. This function uses a predefined number of
161
+ * planning pipelines in parallel to solve the planning problem and choose the best (user-defined) solution.
144
162
* \param [in] planning_scene Scene for which the planning should be solved
145
- * \param [in] joint_model_group Group of joints for which this trajectory is created
146
- * \param [in] goal_constraints Set of constraints that need to be satisfied by the solution
163
+ * \param [in] joint_model_group
164
+ * Group of joints for which this trajectory is created
165
+ * \param [in] goal_constraints Set of constraints that need to
166
+ * be satisfied by the solution
147
167
* \param [in] timeout Maximum planning timeout for an individual stage that is using the pipeline planner in seconds
148
- * \param [in] result Reference to the location where the created trajectory is stored if planning is successful
149
- * \param [in] path_constraints Path contraints for the planning problem
150
- * \return true if the solver found a successful solution for the given planning problem
168
+ * \param [in] result Reference to the location where the created
169
+ * trajectory is stored if planning is successful
170
+ * \param [in] path_constraints Path contraints for the planning
171
+ * problem
172
+ * \return true If the solver found a successful solution for the given planning problem
151
173
*/
152
- Result plan (const planning_scene::PlanningSceneConstPtr& planning_scene,
153
- const moveit::core::JointModelGroup* joint_model_group,
154
- const moveit_msgs::msg::Constraints& goal_constraints, double timeout,
155
- robot_trajectory::RobotTrajectoryPtr& result,
156
- const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints());
174
+ MoveItErrorCode plan (const planning_scene::PlanningSceneConstPtr& planning_scene,
175
+ const moveit::core::JointModelGroup* joint_model_group,
176
+ const moveit_msgs::msg::Constraints& goal_constraints, double timeout,
177
+ robot_trajectory::RobotTrajectoryPtr& result,
178
+ const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints());
157
179
158
180
rclcpp::Node::SharedPtr node_;
159
181
160
182
std::string last_successful_planner_;
161
183
162
- /* * \brief Map of instantiated (and named) planning pipelines. */
184
+ /* * \brief Map of pipeline names (ids) and their corresponding planner ids. The planning problem is solved for every
185
+ * pipeline-planner pair in this map. If no pipelines are passed via constructor argument, the pipeline names are
186
+ * used to initialize a set of planning pipelines. */
187
+ std::unordered_map<std::string, std::string> pipeline_id_planner_id_map_;
188
+
189
+ /* * \brief Map of pipelines names and planning pipelines. This map is used to quickly search for a requested motion
190
+ * planning pipeline when during plan(..) */
163
191
std::unordered_map<std::string, planning_pipeline::PlanningPipelinePtr> planning_pipelines_;
164
192
165
193
moveit::planning_pipeline_interfaces::StoppingCriterionFunction stopping_criterion_callback_;
0 commit comments