Repository navigation
Expand file tree
/
Copy pathframework.launch.py
More file actions
181 lines (150 loc) · 4.81 KB
/
Copy pathframework.launch.py
File metadata and controls
181 lines (150 loc) · 4.81 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import os
from launch import LaunchDescription, LaunchContext
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument
from launch.conditions import IfCondition, LaunchConfigurationNotEquals, LaunchConfigurationEquals
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
from launch.substitutions import LaunchConfiguration, EqualsSubstitution, PathJoinSubstitution
from launch.actions import GroupAction
def webots_launch():
webots_gateway = Node(
package="crazyflie_webots_gateway",
executable="gateway",
name="crazyflie_webots_gateway",
output="screen",
parameters=[
{
"webots_port": 1234,
"webots_use_tcp": False,
"webots_tcp_ip": "127.0.0.1",
}
],
)
wand = Node(
package="crazyflie_webots",
executable="wand",
name="Wand1",
parameters=[
{
"id": 1,
"webots_port": 1234,
"webots_use_tcp": False,
"webots_tcp_ip": "127.0.0.1",
}
],
output="screen",
)
return [webots_gateway, wand]
def tracking_launch():
motion_capture = Node(
package="ros_motioncapture",
executable="motioncapture_node",
name="node",
output="screen",
parameters=[
{
"type": "vicon",
"hostname": "172.20.37.251",
"add_labeled_markers_to_pointcloud": True,
}
],
)
config = PathJoinSubstitution([
FindPackageShare("object_tracker"),
"launch",
"tracker_config.yaml",
])
object_tracker = Node(
package="object_tracker",
executable="tracker",
name="tracker",
parameters=[config],
)
return [motion_capture, object_tracker]
def sitl_launch():
sitl_crazyflie = Node(
package="crazyflie_sitl",
executable="crazyflie_sitl",
parameters=[
{
"id": 231,
"initial_position": [0.0, 0.0, 0.0],
}
],
output="screen",
)
return [sitl_crazyflie]
def hardware_launch():
sitl_arg = DeclareLaunchArgument(
"sitl",
default_value="false",
description="Whether to start the crazyflie sitl. "
"This is useful for testing without hardware. "
"backend must be set to hardware for this to work. "
"(Dont activate tracking if using SITL.)",
)
tracked_arg = DeclareLaunchArgument(
"tracked",
default_value="false",
description="Whether to use motion capture for tracking the crazyflies."
"Only available if backend is set to hardware. "
"Make sure to set up the motion capture system accordingly (modify IP in this launch file).",
)
hardware_gateway = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
FindPackageShare("crazyflie_hardware_bringup"),
"/launch/hardware.launch.py",
]
),
launch_arguments={
"sitl_udp_radio": LaunchConfiguration("sitl"),
}.items(),
)
tracking = GroupAction(
condition=IfCondition(LaunchConfiguration("tracked")),
actions=tracking_launch(),
)
sitl = GroupAction(
condition=IfCondition(LaunchConfiguration("sitl")),
actions=sitl_launch(),
)
return [tracked_arg, sitl_arg, hardware_gateway, tracking, sitl]
def simulation_launch():
simulation_gateway = Node(
package="crazyflie_simulation_gateway",
executable="gateway",
name="crazyflie_simulation_gateway",
output="screen",
)
return [simulation_gateway]
def generate_launch_description():
backend_arg = DeclareLaunchArgument(
"backend",
default_value="simulation",
description="Select a crazyflie implementation to use.",
choices=["hardware", "simulation", "webots"],
)
# In Jazzy we can use Substitions with Equals and Or
# Then we can also start combinations.
hardware = GroupAction(
condition=IfCondition(EqualsSubstitution(LaunchConfiguration("backend"), "hardware")),
actions=hardware_launch(),
)
simulation = GroupAction(
condition=IfCondition(EqualsSubstitution(LaunchConfiguration("backend"), "simulation")),
actions=simulation_launch(),
)
webots = GroupAction(
condition=IfCondition(EqualsSubstitution(LaunchConfiguration("backend"), "webots")),
actions=webots_launch(),
)
return LaunchDescription(
[
backend_arg,
hardware,
simulation,
webots,
]
)