3232 * POSSIBILITY OF SUCH DAMAGE.
3333 *********************************************************************/
3434
35- /* Authors: Robert Haschke, Sebastian Jahr
36- Description: Solver that uses a set of MoveIt PlanningPipelines to solve a given planning problem.
35+ /* Authors: Robert Haschke
36+ Desc: plan using MoveIt's PlanningPipeline
3737*/
3838
3939#pragma once
4040
4141#include < moveit/task_constructor/solvers/planner_interface.h>
42- #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>
42+ #include < moveit_msgs/msg/motion_plan_request.hpp>
4543#include < rclcpp/node.hpp>
4644#include < moveit/macros/class_forward.h>
4745
@@ -59,111 +57,52 @@ MOVEIT_CLASS_FORWARD(PipelinePlanner);
5957class PipelinePlanner : public PlannerInterface
6058{
6159public:
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.
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.
60+ struct Specification
61+ {
62+ moveit::core::RobotModelConstPtr model;
63+ std::string ns{ " ompl" };
64+ std::string pipeline{ " ompl" };
65+ std::string adapter_param{ " request_adapters" };
66+ };
67+
68+ static planning_pipeline::PlanningPipelinePtr create (const rclcpp::Node::SharedPtr& node,
69+ const moveit::core::RobotModelConstPtr& model) {
70+ Specification spec;
71+ spec.model = model;
72+ return create (node, spec);
73+ }
74+
75+ static planning_pipeline::PlanningPipelinePtr create (const rclcpp::Node::SharedPtr& node, const Specification& spec);
76+
77+ /* *
78+ *
79+ * @param node used to load the parameters for the planning pipeline
6780 */
68- 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 } }) {}
71-
72- /* * \brief Constructor
73- * \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
77- */
78- PipelinePlanner (
79- const rclcpp::Node::SharedPtr& node,
80- const std::unordered_map<std::string, std::string>& pipeline_id_planner_id_map,
81- const moveit::planning_pipeline_interfaces::StoppingCriterionFunction& stopping_criterion_callback = nullptr ,
82- const moveit::planning_pipeline_interfaces::SolutionSelectionFunction& solution_selection_function =
83- &moveit::planning_pipeline_interfaces::getShortestSolution);
84-
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
88- * \return true if the pipeline exists and the corresponding ID is set successfully
89- */
90- bool setPlannerId (const std::string& pipeline_name, const std::string& planner_id);
81+ PipelinePlanner (const rclcpp::Node::SharedPtr& node, const std::string& pipeline = " ompl" );
9182
92- /* * \brief Set stopping criterion function for parallel planning
93- * \param [in] stopping_criterion_callback New stopping criterion function that will be used
94- */
95- void setStoppingCriterionFunction (
96- const moveit::planning_pipeline_interfaces::StoppingCriterionFunction& stopping_criterion_callback);
83+ PipelinePlanner (const planning_pipeline::PlanningPipelinePtr& planning_pipeline);
9784
98- /* * \brief Set solution selection function for parallel planning
99- * \param [in] solution_selection_function New solution selection that will be used
100- */
101- void setSolutionSelectionFunction (
102- const moveit::planning_pipeline_interfaces::SolutionSelectionFunction& solution_selection_function);
85+ void setPlannerId (const std::string& planner) { setProperty (" planner" , planner); }
86+ std::string getPlannerId () const override { return properties ().get <std::string>(" planner" ); }
10387
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
106- */
10788 void init (const moveit::core::RobotModelConstPtr& robot_model) override ;
10889
109- /* * \brief Plan a trajectory from a planning scene 'from' to scene 'to'
110- * \param [in] from Start planning scene
111- * \param [in] to Goal planning scene (used to create goal constraints)
112- * \param [in] joint_model_group Group of joints for which this trajectory is created
113- * \param [in] timeout Maximum planning timeout for an individual stage that is using the pipeline planner in seconds
114- * \param [in] result Reference to the location where the created trajectory is stored if planning is successful
115- * \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
117- */
11890 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,
91+ const core::JointModelGroup* jmg, double timeout, robot_trajectory::RobotTrajectoryPtr& result,
12192 const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override ;
12293
123- /* * \brief Plan a trajectory from a planning scene 'from' to a Cartesian target pose with an offset
124- * \param [in] from Start planning scene
125- * \param [in] link Link for which a target pose is given
126- * \param [in] offset Offset to be applied to a given target pose
127- * \param [in] target Target pose
128- * \param [in] joint_model_group Group of joints for which this trajectory is created
129- * \param [in] timeout Maximum planning timeout for an individual stage that is using the pipeline planner in seconds
130- * \param [in] result Reference to the location where the created trajectory is stored if planning is successful
131- * \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
133- */
13494 Result plan (const planning_scene::PlanningSceneConstPtr& from, const moveit::core::LinkModel& link,
13595 const Eigen::Isometry3d& offset, const Eigen::Isometry3d& target,
136- const moveit::core::JointModelGroup* joint_model_group, double timeout,
137- robot_trajectory::RobotTrajectoryPtr& result,
96+ const moveit::core::JointModelGroup* jmg, double timeout, robot_trajectory::RobotTrajectoryPtr& result,
13897 const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override ;
13998
140- std::string getPlannerId () const override { return last_successful_planner_; }
141-
14299protected:
143- /* * \brief Actual plan() implementation, targeting the given goal_constraints.
144- * \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
147- * \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
151- */
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());
100+ Result plan (const planning_scene::PlanningSceneConstPtr& from, const moveit_msgs::msg::MotionPlanRequest& req,
101+ robot_trajectory::RobotTrajectoryPtr& result);
157102
103+ std::string pipeline_name_;
104+ planning_pipeline::PlanningPipelinePtr planner_;
158105 rclcpp::Node::SharedPtr node_;
159-
160- std::string last_successful_planner_;
161-
162- /* * \brief Map of instantiated (and named) planning pipelines. */
163- std::unordered_map<std::string, planning_pipeline::PlanningPipelinePtr> planning_pipelines_;
164-
165- moveit::planning_pipeline_interfaces::StoppingCriterionFunction stopping_criterion_callback_;
166- moveit::planning_pipeline_interfaces::SolutionSelectionFunction solution_selection_function_;
167106};
168107} // namespace solvers
169108} // namespace task_constructor
0 commit comments