Skip to content

Commit 7a0c429

Browse files
authored
Update tutorials for changes on moveit2 main (#785)
1 parent 8cd7875 commit 7a0c429

File tree

6 files changed

+54
-61
lines changed

6 files changed

+54
-61
lines changed

doc/examples/motion_planning_pipeline/launch/motion_planning_pipeline_tutorial.launch.py

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from launch import LaunchDescription
44
from launch_ros.actions import Node
55
from ament_index_python.packages import get_package_share_directory
6+
from moveit_configs_utils import MoveItConfigsBuilder
67

78

89
def load_file(package_name, file_path):
@@ -28,41 +29,29 @@ def load_yaml(package_name, file_path):
2829

2930

3031
def generate_launch_description():
31-
# planning_context
32-
robot_description_config = load_file(
33-
"moveit_resources_panda_description", "urdf/panda.urdf"
34-
)
35-
robot_description = {"robot_description": robot_description_config}
36-
37-
robot_description_semantic_config = load_file(
38-
"moveit_resources_panda_moveit_config", "config/panda.srdf"
39-
)
40-
robot_description_semantic = {
41-
"robot_description_semantic": robot_description_semantic_config
42-
}
4332

44-
kinematics_yaml = load_yaml(
45-
"moveit_resources_panda_moveit_config", "config/kinematics.yaml"
33+
moveit_config = (
34+
MoveItConfigsBuilder("moveit_resources_panda")
35+
.robot_description(file_path="config/panda.urdf.xacro")
36+
.planning_scene_monitor(
37+
publish_robot_description=True, publish_robot_description_semantic=True
38+
)
39+
.planning_pipelines("ompl", ["ompl"])
40+
.to_moveit_configs()
4641
)
4742

48-
# Planning Functionality
49-
ompl_planning_pipeline_config = {
50-
"planning_plugin": "ompl_interface/OMPLPlanner",
51-
"request_adapters": """default_planner_request_adapters/AddTimeOptimalParameterization default_planner_request_adapters/FixWorkspaceBounds default_planner_request_adapters/FixStartStateBounds default_planner_request_adapters/FixStartStateCollision default_planner_request_adapters/FixStartStatePathConstraints""",
52-
"start_state_max_bounds_error": 0.1,
53-
}
54-
5543
# MotionPlanningPipeline demo executable
5644
motion_planning_pipeline_demo = Node(
5745
name="motion_planning_pipeline_tutorial",
5846
package="moveit2_tutorials",
5947
executable="motion_planning_pipeline_tutorial",
6048
output="screen",
6149
parameters=[
62-
robot_description,
63-
robot_description_semantic,
64-
kinematics_yaml,
65-
ompl_planning_pipeline_config,
50+
moveit_config.robot_description,
51+
moveit_config.robot_description_semantic,
52+
moveit_config.robot_description_kinematics,
53+
moveit_config.planning_pipelines,
54+
moveit_config.joint_limits,
6655
],
6756
)
6857

doc/examples/motion_planning_pipeline/src/motion_planning_pipeline_tutorial.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ int main(int argc, char** argv)
108108
// We can now setup the PlanningPipeline object, which will use the ROS parameter server
109109
// to determine the set of request adapters and the planning plugin to use
110110
planning_pipeline::PlanningPipelinePtr planning_pipeline(
111-
new planning_pipeline::PlanningPipeline(robot_model, node, "", "planning_plugin", "request_adapters"));
111+
new planning_pipeline::PlanningPipeline(robot_model, node, "ompl"));
112112

113113
// Visualization
114114
// ^^^^^^^^^^^^^
@@ -138,6 +138,9 @@ int main(int argc, char** argv)
138138
// We will now create a motion plan request for the right arm of the Panda
139139
// specifying the desired pose of the end-effector as input.
140140
planning_interface::MotionPlanRequest req;
141+
req.pipeline_id = "ompl";
142+
req.planner_id = "RRTConnectkConfigDefault";
143+
req.allowed_planning_time = 1.0;
141144
planning_interface::MotionPlanResponse res;
142145
geometry_msgs::msg::PoseStamped pose;
143146
pose.header.frame_id = "panda_link0";
@@ -148,8 +151,8 @@ int main(int argc, char** argv)
148151

149152
// A tolerance of 0.01 m is specified in position
150153
// and 0.01 radians in orientation
151-
std::vector<double> tolerance_pose(3, 0.01);
152-
std::vector<double> tolerance_angle(3, 0.01);
154+
std::vector<double> tolerance_pose(3, 0.1);
155+
std::vector<double> tolerance_angle(3, 0.1);
153156

154157
// We will create the request as a constraint using a helper
155158
// function available from the
@@ -165,16 +168,14 @@ int main(int argc, char** argv)
165168
{
166169
planning_scene_monitor::LockedPlanningSceneRO lscene(psm);
167170
/* Now, call the pipeline and check whether planning was successful. */
168-
planning_pipeline->generatePlan(lscene, req, res);
171+
/* Check that the planning was successful */
172+
if (!planning_pipeline->generatePlan(lscene, req, res) || res.error_code.val != res.error_code.SUCCESS)
173+
{
174+
RCLCPP_ERROR(LOGGER, "Could not compute plan successfully");
175+
rclcpp::shutdown();
176+
return -1;
177+
}
169178
}
170-
/* Now, call the pipeline and check whether planning was successful. */
171-
/* Check that the planning was successful */
172-
if (res.error_code.val != res.error_code.SUCCESS)
173-
{
174-
RCLCPP_ERROR(LOGGER, "Could not compute plan successfully");
175-
return 0;
176-
}
177-
178179
// Visualize the result
179180
// ^^^^^^^^^^^^^^^^^^^^
180181
rclcpp::Publisher<moveit_msgs::msg::DisplayTrajectory>::SharedPtr display_publisher =
@@ -217,13 +218,12 @@ int main(int argc, char** argv)
217218
{
218219
planning_scene_monitor::LockedPlanningSceneRO lscene(psm);
219220
/* Now, call the pipeline and check whether planning was successful. */
220-
planning_pipeline->generatePlan(lscene, req, res);
221-
}
222-
/* Check that the planning was successful */
223-
if (res.error_code.val != res.error_code.SUCCESS)
224-
{
225-
RCLCPP_ERROR(LOGGER, "Could not compute plan successfully");
226-
return 0;
221+
if (!planning_pipeline->generatePlan(lscene, req, res) || res.error_code.val != res.error_code.SUCCESS)
222+
{
223+
RCLCPP_ERROR(LOGGER, "Could not compute plan successfully");
224+
rclcpp::shutdown();
225+
return -1;
226+
}
227227
}
228228
/* Visualize the trajectory */
229229
RCLCPP_INFO(LOGGER, "Visualizing the trajectory");
@@ -264,12 +264,12 @@ int main(int argc, char** argv)
264264
{
265265
planning_scene_monitor::LockedPlanningSceneRO lscene(psm);
266266
/* Now, call the pipeline and check whether planning was successful. */
267-
planning_pipeline->generatePlan(lscene, req, res);
268-
}
269-
if (res.error_code.val != res.error_code.SUCCESS)
270-
{
271-
RCLCPP_ERROR(LOGGER, "Could not compute plan successfully");
272-
return 0;
267+
if (!planning_pipeline->generatePlan(lscene, req, res) || res.error_code.val != res.error_code.SUCCESS)
268+
{
269+
RCLCPP_ERROR(LOGGER, "Could not compute plan successfully");
270+
rclcpp::shutdown();
271+
return -1;
272+
}
273273
}
274274
/* Visualize the trajectory */
275275
RCLCPP_INFO(LOGGER, "Visualizing the trajectory");

doc/how_to_guides/parallel_planning/config/parallel_planning_moveit_cpp.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ planning_scene_monitor_options:
1010

1111
# Define which planning pipelines are loaded by moveit_cpp. These loaded pipelines will be available for simple and parallel planning
1212
planning_pipelines:
13-
pipeline_names: ["ompl", "pilz_industrial_motion_planner", "chomp", "ompl_rrt_star"]
13+
pipeline_names: ["ompl", "pilz_industrial_motion_planner", "chomp", "ompl_2"]
1414

1515
# Configure parameters of a multi-pipeline plan request. The actual request is created in the cpp code when calling for example:
1616
# MultiPipelinePlanRequestParameters multi_pipeline_plan_request{
@@ -34,10 +34,11 @@ pilz_lin:
3434
max_acceleration_scaling_factor: 1.0
3535
planning_time: 0.8
3636

37-
chomp:
37+
chomp_planner:
3838
plan_request_params:
3939
planning_attempts: 1
4040
planning_pipeline: chomp
41+
pipeline_id: chomp
4142
max_velocity_scaling_factor: 1.0
4243
max_acceleration_scaling_factor: 1.0
4344
planning_time: 1.5
@@ -46,7 +47,7 @@ chomp:
4647
ompl_rrt_star:
4748
plan_request_params:
4849
planning_attempts: 1
49-
planning_pipeline: ompl_rrt_star # Different OMPL pipeline name!
50+
planning_pipeline: ompl_2 # Different OMPL pipeline name!
5051
planner_id: "RRTstarkConfigDefault"
5152
max_velocity_scaling_factor: 1.0
5253
max_acceleration_scaling_factor: 1.0

doc/how_to_guides/parallel_planning/launch/parallel_planning_example.launch.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def launch_setup(context, *args, **kwargs):
5656

5757
# Load additional OMPL pipeline
5858
ompl_planning_pipeline_config = {
59-
"ompl_rrt_star": {
59+
"ompl_2": {
6060
"planning_plugin": "ompl_interface/OMPLPlanner",
6161
"request_adapters": """\
6262
default_planner_request_adapters/AddTimeOptimalParameterization \
@@ -71,7 +71,7 @@ def launch_setup(context, *args, **kwargs):
7171
ompl_planning_yaml = load_yaml(
7272
"moveit_resources_panda_moveit_config", "config/ompl_planning.yaml"
7373
)
74-
ompl_planning_pipeline_config["ompl_rrt_star"].update(ompl_planning_yaml)
74+
ompl_planning_pipeline_config["ompl_2"].update(ompl_planning_yaml)
7575

7676
# Warehouse config
7777
sqlite_database = os.path.join(
@@ -96,7 +96,11 @@ def launch_setup(context, *args, **kwargs):
9696
package="moveit2_tutorials",
9797
executable="parallel_planning_example",
9898
output="screen",
99-
parameters=[moveit_config.to_dict(), warehouse_ros_config],
99+
parameters=[
100+
moveit_config.to_dict(),
101+
warehouse_ros_config,
102+
ompl_planning_pipeline_config,
103+
],
100104
)
101105

102106
# RViz

doc/how_to_guides/parallel_planning/src/parallel_planning_main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class Demo
225225
// The MultiPipelinePlanRequestParameters choose a set of planning pipelines to be used for parallel planning. Here,
226226
// we use all available pipelines but it is also possible to use a subset of pipelines.
227227
moveit_cpp::PlanningComponent::MultiPipelinePlanRequestParameters multi_pipeline_plan_request{
228-
node_, { "ompl_rrtc", "pilz_lin", "chomp", "ompl_rrt_star" }
228+
node_, { "ompl_rrtc", "pilz_lin", "chomp_planner", "ompl_rrt_star" }
229229
};
230230

231231
auto plan_solution = planning_component_->plan(multi_pipeline_plan_request, &getShortestSolution);
@@ -293,7 +293,6 @@ int main(int argc, char** argv)
293293
RCLCPP_INFO(LOGGER, "Experiment 2 - Long motion with collisions");
294294
demo.setQueryGoal();
295295
demo.planAndPrint();
296-
297296
rclcpp::shutdown();
298297
return 0;
299298
}

doc/how_to_guides/pilz_industrial_motion_planner/src/pilz_mtc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ mtc::Task MTCTaskNode::createTask()
101101

102102
// Set up 3 separate pilz planners with different IDs
103103
auto pilz_ptp_planner = std::make_shared<mtc::solvers::PipelinePlanner>(node_, "pilz_industrial_motion_planner");
104-
pilz_ptp_planner->setPlannerId("PTP");
104+
pilz_ptp_planner->setPlannerId("pilz_industrial_motion_planner", "PTP");
105105
pilz_ptp_planner->setProperty("max_velocity_scaling_factor", 0.5);
106106
pilz_ptp_planner->setProperty("max_acceleration_scaling_factor", 0.5);
107107

108108
auto pilz_lin_planner = std::make_shared<mtc::solvers::PipelinePlanner>(node_, "pilz_industrial_motion_planner");
109-
pilz_lin_planner->setPlannerId("LIN");
109+
pilz_lin_planner->setPlannerId("pilz_industrial_motion_planner", "LIN");
110110
pilz_lin_planner->setProperty("max_velocity_scaling_factor", 0.2);
111111
pilz_lin_planner->setProperty("max_acceleration_scaling_factor", 0.2);
112112

113113
auto pilz_circ_planner = std::make_shared<mtc::solvers::PipelinePlanner>(node_, "pilz_industrial_motion_planner");
114-
pilz_circ_planner->setPlannerId("CIRC");
114+
pilz_circ_planner->setPlannerId("pilz_industrial_motion_planner", "CIRC");
115115
pilz_circ_planner->setProperty("max_velocity_scaling_factor", 0.3);
116116
pilz_circ_planner->setProperty("max_acceleration_scaling_factor", 0.3);
117117

0 commit comments

Comments
 (0)