Skip to content

Commit d6d02d0

Browse files
committed
added launcher for drone gymkhana exercise
1 parent 35680ea commit d6d02d0

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

Launchers/drone_gymkhana.launch.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
"""Entry point for the Drone Gymkhana exercise."""
2+
3+
import os
4+
5+
from ament_index_python.packages import get_package_share_directory
6+
7+
from launch import LaunchDescription
8+
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
9+
from launch.conditions import IfCondition
10+
from launch.launch_description_sources import PythonLaunchDescriptionSource
11+
from launch.substitutions import LaunchConfiguration
12+
from launch_ros.actions import Node
13+
14+
15+
def generate_launch_description():
16+
"""Generate the launch description for drone gymkhana simulation."""
17+
custom_robots_share = get_package_share_directory("custom_robots")
18+
# same bridges file as rescue_people exercise
19+
bridges_path = os.path.join(custom_robots_share, "bridges", "rescue_people.yaml")
20+
world_path = os.path.join(
21+
custom_robots_share, "worlds", "drone_gymkhana_harmonic.world"
22+
)
23+
24+
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE #
25+
declare_use_simulator_cmd = DeclareLaunchArgument(
26+
name="use_simulator",
27+
default_value="True",
28+
description="Whether to start the simulator",
29+
)
30+
31+
# Start Gazebo server
32+
gzsim = IncludeLaunchDescription(
33+
PythonLaunchDescriptionSource(
34+
[
35+
os.path.join(get_package_share_directory("jderobot_drones"), "launch"),
36+
"/gz_sim.launch.py",
37+
]
38+
),
39+
condition=IfCondition(LaunchConfiguration("use_simulator")),
40+
launch_arguments={
41+
"namespace": "drone0",
42+
"bridges_file": bridges_path,
43+
"world_file": world_path,
44+
}.items(),
45+
)
46+
47+
as2 = IncludeLaunchDescription(
48+
PythonLaunchDescriptionSource(
49+
[
50+
os.path.join(get_package_share_directory("jderobot_drones"), "launch"),
51+
"/as2_default_gazebo_sim.launch.py",
52+
]
53+
),
54+
launch_arguments={
55+
"namespace": "drone0",
56+
}.items(),
57+
)
58+
59+
start_gazebo_frontal_image_bridge_cmd = Node(
60+
package="ros_gz_image",
61+
executable="image_bridge",
62+
arguments=["/drone0/frontal_cam/image_raw"],
63+
output="screen",
64+
)
65+
66+
start_gazebo_ventral_image_bridge_cmd = Node(
67+
package="ros_gz_image",
68+
executable="image_bridge",
69+
arguments=["/drone0/ventral_cam/image_raw"],
70+
output="screen",
71+
)
72+
73+
# Create the launch description and populate
74+
ld = LaunchDescription()
75+
ld.add_action(declare_use_simulator_cmd)
76+
ld.add_action(gzsim)
77+
ld.add_action(as2)
78+
ld.add_action(start_gazebo_frontal_image_bridge_cmd)
79+
ld.add_action(start_gazebo_ventral_image_bridge_cmd)
80+
81+
return ld

0 commit comments

Comments
 (0)