-
Notifications
You must be signed in to change notification settings - Fork 0
/
patient_cart_classic_bringup.launch.py
106 lines (92 loc) · 3.44 KB
/
patient_cart_classic_bringup.launch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
from launch import LaunchDescription
from launch.substitutions import Command, PathJoinSubstitution, FindExecutable
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
from launch_ros.descriptions import ParameterValue
from launch.actions import RegisterEventHandler
from launch.event_handlers import OnProcessExit
def generate_launch_description():
# Get robot description via xacro
robot_description = {
"robot_description": ParameterValue(
Command([
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution(
[FindPackageShare("patient_cart_description"), "urdf", "patient_cart.classic.urdf.xacro"]
)
]),
value_type=str
)
}
# Path to the controller configuration file
controller_file = "patient_cart.classic.controllers.yaml"
# Path to the controller configuration file
controller_config = PathJoinSubstitution(
[FindPackageShare("patient_cart_description"), "config", controller_file]
)
# For ros2_control_node
controller_manager = Node(
package="controller_manager",
executable="ros2_control_node",
output="screen",
parameters=[controller_config, {'use_sim_time': True}],
remappings=[('~/robot_description', '/robot_description')]
)
# For robot_state_publisher
robot_state_publisher = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="screen",
parameters=[robot_description, {'publish_robot_description': True, 'use_sim_time': True}],
)
# Load joint state broadcaster
load_joint_state_broadcaster = Node(
package='controller_manager',
executable='spawner',
arguments=['joint_state_broadcaster', '--controller-manager', '/controller_manager'],
parameters=[{'use_sim_time': True}],
output='screen',
)
# Load the joint group position controller
load_joint_group_position_controller = Node(
package='controller_manager',
executable='spawner',
arguments=['forward_position_controller', '--controller-manager', '/controller_manager'],
output='screen',
)
# Joint Position Controller Node
joint_position_controller = Node(
package="patient_cart_description",
executable="patient_cart_joint_controller",
output="screen",
parameters=[{'use_sim_time': True}]
)
# Path to the RViz file
ecm_rviz_file = PathJoinSubstitution(
[FindPackageShare("patient_cart_description"), "rviz", "patient_cart_description.rviz"]
)
# For RViz
rviz_node = Node(
package='rviz2',
executable='rviz2',
name='rviz2',
output='screen',
parameters=[{'use_sim_time': True}],
arguments=['-d', ecm_rviz_file],
)
# Delay rviz start after `joint_state_broadcaster`
delay_rviz_after_joint_state_broadcaster_spawner = RegisterEventHandler(
event_handler=OnProcessExit(
target_action=load_joint_state_broadcaster,
on_exit=[rviz_node],
)
)
return LaunchDescription([
robot_state_publisher,
controller_manager,
load_joint_state_broadcaster,
load_joint_group_position_controller,
joint_position_controller,
delay_rviz_after_joint_state_broadcaster_spawner
])