1
1
import os
2
- import yaml
3
2
from launch import LaunchDescription
4
3
from launch .actions import DeclareLaunchArgument
5
4
from launch .substitutions import LaunchConfiguration
6
5
from launch .conditions import IfCondition , UnlessCondition
7
6
from launch_ros .actions import Node
8
7
from launch .actions import ExecuteProcess
9
8
from ament_index_python .packages import get_package_share_directory
10
- import xacro
11
-
12
-
13
- def load_file (package_name , file_path ):
14
- package_path = get_package_share_directory (package_name )
15
- absolute_file_path = os .path .join (package_path , file_path )
16
-
17
- try :
18
- with open (absolute_file_path , "r" ) as file :
19
- return file .read ()
20
- except EnvironmentError : # parent of IOError, OSError *and* WindowsError where available
21
- return None
22
-
23
-
24
- def load_yaml (package_name , file_path ):
25
- package_path = get_package_share_directory (package_name )
26
- absolute_file_path = os .path .join (package_path , file_path )
27
-
28
- try :
29
- with open (absolute_file_path , "r" ) as file :
30
- return yaml .safe_load (file )
31
- except EnvironmentError : # parent of IOError, OSError *and* WindowsError where available
32
- return None
9
+ from moveit_configs_utils import MoveItConfigsBuilder
33
10
34
11
35
12
def generate_launch_description ():
@@ -40,77 +17,19 @@ def generate_launch_description():
40
17
)
41
18
42
19
# planning_context
43
- robot_description_config = xacro .process_file (
44
- os .path .join (
45
- get_package_share_directory ("moveit_resources_panda_moveit_config" ),
46
- "config" ,
47
- "panda.urdf.xacro" ,
48
- )
49
- )
50
- robot_description = {"robot_description" : robot_description_config .toxml ()}
51
-
52
- robot_description_semantic_config = load_file (
53
- "moveit_resources_panda_moveit_config" , "config/panda.srdf"
54
- )
55
- robot_description_semantic = {
56
- "robot_description_semantic" : robot_description_semantic_config
57
- }
58
-
59
- kinematics_yaml = load_yaml (
60
- "moveit_resources_panda_moveit_config" , "config/kinematics.yaml"
61
- )
62
- robot_description_kinematics = {"robot_description_kinematics" : kinematics_yaml }
63
-
64
- # Planning Functionality
65
- ompl_planning_pipeline_config = {
66
- "move_group" : {
67
- "planning_plugin" : "ompl_interface/OMPLPlanner" ,
68
- "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""" ,
69
- "start_state_max_bounds_error" : 0.1 ,
70
- }
71
- }
72
- ompl_planning_yaml = load_yaml (
73
- "moveit_resources_panda_moveit_config" , "config/ompl_planning.yaml"
74
- )
75
- ompl_planning_pipeline_config ["move_group" ].update (ompl_planning_yaml )
76
-
77
- # Trajectory Execution Functionality
78
- moveit_simple_controllers_yaml = load_yaml (
79
- "moveit_resources_panda_moveit_config" , "config/moveit_controllers.yaml"
20
+ moveit_config = (
21
+ MoveItConfigsBuilder ("moveit_resources_panda" )
22
+ .robot_description (file_path = "config/panda.urdf.xacro" )
23
+ .trajectory_execution (file_path = "config/gripper_moveit_controllers.yaml" )
24
+ .to_moveit_configs ()
80
25
)
81
- moveit_controllers = {
82
- "moveit_simple_controller_manager" : moveit_simple_controllers_yaml ,
83
- "moveit_controller_manager" : "moveit_simple_controller_manager/MoveItSimpleControllerManager" ,
84
- }
85
-
86
- trajectory_execution = {
87
- "moveit_manage_controllers" : True ,
88
- "trajectory_execution.allowed_execution_duration_scaling" : 1.2 ,
89
- "trajectory_execution.allowed_goal_duration_margin" : 0.5 ,
90
- "trajectory_execution.allowed_start_tolerance" : 0.01 ,
91
- }
92
-
93
- planning_scene_monitor_parameters = {
94
- "publish_planning_scene" : True ,
95
- "publish_geometry_updates" : True ,
96
- "publish_state_updates" : True ,
97
- "publish_transforms_updates" : True ,
98
- }
99
26
100
27
# Start the actual move_group node/action server
101
28
run_move_group_node = Node (
102
29
package = "moveit_ros_move_group" ,
103
30
executable = "move_group" ,
104
31
output = "screen" ,
105
- parameters = [
106
- robot_description ,
107
- robot_description_semantic ,
108
- kinematics_yaml ,
109
- ompl_planning_pipeline_config ,
110
- trajectory_execution ,
111
- moveit_controllers ,
112
- planning_scene_monitor_parameters ,
113
- ],
32
+ parameters = [moveit_config .to_dict ()],
114
33
)
115
34
116
35
# RViz
@@ -125,10 +44,10 @@ def generate_launch_description():
125
44
output = "log" ,
126
45
arguments = ["-d" , rviz_empty_config ],
127
46
parameters = [
128
- robot_description ,
129
- robot_description_semantic ,
130
- ompl_planning_pipeline_config ,
131
- kinematics_yaml ,
47
+ moveit_config . robot_description ,
48
+ moveit_config . robot_description_semantic ,
49
+ moveit_config . robot_description_kinematics ,
50
+ moveit_config . planning_pipelines ,
132
51
],
133
52
condition = IfCondition (tutorial_mode ),
134
53
)
@@ -139,10 +58,10 @@ def generate_launch_description():
139
58
output = "log" ,
140
59
arguments = ["-d" , rviz_full_config ],
141
60
parameters = [
142
- robot_description ,
143
- robot_description_semantic ,
144
- ompl_planning_pipeline_config ,
145
- kinematics_yaml ,
61
+ moveit_config . robot_description ,
62
+ moveit_config . robot_description_semantic ,
63
+ moveit_config . robot_description_kinematics ,
64
+ moveit_config . planning_pipelines ,
146
65
],
147
66
condition = UnlessCondition (tutorial_mode ),
148
67
)
@@ -162,7 +81,7 @@ def generate_launch_description():
162
81
executable = "robot_state_publisher" ,
163
82
name = "robot_state_publisher" ,
164
83
output = "both" ,
165
- parameters = [robot_description ],
84
+ parameters = [moveit_config . robot_description ],
166
85
)
167
86
168
87
# ros2_control using FakeSystem as hardware
@@ -174,7 +93,7 @@ def generate_launch_description():
174
93
ros2_control_node = Node (
175
94
package = "controller_manager" ,
176
95
executable = "ros2_control_node" ,
177
- parameters = [robot_description , ros2_controllers_path ],
96
+ parameters = [moveit_config . robot_description , ros2_controllers_path ],
178
97
output = "both" ,
179
98
)
180
99
0 commit comments