Skip to content

Commit

Permalink
[ros2] Conditional launch includes (#979)
Browse files Browse the repository at this point in the history
* [ros2] Conditional launch includes

Signed-off-by: Louise Poubel <louise@openrobotics.org>

* remove unused import

Signed-off-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
chapulina authored and j-rivero committed Oct 3, 2019
1 parent 2c95baa commit 0f4818c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gazebo_ros/launch/gazebo.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,30 @@
"""Launch Gazebo server and client with command line arguments."""

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
from launch.substitutions import ThisLaunchFileDir


def generate_launch_description():

# (TODO) Allow conditional include of gzserver and gzclient, once supported
# https://github.com/ros2/launch/issues/303
return LaunchDescription([
DeclareLaunchArgument('gui', default_value='true',
description='Set to "false" to run headless.'),

DeclareLaunchArgument('server', default_value='true',
description='Set to "false" not to run gzserver.'),

IncludeLaunchDescription(
PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/gzserver.launch.py']),
condition=IfCondition(LaunchConfiguration('server'))
),

IncludeLaunchDescription(
PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/gzclient.launch.py']),
condition=IfCondition(LaunchConfiguration('gui'))
),
])
2 changes: 2 additions & 0 deletions gazebo_ros/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<depend>std_srvs</depend>
<depend>tinyxml_vendor</depend>

<exec_depend>launch_ros</exec_depend>

<build_export_depend>geometry_msgs</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>

Expand Down

0 comments on commit 0f4818c

Please sign in to comment.