Skip to content

Commit fc1d676

Browse files
Tomas BacaTomas Baca
authored andcommitted
added core launchfiile
1 parent 79c77ca commit fc1d676

File tree

2 files changed

+244
-4
lines changed

2 files changed

+244
-4
lines changed

ros_packages/mrs_uav_core/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ install(
3030
RUNTIME DESTINATION bin
3131
)
3232

33-
# install(
34-
# DIRECTORY launch
35-
# DESTINATION share/${PROJECT_NAME}
36-
# )
33+
install(
34+
DIRECTORY launch
35+
DESTINATION share/${PROJECT_NAME}
36+
)
3737

3838
# install(
3939
# DIRECTORY config
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
#!/usr/bin/env python3
2+
3+
import launch
4+
import os
5+
import sys
6+
7+
from launch.actions import IncludeLaunchDescription
8+
from launch.actions import DeclareLaunchArgument
9+
from launch_ros.actions import ComposableNodeContainer, LoadComposableNodes
10+
from launch.launch_description_sources import PythonLaunchDescriptionSource
11+
from launch.conditions import IfCondition, UnlessCondition
12+
from launch_ros.substitutions import FindPackageShare
13+
from launch.substitutions import (
14+
LaunchConfiguration,
15+
IfElseSubstitution,
16+
PythonExpression,
17+
PathJoinSubstitution,
18+
EnvironmentVariable,
19+
)
20+
21+
from ament_index_python.packages import get_package_share_directory
22+
23+
def generate_launch_description():
24+
25+
ld = launch.LaunchDescription()
26+
27+
# #{ standalone
28+
29+
standalone = LaunchConfiguration('standalone')
30+
31+
declare_standalone = DeclareLaunchArgument(
32+
'standalone',
33+
default_value='false',
34+
description='Whether to start a as a standalone or load into an existing container.'
35+
)
36+
37+
ld.add_action(declare_standalone)
38+
39+
# #} end of standalone
40+
41+
# #{ custom_config
42+
43+
custom_config = LaunchConfiguration('custom_config')
44+
45+
# this adds the args to the list of args available for this launch files
46+
# these args can be listed at runtime using -s flag
47+
# default_value is required to if the arg is supposed to be optional at launch time
48+
ld.add_action(DeclareLaunchArgument(
49+
'custom_config',
50+
default_value="",
51+
description="Path to the custom configuration file. The path can be absolute, starting with '/' or relative to the current working directory",
52+
))
53+
54+
# behaviour:
55+
# custom_config == "" => custom_config: ""
56+
# custom_config == "/<path>" => custom_config: "/<path>"
57+
# custom_config == "<path>" => custom_config: "$(pwd)/<path>"
58+
custom_config = IfElseSubstitution(
59+
condition=PythonExpression(['"', custom_config, '" != "" and ', 'not "', custom_config, '".startswith("/")']),
60+
if_value=PathJoinSubstitution([EnvironmentVariable('PWD'), custom_config]),
61+
else_value=custom_config
62+
)
63+
64+
# #} end of custom_config
65+
66+
# #{ platform_config
67+
68+
platform_config = LaunchConfiguration('platform_config')
69+
70+
# this adds the args to the list of args available for this launch files
71+
# these args can be listed at runtime using -s flag
72+
# default_value is required to if the arg is supposed to be optional at launch time
73+
ld.add_action(DeclareLaunchArgument(
74+
'platform_config',
75+
default_value="",
76+
description="Path to the custom configuration file. The path can be absolute, starting with '/' or relative to the current working directory",
77+
))
78+
79+
# behaviour:
80+
# platform_config == "" => platform_config: ""
81+
# platform_config == "/<path>" => platform_config: "/<path>"
82+
# platform_config == "<path>" => platform_config: "$(pwd)/<path>"
83+
platform_config = IfElseSubstitution(
84+
condition=PythonExpression(['"', platform_config, '" != "" and ', 'not "', platform_config, '".startswith("/")']),
85+
if_value=PathJoinSubstitution([EnvironmentVariable('PWD'), platform_config]),
86+
else_value=platform_config
87+
)
88+
89+
# #} end of platform_config
90+
91+
# #{ world_config
92+
93+
world_config = LaunchConfiguration('world_config')
94+
95+
# this adds the args to the list of args available for this launch files
96+
# these args can be listed at runtime using -s flag
97+
# default_value is required to if the arg is supposed to be optional at launch time
98+
ld.add_action(DeclareLaunchArgument(
99+
'world_config',
100+
default_value="",
101+
description="Path to the custom configuration file. The path can be absolute, starting with '/' or relative to the current working directory",
102+
))
103+
104+
# behaviour:
105+
# world_config == "" => world_config: ""
106+
# world_config == "/<path>" => world_config: "/<path>"
107+
# world_config == "<path>" => world_config: "$(pwd)/<path>"
108+
world_config = IfElseSubstitution(
109+
condition=PythonExpression(['"', world_config, '" != "" and ', 'not "', world_config, '".startswith("/")']),
110+
if_value=PathJoinSubstitution([EnvironmentVariable('PWD'), world_config]),
111+
else_value=world_config
112+
)
113+
114+
# #} end of world_config
115+
116+
# #{ network_config
117+
118+
network_config = LaunchConfiguration('network_config')
119+
120+
# this adds the args to the list of args available for this launch files
121+
# these args can be listed at runtime using -s flag
122+
# default_value is required to if the arg is supposed to be optional at launch time
123+
ld.add_action(DeclareLaunchArgument(
124+
'network_config',
125+
default_value="",
126+
description="Path to the custom configuration file. The path can be absolute, starting with '/' or relative to the current working directory",
127+
))
128+
129+
# behaviour:
130+
# network_config == "" => network_config: ""
131+
# network_config == "/<path>" => network_config: "/<path>"
132+
# network_config == "<path>" => network_config: "$(pwd)/<path>"
133+
network_config = IfElseSubstitution(
134+
condition=PythonExpression(['"', network_config, '" != "" and ', 'not "', network_config, '".startswith("/")']),
135+
if_value=PathJoinSubstitution([EnvironmentVariable('PWD'), network_config]),
136+
else_value=network_config
137+
)
138+
139+
# #} end of network_config
140+
141+
uav_name=os.getenv('UAV_NAME', "uav1")
142+
143+
container_name = "/" + uav_name + "/uav_core_container"
144+
145+
core_container = ComposableNodeContainer(
146+
namespace=uav_name,
147+
name='uav_core_container',
148+
package='rclcpp_components',
149+
executable='component_container_mt',
150+
output="screen",
151+
parameters=[
152+
{'thread_num': 16},
153+
{'use_intra_process_comms': True},
154+
],
155+
condition=UnlessCondition(standalone)
156+
)
157+
158+
ld.add_action(core_container)
159+
160+
ld.add_action(
161+
IncludeLaunchDescription(
162+
PythonLaunchDescriptionSource([
163+
FindPackageShare('mrs_uav_managers'), '/launch/control_manager.py'
164+
]),
165+
launch_arguments={
166+
'custom_config': custom_config,
167+
'platforom_config': platform_config,
168+
'world_config': world_config,
169+
'network_config': network_config,
170+
'standalone': standalone,
171+
'container_name': container_name,
172+
}.items()
173+
)
174+
)
175+
176+
ld.add_action(
177+
IncludeLaunchDescription(
178+
PythonLaunchDescriptionSource([
179+
FindPackageShare('mrs_uav_managers'), '/launch/uav_manager.py'
180+
]),
181+
launch_arguments={
182+
'custom_config': custom_config,
183+
'platforom_config': platform_config,
184+
'world_config': world_config,
185+
'network_config': network_config,
186+
'standalone': standalone,
187+
'container_name': container_name,
188+
}.items()
189+
)
190+
)
191+
192+
ld.add_action(
193+
IncludeLaunchDescription(
194+
PythonLaunchDescriptionSource([
195+
FindPackageShare('mrs_uav_managers'), '/launch/transform_manager.py'
196+
]),
197+
launch_arguments={
198+
'custom_config': custom_config,
199+
'platforom_config': platform_config,
200+
'world_config': world_config,
201+
'network_config': network_config,
202+
'standalone': standalone,
203+
'container_name': container_name,
204+
}.items()
205+
)
206+
)
207+
208+
ld.add_action(
209+
IncludeLaunchDescription(
210+
PythonLaunchDescriptionSource([
211+
FindPackageShare('mrs_uav_managers'), '/launch/constraint_manager.py'
212+
]),
213+
launch_arguments={
214+
'custom_config': custom_config,
215+
'platforom_config': platform_config,
216+
'world_config': world_config,
217+
'network_config': network_config,
218+
'standalone': standalone,
219+
'container_name': container_name,
220+
}.items()
221+
)
222+
)
223+
224+
ld.add_action(
225+
IncludeLaunchDescription(
226+
PythonLaunchDescriptionSource([
227+
FindPackageShare('mrs_uav_managers'), '/launch/estimation_manager.py'
228+
]),
229+
launch_arguments={
230+
'custom_config': custom_config,
231+
'platforom_config': platform_config,
232+
'world_config': world_config,
233+
'network_config': network_config,
234+
'standalone': standalone,
235+
'container_name': container_name,
236+
}.items()
237+
)
238+
)
239+
240+
return ld

0 commit comments

Comments
 (0)