forked from ros-simulation/gazebo_ros_pkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ros2] Port gazebo launch scripts to ROS2 (ros-simulation#962)
* [ros2] Port gazebo launch scripts to ROS2 * Add gdb and valgrind option * Use shell command for extra gazebo args
- Loading branch information
1 parent
53bac8d
commit 2edc893
Showing
10 changed files
with
267 additions
and
225 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2019 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Launch Gazebo server and client with command line arguments.""" | ||
|
||
from launch import LaunchDescription | ||
from launch.actions import IncludeLaunchDescription | ||
from launch.launch_description_sources import PythonLaunchDescriptionSource | ||
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([ | ||
IncludeLaunchDescription( | ||
PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/gzserver.launch.py']), | ||
), | ||
|
||
IncludeLaunchDescription( | ||
PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/gzclient.launch.py']), | ||
), | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Copyright 2019 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Launch a Gazebo client with command line arguments.""" | ||
|
||
from os import environ | ||
|
||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.actions import ExecuteProcess | ||
from launch.substitutions import LaunchConfiguration | ||
from launch.substitutions import PythonExpression | ||
|
||
from scripts import GazeboRosPaths | ||
|
||
|
||
def generate_launch_description(): | ||
model, plugin, media = GazeboRosPaths.get_paths() | ||
|
||
if 'GAZEBO_MODEL_PATH' in environ: | ||
model += ':'+environ['GAZEBO_MODEL_PATH'] | ||
if 'GAZEBO_PLUGIN_PATH' in environ: | ||
plugin += ':'+environ['GAZEBO_PLUGIN_PATH'] | ||
if 'GAZEBO_RESOURCE_PATH' in environ: | ||
media += ':'+environ['GAZEBO_RESOURCE_PATH'] | ||
|
||
env = {'GAZEBO_MODEL_PATH': model, | ||
'GAZEBO_PLUGIN_PATH': plugin, | ||
'GAZEBO_RESOURCE_PATH': media} | ||
|
||
return LaunchDescription([ | ||
DeclareLaunchArgument('version', default_value='false', | ||
description='Set "true" to output version information'), | ||
DeclareLaunchArgument('verbose', default_value='false', | ||
description='Set "true" to increase messages written to terminal'), | ||
DeclareLaunchArgument('help', default_value='false', | ||
description='Set "true" to produce gzclient help message'), | ||
DeclareLaunchArgument('extra_gazebo_args', default_value='', | ||
description='Extra arguments to be passed to Gazebo'), | ||
|
||
# Specific to gazebo_ros | ||
DeclareLaunchArgument('gdb', default_value='false', | ||
description='Set "true" to run gzserver with gdb'), | ||
DeclareLaunchArgument('valgrind', default_value='false', | ||
description='Set "true" to run gzserver with valgrind'), | ||
|
||
# Execute | ||
ExecuteProcess( | ||
cmd=[['gzclient', | ||
_boolean_command('version'), ' ', | ||
_boolean_command('verbose'), ' ', | ||
_boolean_command('help'), ' ', | ||
LaunchConfiguration('extra_gazebo_args'), | ||
]], | ||
output='screen', | ||
additional_env=env, | ||
shell=True, | ||
prefix=PythonExpression(['"gdb -ex run --args" if "true" == "', | ||
LaunchConfiguration('gdb'), | ||
'"else "valgrind" if "true" == "', | ||
LaunchConfiguration('valgrind'), | ||
'"else ""']), | ||
) | ||
]) | ||
|
||
|
||
# Add boolean commands if true | ||
def _boolean_command(arg): | ||
cmd = ['"--', arg, '" if "true" == "', LaunchConfiguration(arg), '" else ""'] | ||
py_cmd = PythonExpression(cmd) | ||
return py_cmd |
Oops, something went wrong.