Skip to content

Commit e942e9c

Browse files
committed
Revert "Enable parallel planning with PipelinePlanner (moveit#450)"
This reverts commit 0e02fca.
1 parent 8d0708c commit e942e9c

File tree

14 files changed

+194
-303
lines changed

14 files changed

+194
-303
lines changed

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

Lines changed: 33 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@
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);
5957
class PipelinePlanner : public PlannerInterface
6058
{
6159
public:
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-
14299
protected:
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

core/python/bindings/src/solvers.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,20 @@ void export_solvers(py::module& m) {
6969
from moveit.task_constructor import core
7070
7171
# Create and configure a planner instance
72-
pipelinePlanner = core.PipelinePlanner(node, 'ompl', 'PRMkConfigDefault')
72+
pipelinePlanner = core.PipelinePlanner()
73+
pipelinePlanner.planner = 'PRMkConfigDefault'
7374
pipelinePlanner.num_planning_attempts = 10
7475
)")
76+
.property<std::string>("planner", "str: Planner ID")
7577
.property<uint>("num_planning_attempts", "int: Number of planning attempts")
7678
.property<moveit_msgs::msg::WorkspaceParameters>(
7779
"workspace_parameters",
7880
":moveit_msgs:`WorkspaceParameters`: Specifies workspace box to be used for Cartesian sampling")
7981
.property<double>("goal_joint_tolerance", "float: Tolerance for reaching joint goals")
8082
.property<double>("goal_position_tolerance", "float: Tolerance for reaching position goals")
8183
.property<double>("goal_orientation_tolerance", "float: Tolerance for reaching orientation goals")
82-
.def(py::init<const rclcpp::Node::SharedPtr&, const std::string&, const std::string&>(), "node"_a,
83-
"pipeline"_a = std::string("ompl"), "planner_id"_a = std::string(""));
84+
.def(py::init<const rclcpp::Node::SharedPtr&, const std::string&>(), "node"_a,
85+
"pipeline"_a = std::string("ompl"));
8486

8587
properties::class_<JointInterpolationPlanner, PlannerInterface>(
8688
m, "JointInterpolationPlanner",

core/python/test/test_mtc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,21 @@ def test_assign_in_reference(self):
6666

6767
props["planner"] = "planner"
6868
self.assertEqual(props["planner"], "planner")
69+
self.assertEqual(planner.planner, "planner")
6970

7071
props["double"] = 3.14
7172
a = props
7273
props["double"] = 2.71
7374
self.assertEqual(a["double"], 2.71)
7475

76+
planner.planner = "other"
77+
self.assertEqual(props["planner"], "other")
78+
self.assertEqual(planner.planner, "other")
79+
7580
del planner
7681
# We can still access props, because actual destruction of planner is delayed
7782
self.assertEqual(props["goal_joint_tolerance"], 2.71)
83+
self.assertEqual(props["planner"], "other")
7884

7985
def test_iter(self):
8086
# assign values so we can iterate over them

0 commit comments

Comments
 (0)