Skip to content

Commit e33d793

Browse files
committed
Revert PipelinePlanner changes, use MoveItErrorCode and minor cleanups
1 parent e1b891b commit e33d793

12 files changed

+242
-199
lines changed

core/include/moveit/task_constructor/solvers/cartesian_path.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ class CartesianPath : public PlannerInterface
6363

6464
void init(const moveit::core::RobotModelConstPtr& robot_model) override;
6565

66-
Result plan(const planning_scene::PlanningSceneConstPtr& from, const planning_scene::PlanningSceneConstPtr& to,
66+
MoveItErrorCode plan(const planning_scene::PlanningSceneConstPtr& from, const planning_scene::PlanningSceneConstPtr& to,
6767
const moveit::core::JointModelGroup* jmg, double timeout, robot_trajectory::RobotTrajectoryPtr& result,
6868
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override;
6969

70-
Result plan(const planning_scene::PlanningSceneConstPtr& from, const moveit::core::LinkModel& link,
70+
MoveItErrorCode plan(const planning_scene::PlanningSceneConstPtr& from, const moveit::core::LinkModel& link,
7171
const Eigen::Isometry3d& offset, const Eigen::Isometry3d& target, const moveit::core::JointModelGroup* jmg,
7272
double timeout, robot_trajectory::RobotTrajectoryPtr& result,
7373
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override;

core/include/moveit/task_constructor/solvers/joint_interpolation.h

+9-7
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,16 @@ class JointInterpolationPlanner : public PlannerInterface
5858

5959
void init(const moveit::core::RobotModelConstPtr& robot_model) override;
6060

61-
Result plan(const planning_scene::PlanningSceneConstPtr& from, const planning_scene::PlanningSceneConstPtr& to,
62-
const core::JointModelGroup* jmg, double timeout, robot_trajectory::RobotTrajectoryPtr& result,
63-
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override;
61+
MoveItErrorCode
62+
plan(const planning_scene::PlanningSceneConstPtr& from, const planning_scene::PlanningSceneConstPtr& to,
63+
const core::JointModelGroup* jmg, double timeout, robot_trajectory::RobotTrajectoryPtr& result,
64+
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override;
6465

65-
Result plan(const planning_scene::PlanningSceneConstPtr& from, const moveit::core::LinkModel& link,
66-
const Eigen::Isometry3d& offset, const Eigen::Isometry3d& target,
67-
const moveit::core::JointModelGroup* jmg, double timeout, robot_trajectory::RobotTrajectoryPtr& result,
68-
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override;
66+
MoveItErrorCode
67+
plan(const planning_scene::PlanningSceneConstPtr& from, const moveit::core::LinkModel& link,
68+
const Eigen::Isometry3d& offset, const Eigen::Isometry3d& target, const moveit::core::JointModelGroup* jmg,
69+
double timeout, robot_trajectory::RobotTrajectoryPtr& result,
70+
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override;
6971

7072
std::string getPlannerId() const override { return "JointInterpolationPlanner"; }
7173
};

core/include/moveit/task_constructor/solvers/multi_planner.h

+9-7
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,16 @@ class MultiPlanner : public PlannerInterface, public std::vector<solvers::Planne
6363

6464
void init(const moveit::core::RobotModelConstPtr& robot_model) override;
6565

66-
Result plan(const planning_scene::PlanningSceneConstPtr& from, const planning_scene::PlanningSceneConstPtr& to,
67-
const moveit::core::JointModelGroup* jmg, double timeout, robot_trajectory::RobotTrajectoryPtr& result,
68-
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override;
66+
MoveItErrorCode
67+
plan(const planning_scene::PlanningSceneConstPtr& from, const planning_scene::PlanningSceneConstPtr& to,
68+
const moveit::core::JointModelGroup* jmg, double timeout, robot_trajectory::RobotTrajectoryPtr& result,
69+
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override;
6970

70-
Result plan(const planning_scene::PlanningSceneConstPtr& from, const moveit::core::LinkModel& link,
71-
const Eigen::Isometry3d& offset, const Eigen::Isometry3d& target,
72-
const moveit::core::JointModelGroup* jmg, double timeout, robot_trajectory::RobotTrajectoryPtr& result,
73-
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override;
71+
MoveItErrorCode
72+
plan(const planning_scene::PlanningSceneConstPtr& from, const moveit::core::LinkModel& link,
73+
const Eigen::Isometry3d& offset, const Eigen::Isometry3d& target, const moveit::core::JointModelGroup* jmg,
74+
double timeout, robot_trajectory::RobotTrajectoryPtr& result,
75+
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override;
7476
};
7577
} // namespace solvers
7678
} // namespace task_constructor

core/include/moveit/task_constructor/solvers/pipeline_planner.h

+68-40
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,35 @@ class PipelinePlanner : public PlannerInterface
6161
public:
6262
/** Simple Constructor to use only a single pipeline
6363
* \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
6766
*/
6867
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 = "");
7169

7270
/** \brief Constructor
7371
* \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
7780
*/
7881
PipelinePlanner(
7982
const rclcpp::Node::SharedPtr& node,
8083
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>(),
8186
const moveit::planning_pipeline_interfaces::StoppingCriterionFunction& stopping_criterion_callback = nullptr,
8287
const moveit::planning_pipeline_interfaces::SolutionSelectionFunction& solution_selection_function =
8388
&moveit::planning_pipeline_interfaces::getShortestSolution);
8489

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
8893
* \return true if the pipeline exists and the corresponding ID is set successfully
8994
*/
9095
bool setPlannerId(const std::string& pipeline_name, const std::string& planner_id);
@@ -101,26 +106,31 @@ class PipelinePlanner : public PlannerInterface
101106
void setSolutionSelectionFunction(
102107
const moveit::planning_pipeline_interfaces::SolutionSelectionFunction& solution_selection_function);
103108

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
106114
*/
107115
void init(const moveit::core::RobotModelConstPtr& robot_model) override;
108116

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'
110119
* \param [in] from Start planning scene
111120
* \param [in] to Goal planning scene (used to create goal constraints)
112121
* \param [in] joint_model_group Group of joints for which this trajectory is created
113122
* \param [in] timeout Maximum planning timeout for an individual stage that is using the pipeline planner in seconds
114123
* \param [in] result Reference to the location where the created trajectory is stored if planning is successful
115124
* \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.
117127
*/
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;
122132

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
124134
* \param [in] from Start planning scene
125135
* \param [in] link Link for which a target pose is given
126136
* \param [in] offset Offset to be applied to a given target pose
@@ -129,37 +139,55 @@ class PipelinePlanner : public PlannerInterface
129139
* \param [in] timeout Maximum planning timeout for an individual stage that is using the pipeline planner in seconds
130140
* \param [in] result Reference to the location where the created trajectory is stored if planning is successful
131141
* \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.
133144
*/
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;
141157

142158
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.
144162
* \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
147167
* \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
151173
*/
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());
157179

158180
rclcpp::Node::SharedPtr node_;
159181

160182
std::string last_successful_planner_;
161183

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(..) */
163191
std::unordered_map<std::string, planning_pipeline::PlanningPipelinePtr> planning_pipelines_;
164192

165193
moveit::planning_pipeline_interfaces::StoppingCriterionFunction stopping_criterion_callback_;

core/include/moveit/task_constructor/solvers/planner_interface.h

+13-17
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <moveit/macros/class_forward.h>
4242
#include <moveit_msgs/msg/constraints.hpp>
4343
#include <moveit/task_constructor/properties.h>
44+
#include <moveit/utils/moveit_error_code.h>
4445
#include <Eigen/Geometry>
4546

4647
namespace planning_scene {
@@ -64,21 +65,16 @@ namespace moveit {
6465
namespace task_constructor {
6566
namespace solvers {
6667

68+
using MoveItErrorCode = moveit::core::MoveItErrorCode;
69+
using MoveItErrorCodes = moveit_msgs::msg::MoveItErrorCodes;
70+
6771
MOVEIT_CLASS_FORWARD(PlannerInterface);
6872
class PlannerInterface
6973
{
7074
// these properties take precedence over stage properties
7175
PropertyMap properties_;
7276

7377
public:
74-
struct Result
75-
{
76-
bool success;
77-
std::string message;
78-
79-
operator bool() const { return success; }
80-
};
81-
8278
PlannerInterface();
8379
virtual ~PlannerInterface() {}
8480

@@ -96,17 +92,17 @@ class PlannerInterface
9692
virtual void init(const moveit::core::RobotModelConstPtr& robot_model) = 0;
9793

9894
/// plan trajectory between to robot states
99-
virtual Result plan(const planning_scene::PlanningSceneConstPtr& from,
100-
const planning_scene::PlanningSceneConstPtr& to, const moveit::core::JointModelGroup* jmg,
101-
double timeout, robot_trajectory::RobotTrajectoryPtr& result,
102-
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) = 0;
95+
virtual MoveItErrorCode
96+
plan(const planning_scene::PlanningSceneConstPtr& from, const planning_scene::PlanningSceneConstPtr& to,
97+
const moveit::core::JointModelGroup* jmg, double timeout, robot_trajectory::RobotTrajectoryPtr& result,
98+
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) = 0;
10399

104100
/// plan trajectory from current robot state to Cartesian target, such that pose(link)*offset == target
105-
virtual Result plan(const planning_scene::PlanningSceneConstPtr& from, const moveit::core::LinkModel& link,
106-
const Eigen::Isometry3d& offset, const Eigen::Isometry3d& target,
107-
const moveit::core::JointModelGroup* jmg, double timeout,
108-
robot_trajectory::RobotTrajectoryPtr& result,
109-
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) = 0;
101+
virtual MoveItErrorCode
102+
plan(const planning_scene::PlanningSceneConstPtr& from, const moveit::core::LinkModel& link,
103+
const Eigen::Isometry3d& offset, const Eigen::Isometry3d& target, const moveit::core::JointModelGroup* jmg,
104+
double timeout, robot_trajectory::RobotTrajectoryPtr& result,
105+
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) = 0;
110106

111107
// get name of the planner
112108
virtual std::string getPlannerId() const = 0;

0 commit comments

Comments
 (0)