-
Notifications
You must be signed in to change notification settings - Fork 0
/
suj_bringup.launch.py
114 lines (99 loc) · 3.59 KB
/
suj_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
107
108
109
110
111
112
113
114
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, DeclareLaunchArgument
from launch.event_handlers import OnProcessExit
from launch.substitutions import LaunchConfiguration
def generate_launch_description():
# Get the URDF Xacro file
urdf_arg = DeclareLaunchArgument(
"urdf",
description="Name of the URDF Xacro file"
)
# Get robot description via xacro
robot_description = {
"robot_description": ParameterValue(
Command([
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution(
[FindPackageShare("suj_description"), "urdf", LaunchConfiguration("urdf")]
)
]),
value_type=str
)
}
# Path to the controller configuration file
controller_file = "suj.controllers.yaml"
# Path to the controller configuration file
controller_config = PathJoinSubstitution(
[FindPackageShare("suj_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="suj_description",
executable="suj_joint_controller",
output="screen",
parameters=[{'use_sim_time': True}]
)
# Path to the RViz file
suj_rviz_file = PathJoinSubstitution(
[FindPackageShare("suj_description"), "rviz", "suj_description.rviz"]
)
# For RViz
rviz_node = Node(
package='rviz2',
executable='rviz2',
name='rviz2',
output='screen',
parameters=[{'use_sim_time': True}],
arguments=['-d', suj_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([
urdf_arg,
robot_state_publisher,
controller_manager,
load_joint_state_broadcaster,
load_joint_group_position_controller,
joint_position_controller,
delay_rviz_after_joint_state_broadcaster_spawner
])