-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathignition.launch.py
More file actions
84 lines (69 loc) · 3.35 KB
/
Copy pathignition.launch.py
File metadata and controls
84 lines (69 loc) · 3.35 KB
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
# Copyright 2021 Clearpath Robotics, Inc.
# @author Roni Kreinin (rkreinin@clearpathrobotics.com)
import os
from pathlib import Path
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription, AppendEnvironmentVariable
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
ARGUMENTS = [
DeclareLaunchArgument('use_sim_time', default_value='true',
choices=['true', 'false'],
description='use_sim_time'),
DeclareLaunchArgument('world', default_value='depot',
description='Ignition World'),
]
def generate_launch_description():
# Directories
pkg_irobot_create_ignition_bringup = get_package_share_directory(
'irobot_create_ignition_bringup')
pkg_irobot_create_ignition_plugins = get_package_share_directory(
'irobot_create_ignition_plugins')
pkg_irobot_create_description = get_package_share_directory(
'irobot_create_description')
pkg_ros_ign_gazebo = get_package_share_directory(
'ros_ign_gazebo')
# Set Ignition resource path
ign_resource_path = AppendEnvironmentVariable(name='IGN_GAZEBO_RESOURCE_PATH',
value=[os.path.join(
pkg_irobot_create_ignition_bringup,
'worlds'), ':' +
str(Path(
pkg_irobot_create_description).
parent.resolve())])
ign_gui_plugin_path = AppendEnvironmentVariable(name='IGN_GUI_PLUGIN_PATH',
value=[os.path.join(
pkg_irobot_create_ignition_plugins,
'lib')])
# Paths
ign_gazebo_launch = PathJoinSubstitution(
[pkg_ros_ign_gazebo, 'launch', 'ign_gazebo.launch.py'])
# Ignition gazebo
ignition_gazebo = IncludeLaunchDescription(
PythonLaunchDescriptionSource([ign_gazebo_launch]),
launch_arguments=[
('ign_args', [LaunchConfiguration('world'),
'.sdf',
' -v 4',
' --gui-config ',
PathJoinSubstitution([pkg_irobot_create_ignition_bringup,
'gui', 'create3', 'gui.config'])])
]
)
# clock bridge
clock_bridge = Node(package='ros_gz_bridge', executable='parameter_bridge',
name='clock_bridge',
output='screen',
arguments=[
'/clock' + '@rosgraph_msgs/msg/Clock' + '[ignition.msgs.Clock'
])
# Create launch description and add actions
ld = LaunchDescription(ARGUMENTS)
ld.add_action(ign_resource_path)
ld.add_action(ign_gui_plugin_path)
ld.add_action(ignition_gazebo)
ld.add_action(clock_bridge)
return ld