-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_example_comment.launch.py
More file actions
99 lines (97 loc) · 4.23 KB
/
Copy pathpython_example_comment.launch.py
File metadata and controls
99 lines (97 loc) · 4.23 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# from https://docs.ros.org/en/rolling/How-To-Guides/Launch-file-different-formats.html
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, GroupAction, IncludeLaunchDescription
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node, PushROSNamespace
from launch_ros.substitutions import FindPackageShare
def generate_launch_description():
# launch_dir = PathJoinSubstitution(
# [FindPackageShare("demo_nodes_cpp_comment"), "launch", "topics"]
# )
"""
launch_dir = PathJoinSubstitution(
[FindPackageShare("demo_nodes_cpp_commentII"), "launch", "topics"]
)
"""
launch_dir = PathJoinSubstitution(
[FindPackageShare("demo_nodes_cpp"), "launch", "topics"]
)
return LaunchDescription(
[
# args that can be set from the command line or a default will be used
DeclareLaunchArgument("background_r", default_value="0"),
DeclareLaunchArgument("background_g", default_value="255"),
DeclareLaunchArgument("background_b", default_value="0"),
DeclareLaunchArgument("chatter_py_ns", default_value="chatter/py/ns"),
DeclareLaunchArgument("chatter_xml_ns", default_value="chatter/xml/ns"),
DeclareLaunchArgument("chatter_yaml_ns", default_value="chatter/yaml/ns"),
# include another launch file
IncludeLaunchDescription(
PathJoinSubstitution([launch_dir, "talker_listener_launch.py"])
),
# include a Python launch file in the chatter_py_ns namespace
GroupAction(
actions=[
# push_ros_namespace first to set namespace of included nodes for following actions
PushROSNamespace("chatter_py_ns"),
IncludeLaunchDescription(
PathJoinSubstitution([launch_dir, "talker_listener_launch.py"])
),
]
),
# include a xml launch file in the chatter_xml_ns namespace
GroupAction(
actions=[
# push_ros_namespace first to set namespace of included nodes for following actions
PushROSNamespace("chatter_xml_ns"),
IncludeLaunchDescription(
PathJoinSubstitution([launch_dir, "talker_listener_launch.xml"])
),
]
),
# include a yaml launch file in the chatter_yaml_ns namespace
GroupAction(
actions=[
# push_ros_namespace first to set namespace of included nodes for following actions
PushROSNamespace("chatter_yaml_ns"),
IncludeLaunchDescription(
PathJoinSubstitution(
[launch_dir, "talker_listener_launch.yaml"]
)
),
]
),
# start a turtlesim_node in the turtlesim1 namespace
Node(
package="turtlesim",
namespace="turtlesim1",
executable="turtlesim_node",
name="sim",
),
# start another turtlesim_node in the turtlesim2 namespace
# and use args to set parameters
Node(
package="turtlesim",
namespace="turtlesim2",
executable="turtlesim_node",
name="sim",
parameters=[
{
"background_r": LaunchConfiguration("background_r"),
"background_g": LaunchConfiguration("background_g"),
"background_b": LaunchConfiguration("background_b"),
}
],
),
# perform remap so both turtles listen to the same command topic
Node(
package="turtlesim",
executable="mimic",
name="mimic",
remappings=[
("/input/pose", "/turtlesim1/turtle1/pose"),
("/output/cmd_vel", "/turtlesim2/turtle1/cmd_vel"),
],
),
]
)