moveit2
The MoveIt Motion Planning Framework for ROS 2.
pose_tracking_example.launch.py
Go to the documentation of this file.
1 import os
2 from launch import LaunchDescription
3 from launch.actions import ExecuteProcess
4 from launch_ros.actions import Node
5 from ament_index_python.packages import get_package_share_directory
6 from moveit_configs_utils import MoveItConfigsBuilder
7 from launch_param_builder import ParameterBuilder
8 
9 
11  moveit_config = (
12  MoveItConfigsBuilder("moveit_resources_panda")
13  .robot_description(file_path="config/panda.urdf.xacro")
14  .to_moveit_configs()
15  )
16 
17  # Get parameters for the Pose Tracking node
18  servo_params = {
19  "moveit_servo": ParameterBuilder("moveit_servo")
20  .yaml("config/pose_tracking_settings.yaml")
21  .yaml("config/panda_simulated_config_pose_tracking.yaml")
22  .to_dict()
23  }
24 
25  # RViz
26  rviz_config_file = (
27  get_package_share_directory("moveit_servo")
28  + "/config/demo_rviz_pose_tracking.rviz"
29  )
30  rviz_node = Node(
31  package="rviz2",
32  executable="rviz2",
33  name="rviz2",
34  # prefix=['xterm -e gdb -ex run --args'],
35  output="log",
36  arguments=["-d", rviz_config_file],
37  parameters=[moveit_config.to_dict()],
38  )
39 
40  # Publishes tf's for the robot
41  robot_state_publisher = Node(
42  package="robot_state_publisher",
43  executable="robot_state_publisher",
44  output="screen",
45  parameters=[moveit_config.robot_description],
46  )
47 
48  # A node to publish world -> panda_link0 transform
49  static_tf = Node(
50  package="tf2_ros",
51  executable="static_transform_publisher",
52  name="static_transform_publisher",
53  output="log",
54  arguments=["0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "world", "panda_link0"],
55  )
56 
57  pose_tracking_node = Node(
58  package="moveit_servo",
59  executable="servo_pose_tracking_demo",
60  # prefix=['xterm -e gdb -ex run --args'],
61  output="screen",
62  parameters=[
63  moveit_config.to_dict(),
64  servo_params,
65  ],
66  )
67 
68  # ros2_control using FakeSystem as hardware
69  ros2_controllers_path = os.path.join(
70  get_package_share_directory("moveit_resources_panda_moveit_config"),
71  "config",
72  "ros2_controllers.yaml",
73  )
74  ros2_control_node = Node(
75  package="controller_manager",
76  executable="ros2_control_node",
77  parameters=[moveit_config.robot_description, ros2_controllers_path],
78  output="screen",
79  )
80 
81  joint_state_broadcaster_spawner = Node(
82  package="controller_manager",
83  executable="spawner",
84  arguments=[
85  "joint_state_broadcaster",
86  "--controller-manager-timeout",
87  "300",
88  "--controller-manager",
89  "/controller_manager",
90  ],
91  )
92 
93  panda_arm_controller_spawner = Node(
94  package="controller_manager",
95  executable="spawner",
96  arguments=["panda_arm_controller", "-c", "/controller_manager"],
97  )
98 
99  return LaunchDescription(
100  [
101  rviz_node,
102  static_tf,
103  pose_tracking_node,
104  ros2_control_node,
105  joint_state_broadcaster_spawner,
106  panda_arm_controller_spawner,
107  robot_state_publisher,
108  ]
109  )