moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
move_group_launch_test_common.py
Go to the documentation of this file.
1import os
2import launch
3import launch_ros
4import launch_testing
5from launch.actions import ExecuteProcess, TimerAction
6from launch.some_substitutions_type import SomeSubstitutionsType
7from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
8from launch_ros.actions import Node
9from ament_index_python.packages import get_package_share_directory
10from moveit_configs_utils import MoveItConfigsBuilder
11
12
13def generate_move_group_test_description(*args, gtest_name: SomeSubstitutionsType):
14 moveit_config = (
15 MoveItConfigsBuilder("moveit_resources_panda")
16 .robot_description(file_path="config/panda.urdf.xacro")
17 .trajectory_execution(file_path="config/gripper_moveit_controllers.yaml")
18 .to_moveit_configs()
19 )
20
21 moveit_config.planning_pipelines["ompl"]["panda_arm"][
22 "enforce_constrained_state_space"
23 ] = True
24 moveit_config.planning_pipelines["ompl"]["panda_arm"][
25 "projection_evaluator"
26 ] = "joints(panda_joint1,panda_joint2)"
27
28 # Start the actual move_group node/action server
29 run_move_group_node = Node(
30 package="moveit_ros_move_group",
31 executable="move_group",
32 output="screen",
33 parameters=[moveit_config.to_dict()],
34 )
35
36 # Static TF
37 static_tf = Node(
38 package="tf2_ros",
39 executable="static_transform_publisher",
40 name="static_transform_publisher",
41 output="log",
42 arguments=["0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "world", "panda_link0"],
43 )
44
45 # Publish TF
46 robot_state_publisher = Node(
47 package="robot_state_publisher",
48 executable="robot_state_publisher",
49 name="robot_state_publisher",
50 output="both",
51 parameters=[moveit_config.robot_description],
52 )
53
54 # ros2_control using FakeSystem as hardware
55 ros2_controllers_path = os.path.join(
56 get_package_share_directory("moveit_resources_panda_moveit_config"),
57 "config",
58 "ros2_controllers.yaml",
59 )
60 ros2_control_node = Node(
61 package="controller_manager",
62 executable="ros2_control_node",
63 parameters=[ros2_controllers_path],
64 remappings=[
65 ("/controller_manager/robot_description", "/robot_description"),
66 ],
67 output="screen",
68 )
69
70 joint_state_broadcaster_spawner = Node(
71 package="controller_manager",
72 executable="spawner",
73 arguments=[
74 "joint_state_broadcaster",
75 "--controller-manager",
76 "/controller_manager",
77 ],
78 )
79
80 panda_arm_controller_spawner = Node(
81 package="controller_manager",
82 executable="spawner",
83 arguments=["panda_arm_controller", "-c", "/controller_manager"],
84 )
85
86 panda_hand_controller_spawner = Node(
87 package="controller_manager",
88 executable="spawner",
89 arguments=["panda_hand_controller", "-c", "/controller_manager"],
90 )
91
92 # test executable
93 ompl_constraint_test = launch_ros.actions.Node(
94 executable=PathJoinSubstitution(
95 [LaunchConfiguration("test_binary_dir"), gtest_name]
96 ),
97 parameters=[
98 moveit_config.robot_description,
99 moveit_config.robot_description_semantic,
100 moveit_config.robot_description_kinematics,
101 ],
102 output="screen",
103 )
104
105 return launch.LaunchDescription(
106 [
107 launch.actions.DeclareLaunchArgument(
108 name="test_binary_dir",
109 description="Binary directory of package "
110 "containing test executables",
111 ),
112 run_move_group_node,
113 static_tf,
114 robot_state_publisher,
115 ros2_control_node,
116 joint_state_broadcaster_spawner,
117 panda_arm_controller_spawner,
118 panda_hand_controller_spawner,
119 TimerAction(period=2.0, actions=[ompl_constraint_test]),
120 launch_testing.actions.ReadyToTest(),
121 ]
122 ), {
123 "run_move_group_node": run_move_group_node,
124 "static_tf": static_tf,
125 "robot_state_publisher": robot_state_publisher,
126 "ros2_control_node": ros2_control_node,
127 "ompl_constraint_test": ompl_constraint_test,
128 }