add option run gazebo without gui
This commit is contained in:
parent
f76340d78a
commit
157e6b6176
1 changed files with 19 additions and 6 deletions
|
@ -4,7 +4,7 @@ from launch import LaunchDescription
|
||||||
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
|
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
|
||||||
from launch_ros.substitutions import FindPackageShare
|
from launch_ros.substitutions import FindPackageShare
|
||||||
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
|
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
|
||||||
from launch.conditions import IfCondition
|
from launch.conditions import IfCondition, UnlessCondition
|
||||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||||
from ament_index_python.packages import get_package_share_directory
|
from ament_index_python.packages import get_package_share_directory
|
||||||
|
|
||||||
|
@ -25,22 +25,34 @@ def generate_launch_description():
|
||||||
declared_arguments.append(
|
declared_arguments.append(
|
||||||
DeclareLaunchArgument("env_manager", default_value="false", description="Launch env_manager?")
|
DeclareLaunchArgument("env_manager", default_value="false", description="Launch env_manager?")
|
||||||
)
|
)
|
||||||
|
declared_arguments.append(
|
||||||
|
DeclareLaunchArgument("gazebo_gui", default_value="false", description="Launch env_manager?")
|
||||||
|
)
|
||||||
|
|
||||||
sim_gazebo = LaunchConfiguration("sim_gazebo")
|
sim_gazebo = LaunchConfiguration("sim_gazebo")
|
||||||
rbs_robot_type = LaunchConfiguration("rbs_robot_type")
|
rbs_robot_type = LaunchConfiguration("rbs_robot_type")
|
||||||
env_manager_cond = LaunchConfiguration("env_manager")
|
env_manager_cond = LaunchConfiguration("env_manager")
|
||||||
|
gazebo_gui = LaunchConfiguration("gazebo_gui")
|
||||||
# FIXME: To args when we'll have different files
|
# FIXME: To args when we'll have different files
|
||||||
world_config_file = PathJoinSubstitution(
|
world_config_file = PathJoinSubstitution(
|
||||||
[FindPackageShare("rbs_simulation"), "worlds", "mir.sdf"]
|
[FindPackageShare("rbs_simulation"), "worlds", "mir.sdf"]
|
||||||
)
|
)
|
||||||
# Gazebo nodes
|
# Gazebo nodes
|
||||||
|
|
||||||
|
gazebo_server = IncludeLaunchDescription(
|
||||||
|
PythonLaunchDescriptionSource(
|
||||||
|
[os.path.join(get_package_share_directory('ros_gz_sim'),
|
||||||
|
'launch', 'gz_sim.launch.py')]),
|
||||||
|
launch_arguments=[('ign_args', [' -r ',world_config_file, " -s"])],
|
||||||
|
condition=UnlessCondition(gazebo_gui))
|
||||||
|
|
||||||
gazebo = IncludeLaunchDescription(
|
gazebo = IncludeLaunchDescription(
|
||||||
PythonLaunchDescriptionSource(
|
PythonLaunchDescriptionSource(
|
||||||
[os.path.join(get_package_share_directory('ros_ign_gazebo'),
|
[os.path.join(get_package_share_directory('ros_gz_sim'),
|
||||||
'launch', 'ign_gazebo.launch.py')]),
|
'launch', 'gz_sim.launch.py')]),
|
||||||
launch_arguments=[('ign_args', [' -r ',world_config_file, " --physics-engine ignition-physics-dartsim-plugin --render-engine ogre2"])],
|
launch_arguments=[('ign_args', [' -r ',world_config_file])],
|
||||||
condition=IfCondition(sim_gazebo))
|
condition=IfCondition(gazebo_gui))
|
||||||
|
|
||||||
# Spawn robot
|
# Spawn robot
|
||||||
gazebo_spawn_robot = Node(package='ros_ign_gazebo', executable='create',
|
gazebo_spawn_robot = Node(package='ros_ign_gazebo', executable='create',
|
||||||
arguments=[
|
arguments=[
|
||||||
|
@ -59,6 +71,7 @@ def generate_launch_description():
|
||||||
|
|
||||||
nodes_to_start = [
|
nodes_to_start = [
|
||||||
gazebo,
|
gazebo,
|
||||||
|
gazebo_server,
|
||||||
gazebo_spawn_robot,
|
gazebo_spawn_robot,
|
||||||
env_manager
|
env_manager
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue