Launch Gazebo Sim paused from a parameter in ROS2 launch file

asked 2022-12-09 15:53:15 -0500

Luczia gravatar image

Hi There !

Could be an easy question, but I can't figure it out.

I would like to use a launch file to launch a Gazebo Sim simulation in the state paused or playing according to a parameter sim_paused which I would like to be a parameter(launch argument) of the file.

I understand from the gz_ros2_control_demo repo that I can choose to launch the from ros_gz_sim package with or without -r argument. The '-r' arg meaning that the simulation will be running.

Example how to call the with '-r' :

   # Launch gazebo environment
                                  'launch', '')]),
                launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]),

But then, how can I use the incomming launch argument sim_paused to activate or not '-r' in ?

# Launch configuration variables 
    sim_paused= LaunchConfiguration('sim_paused')    

    declare_sim_paused = DeclareLaunchArgument(
        description='Whether to start Gazebo paused')
edit retag flag offensive close merge delete