|
1 |
| -import os |
2 |
| -import yaml |
3 | 1 | from launch import LaunchDescription
|
4 | 2 | from launch_ros.actions import Node
|
5 |
| -from ament_index_python.packages import get_package_share_directory |
6 |
| - |
7 |
| - |
8 |
| -def load_file(package_name, file_path): |
9 |
| - package_path = get_package_share_directory(package_name) |
10 |
| - absolute_file_path = os.path.join(package_path, file_path) |
11 |
| - |
12 |
| - try: |
13 |
| - with open(absolute_file_path, "r") as file: |
14 |
| - return file.read() |
15 |
| - except EnvironmentError: # parent of IOError, OSError *and* WindowsError where available |
16 |
| - return None |
17 |
| - |
18 |
| - |
19 |
| -def load_yaml(package_name, file_path): |
20 |
| - package_path = get_package_share_directory(package_name) |
21 |
| - absolute_file_path = os.path.join(package_path, file_path) |
22 |
| - |
23 |
| - try: |
24 |
| - with open(absolute_file_path, "r") as file: |
25 |
| - return yaml.safe_load(file) |
26 |
| - except EnvironmentError: # parent of IOError, OSError *and* WindowsError where available |
27 |
| - return None |
| 3 | +from moveit_configs_utils import MoveItConfigsBuilder |
28 | 4 |
|
29 | 5 |
|
30 | 6 | def generate_launch_description():
|
31 |
| - robot_description_config = load_file( |
32 |
| - "moveit_resources_panda_description", "urdf/panda.urdf" |
| 7 | + moveit_config = ( |
| 8 | + MoveItConfigsBuilder("moveit_resources_panda") |
| 9 | + .robot_description(file_path="config/panda.urdf.xacro") |
| 10 | + .robot_description_semantic(file_path="config/panda.srdf") |
| 11 | + .trajectory_execution(file_path="config/moveit_controllers.yaml") |
| 12 | + .planning_pipelines(pipelines=["ompl"]) |
| 13 | + .to_moveit_configs() |
33 | 14 | )
|
34 |
| - robot_description = {"robot_description": robot_description_config} |
35 |
| - |
36 |
| - robot_description_semantic_config = load_file( |
37 |
| - "moveit_resources_panda_moveit_config", "config/panda.srdf" |
38 |
| - ) |
39 |
| - robot_description_semantic = { |
40 |
| - "robot_description_semantic": robot_description_semantic_config |
41 |
| - } |
42 |
| - |
43 |
| - kinematics_yaml = load_yaml( |
44 |
| - "moveit_resources_panda_moveit_config", "config/kinematics.yaml" |
45 |
| - ) |
46 |
| - |
47 |
| - planning_yaml = load_yaml( |
48 |
| - "moveit_resources_panda_moveit_config", "config/ompl_planning.yaml" |
49 |
| - ) |
50 |
| - |
51 |
| - planning_plugin = {"planning_plugin": "ompl_interface/OMPLPlanner"} |
52 | 15 |
|
53 | 16 | return LaunchDescription(
|
54 | 17 | [
|
55 | 18 | Node(
|
56 | 19 | package="moveit2_tutorials",
|
57 | 20 | executable="motion_planning_api_tutorial",
|
58 | 21 | name="motion_planning_api_tutorial",
|
59 |
| - parameters=[ |
60 |
| - robot_description, |
61 |
| - robot_description_semantic, |
62 |
| - kinematics_yaml, |
63 |
| - planning_yaml, |
64 |
| - planning_plugin, |
65 |
| - ], |
| 22 | + output="screen", |
| 23 | + parameters=[moveit_config.to_dict()], |
66 | 24 | )
|
67 | 25 | ]
|
68 | 26 | )
|
0 commit comments