-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdisplay.launch.py
50 lines (40 loc) · 2 KB
/
display.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
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.conditions import IfCondition, UnlessCondition
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
def generate_launch_description():
ld = LaunchDescription()
urdf_launch_package = FindPackageShare('urdf_launch')
ld.add_action(DeclareLaunchArgument(name='jsp_gui', default_value='true', choices=['true', 'false'],
description='Flag to enable joint_state_publisher_gui'))
default_rviz_config_path = PathJoinSubstitution([urdf_launch_package, 'config', 'urdf.rviz'])
ld.add_action(DeclareLaunchArgument(name='rviz_config', default_value=default_rviz_config_path,
description='Absolute path to rviz config file'))
# need to manually pass configuration in because of https://github.com/ros2/launch/issues/313
ld.add_action(IncludeLaunchDescription(
PathJoinSubstitution([urdf_launch_package, 'launch', 'description.launch.py']),
launch_arguments={
'urdf_package': LaunchConfiguration('urdf_package'),
'urdf_package_path': LaunchConfiguration('urdf_package_path')}.items()
))
# Depending on gui parameter, either launch joint_state_publisher or joint_state_publisher_gui
ld.add_action(Node(
package='joint_state_publisher',
executable='joint_state_publisher',
condition=UnlessCondition(LaunchConfiguration('jsp_gui'))
))
ld.add_action(Node(
package='joint_state_publisher_gui',
executable='joint_state_publisher_gui',
condition=IfCondition(LaunchConfiguration('jsp_gui'))
))
ld.add_action(Node(
package='rviz2',
executable='rviz2',
output='screen',
arguments=['-d', LaunchConfiguration('rviz_config')],
))
return ld