Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do I run Gazebo headless through roslaunch?

I am having issues running Gazebo 7 headless on a VM. That VM is running Ubuntu 16.04.6 with ROS Kinetic. To run Gazebo with ROS, I am currently using roslaunch turtlebot3_gazebo turtlebot3_house_no_x.launch. Everything was installed using APT from Ubuntu's official repositories.

I want to be able to use GzWeb 1.4 to allow a group of people to view the simulator for testing purposes. The VM doesn't have X installed so I modified turtlebot3_house_no_x.launch to not try to launch the GUI client of Gazebo. However, I'm not able to use ROS twist message to move the turtlebot.

When I use these same files and packages on my personal machine (Pop!_os 18.04, GzWeb 1.4, Gazebo 9, ROS Melodic, all installed through official Ubuntu repositories), it does work. I am able to run roscore, roslaunch turtlebot3_gazebo turtlebot3_house_no_x.launch, start GzWeb using NPM, send a twist message and watch the robot move and turn.

turtlebot3_house_no_x.launch is a manually altered version of turtlebot3_house.launch which was then put into /opt/ros/kinetic/share/turtlebot3_gazebo/launch.
There is a corresponding turtlebot3_house_no_x.world in /opt/ros/kinetic/share/turtlebot3_gazebo/launch.
This is the case with both the VM and my local machine (melodic in place of kinetic on the local machine)

Looking at the output, it seems like the Laser and DiffDrive plugins aren't being run on the VM while they are on the local machine. I suspect that's causing the VM to not create topics related to robot movement, but I'm not sure. Does anyone know how to make or make sure those plugins are installed and running? Are there any other possible issues I may have missed?

Here is turtlebot3_house_no_x.launch:

<launch>
  <arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>
  <arg name="x_pos" default="-3.0"/>
  <arg name="y_pos" default="1.0"/>
  <arg name="z_pos" default="0.0"/>
  <arg name="enable_ros_network" default="true" />

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/turtlebot3_house_no_x.world"/>
    <arg name="paused" value="false"/>
    <arg name="use_sim_time" value="true"/>
    <arg name="gui" value="false"/>
    <arg name="headless" value="true"/>
    <arg name="debug" value="false"/>
  </include>

  <group>
    <param name="gazebo/enable_ros_network" value="$(arg enable_ros_network)" />
  </group>

  <param name="robot_description" command="$(find xacro)/xacro --inorder $(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro" />

  <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model turtlebot3 -x $(arg x_pos) -y $(arg y_pos) -z $(arg z_pos) -param robot_description" />
</launch>

Here's turtlebot3_house_no_x.world:

<sdf version='1.4'>
  <world name='default'>
    <!-- A global light source -->
    <include>
      <uri>model://sun</uri>
    </include>

    <!-- A ground plane -->
    <include>
      <uri>model://ground_plane</uri>
    </include>

    <physics type="ode">
      <real_time_update_rate>1000.0</real_time_update_rate>
      <max_step_size>0.001</max_step_size>
      <real_time_factor>1</real_time_factor>
      <ode>
        <solver>
          <type>quick</type>
          <iters>150</iters>
          <precon_iters>0</precon_iters>
          <sor>1.400000</sor>
          <use_dynamic_moi_rescaling>1</use_dynamic_moi_rescaling>
        </solver>
        <constraints>
          <cfm>0.00001</cfm>
          <erp>0.2</erp>
          <contact_max_correcting_vel>2000.000000</contact_max_correcting_vel>
          <contact_surface_layer>0.01000</contact_surface_layer>
        </constraints>
      </ode>
    </physics>

    <!-- A turtlebot symbol -->
    <include>
      <uri>model://turtlebot3_house</uri>
    </include>

    <scene>
      <ambient>0.4 0.4 0.4 1</ambient>
      <background>0.7 0.7 0.7 1</background>
      <shadows>true</shadows>
    </scene>

    <gui fullscreen='0'>
      <camera name='user_camera'>
        <pose>0.0 0.0 17.0 0 1.5708 0</pose>
        <view_controller>orbit</view_controller>
      </camera>
    </gui>
  </world>
</sdf>

When running roslaunch turtlebot3_gazebo turtlebot3_house_no_x.launch on the VM, this is the output:

 ... logging to /root/.ros/log/c5dcbd66-5787-11ea-bb8a-00505699e55f/roslaunch-**HOSTNAME**-7747.log  
Checking log directory for disk usage. This may take awhile.  
Press Ctrl-C to interrupt  
Done checking log file disk usage. Usage is <1GB.  

started roslaunch server http://**url**:43371/  

 SUMMARY  
  ========

 PARAMETERS  
 * /gazebo/enable_ros_network: True  
 * /robot_description: <?xml version="1....  
 * /rosdistro: kinetic  
 * /rosversion: 1.12.14  
 * /use_sim_time: True  

 NODES  
  /  
    gazebo (gazebo_ros/gzserver)  
   spawn_urdf (gazebo_ros/spawn_model)  

 ROS_MASTER_URI=http://**URL**:11311/  

 process[gazebo-1]: started with pid [7767]  
 process[spawn_urdf-2]: started with pid [7768]  
[ INFO] [1583102557.565389130]: Finished loading Gazebo ROS API Plugin.  
[ INFO] [1583102557.578420607]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...  
[ INFO] [1583102568.330416867, 0.024000000]: waitForService: Service [/gazebo/set_physics_properties] is now available.  
[ INFO] [1583102568.492834420, 0.092000000]: Physics dynamic reconfigure ready.  
[spawn_urdf-2] process has finished cleanly  
 log file: /root/.ros/log/c5dcbd66-5787-11ea-bb8a-00505699e55f/spawn_urdf-2*.log

When I run rostopic list on the VM, I see:

/clock
/cmd_vel
/gazebo/link_states
/gazebo/model_states
/gazebo/set_link_state
/gazebo/set_model_state
/rosout
/rosout_agg

This is the output of roslaunch turtlebot3_gazebo turtlebot3_house_no_x.launch on my local machine:

... logging to /home/nathan/.ros/log/f5668fe2-5bf3-11ea-89cd-0cdd241f094b/roslaunch-pop-os-29387.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

xacro: in-order processing became default in ROS Melodic. You can drop the option.
started roslaunch server http://**IP**:46245/

SUMMARY
========

PARAMETERS
 * /gazebo/enable_ros_network: True
 * /robot_description: <?xml version="1....
 * /rosdistro: melodic
 * /rosversion: 1.14.3
 * /use_sim_time: True

NODES
  /
    gazebo (gazebo_ros/gzserver)
    spawn_urdf (gazebo_ros/spawn_model)

ROS_MASTER_URI=http://**IP**:11311

process[gazebo-1]: started with pid [29405]
process[spawn_urdf-2]: started with pid [29410]
[ INFO] [1583110316.654693753]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1583110316.655619646]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[ INFO] [1583110317.434862630, 0.022000000]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1583110317.448314472, 0.035000000]: Physics dynamic reconfigure ready.
[ INFO] [1583110317.771374197, 0.240000000]: Laser Plugin: Using the 'robotNamespace' param: '/'
[ INFO] [1583110317.771415012, 0.240000000]: Starting Laser Plugin (ns = /)
[ INFO] [1583110317.771993685, 0.240000000]: Laser Plugin (ns = /)  <tf_prefix_>, set to ""
[ INFO] [1583110317.880728083, 0.240000000]: Starting plugin DiffDrive(ns = //)
[ INFO] [1583110317.880919093, 0.240000000]: DiffDrive(ns = //): <rosDebugLevel> = na
[ INFO] [1583110317.882069783, 0.240000000]: DiffDrive(ns = //): <tf_prefix> = 
[ INFO] [1583110317.883728481, 0.240000000]: DiffDrive(ns = //): Advertise joint_states
[ INFO] [1583110317.884954389, 0.240000000]: DiffDrive(ns = //): Try to subscribe to cmd_vel
[ INFO] [1583110317.889751895, 0.240000000]: DiffDrive(ns = //): Subscribe to cmd_vel
[ INFO] [1583110317.890882132, 0.240000000]: DiffDrive(ns = //): Advertise odom on odom 
[spawn_urdf-2] process has finished cleanly
log file: /home/nathan/.ros/log/f5668fe2-5bf3-11ea-89cd-0cdd241f094b/spawn_urdf-2*.log

When I run rostopic list on my local machine:

/clock
/cmd_vel
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/set_link_state
/gazebo/set_model_state
/imu
/joint_states
/odom
/rosout
/rosout_agg
/scan
/tf

How do I run Gazebo headless through roslaunch?

I am having issues running Gazebo 7 headless on a VM. That VM is running Ubuntu 16.04.6 with ROS Kinetic. To run Gazebo with ROS, I am currently using roslaunch turtlebot3_gazebo turtlebot3_house_no_x.launch. Everything was installed using APT from Ubuntu's official repositories.

I want to be able to use GzWeb 1.4 to allow a group of people to view the simulator for testing purposes. The VM doesn't have X installed so I modified turtlebot3_house_no_x.launch to not try to launch the GUI client of Gazebo. However, I'm not able to use ROS twist message to move the turtlebot.

When I use these same files and packages on my personal machine (Pop!_os 18.04, GzWeb 1.4, Gazebo 9, ROS Melodic, all installed through official Ubuntu repositories), it does work. I am able to run roscore, roslaunch turtlebot3_gazebo turtlebot3_house_no_x.launch, start GzWeb using NPM, send a twist message and watch the robot move and turn.

turtlebot3_house_no_x.launch is a manually altered version of turtlebot3_house.launch which was then put into /opt/ros/kinetic/share/turtlebot3_gazebo/launch.
There is a corresponding turtlebot3_house_no_x.world in /opt/ros/kinetic/share/turtlebot3_gazebo/launch.
This is the case with both the VM and my local machine (melodic in place of kinetic on the local machine)

Looking at the output, it seems like the Laser and DiffDrive plugins aren't being run on the VM while they are on the local machine. I suspect that's causing the VM to not create topics related to robot movement, but I'm not sure. Does anyone know how to make or make sure those plugins are installed and running? Are there any other possible issues I may have missed?

Edit: It looks like libgazebo_ros_diff_drive.so, libgazebo_ros_gpu_laser.so, and libgazebo_ros_laser.so are present on my local machine but not my VM.

Here is turtlebot3_house_no_x.launch:

<launch>
  <arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>
  <arg name="x_pos" default="-3.0"/>
  <arg name="y_pos" default="1.0"/>
  <arg name="z_pos" default="0.0"/>
  <arg name="enable_ros_network" default="true" />

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/turtlebot3_house_no_x.world"/>
    <arg name="paused" value="false"/>
    <arg name="use_sim_time" value="true"/>
    <arg name="gui" value="false"/>
    <arg name="headless" value="true"/>
    <arg name="debug" value="false"/>
  </include>

  <group>
    <param name="gazebo/enable_ros_network" value="$(arg enable_ros_network)" />
  </group>

  <param name="robot_description" command="$(find xacro)/xacro --inorder $(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro" />

  <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model turtlebot3 -x $(arg x_pos) -y $(arg y_pos) -z $(arg z_pos) -param robot_description" />
</launch>

Here's turtlebot3_house_no_x.world:

<sdf version='1.4'>
  <world name='default'>
    <!-- A global light source -->
    <include>
      <uri>model://sun</uri>
    </include>

    <!-- A ground plane -->
    <include>
      <uri>model://ground_plane</uri>
    </include>

    <physics type="ode">
      <real_time_update_rate>1000.0</real_time_update_rate>
      <max_step_size>0.001</max_step_size>
      <real_time_factor>1</real_time_factor>
      <ode>
        <solver>
          <type>quick</type>
          <iters>150</iters>
          <precon_iters>0</precon_iters>
          <sor>1.400000</sor>
          <use_dynamic_moi_rescaling>1</use_dynamic_moi_rescaling>
        </solver>
        <constraints>
          <cfm>0.00001</cfm>
          <erp>0.2</erp>
          <contact_max_correcting_vel>2000.000000</contact_max_correcting_vel>
          <contact_surface_layer>0.01000</contact_surface_layer>
        </constraints>
      </ode>
    </physics>

    <!-- A turtlebot symbol -->
    <include>
      <uri>model://turtlebot3_house</uri>
    </include>

    <scene>
      <ambient>0.4 0.4 0.4 1</ambient>
      <background>0.7 0.7 0.7 1</background>
      <shadows>true</shadows>
    </scene>

    <gui fullscreen='0'>
      <camera name='user_camera'>
        <pose>0.0 0.0 17.0 0 1.5708 0</pose>
        <view_controller>orbit</view_controller>
      </camera>
    </gui>
  </world>
</sdf>

When running roslaunch turtlebot3_gazebo turtlebot3_house_no_x.launch on the VM, this is the output:

 ... logging to /root/.ros/log/c5dcbd66-5787-11ea-bb8a-00505699e55f/roslaunch-**HOSTNAME**-7747.log  
Checking log directory for disk usage. This may take awhile.  
Press Ctrl-C to interrupt  
Done checking log file disk usage. Usage is <1GB.  

started roslaunch server http://**url**:43371/  

 SUMMARY  
  ========

 PARAMETERS  
 * /gazebo/enable_ros_network: True  
 * /robot_description: <?xml version="1....  
 * /rosdistro: kinetic  
 * /rosversion: 1.12.14  
 * /use_sim_time: True  

 NODES  
  /  
    gazebo (gazebo_ros/gzserver)  
   spawn_urdf (gazebo_ros/spawn_model)  

 ROS_MASTER_URI=http://**URL**:11311/  

 process[gazebo-1]: started with pid [7767]  
 process[spawn_urdf-2]: started with pid [7768]  
[ INFO] [1583102557.565389130]: Finished loading Gazebo ROS API Plugin.  
[ INFO] [1583102557.578420607]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...  
[ INFO] [1583102568.330416867, 0.024000000]: waitForService: Service [/gazebo/set_physics_properties] is now available.  
[ INFO] [1583102568.492834420, 0.092000000]: Physics dynamic reconfigure ready.  
[spawn_urdf-2] process has finished cleanly  
 log file: /root/.ros/log/c5dcbd66-5787-11ea-bb8a-00505699e55f/spawn_urdf-2*.log

When I run rostopic list on the VM, I see:

/clock
/cmd_vel
/gazebo/link_states
/gazebo/model_states
/gazebo/set_link_state
/gazebo/set_model_state
/rosout
/rosout_agg

This is the output of roslaunch turtlebot3_gazebo turtlebot3_house_no_x.launch on my local machine:

... logging to /home/nathan/.ros/log/f5668fe2-5bf3-11ea-89cd-0cdd241f094b/roslaunch-pop-os-29387.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

xacro: in-order processing became default in ROS Melodic. You can drop the option.
started roslaunch server http://**IP**:46245/

SUMMARY
========

PARAMETERS
 * /gazebo/enable_ros_network: True
 * /robot_description: <?xml version="1....
 * /rosdistro: melodic
 * /rosversion: 1.14.3
 * /use_sim_time: True

NODES
  /
    gazebo (gazebo_ros/gzserver)
    spawn_urdf (gazebo_ros/spawn_model)

ROS_MASTER_URI=http://**IP**:11311

process[gazebo-1]: started with pid [29405]
process[spawn_urdf-2]: started with pid [29410]
[ INFO] [1583110316.654693753]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1583110316.655619646]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[ INFO] [1583110317.434862630, 0.022000000]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1583110317.448314472, 0.035000000]: Physics dynamic reconfigure ready.
[ INFO] [1583110317.771374197, 0.240000000]: Laser Plugin: Using the 'robotNamespace' param: '/'
[ INFO] [1583110317.771415012, 0.240000000]: Starting Laser Plugin (ns = /)
[ INFO] [1583110317.771993685, 0.240000000]: Laser Plugin (ns = /)  <tf_prefix_>, set to ""
[ INFO] [1583110317.880728083, 0.240000000]: Starting plugin DiffDrive(ns = //)
[ INFO] [1583110317.880919093, 0.240000000]: DiffDrive(ns = //): <rosDebugLevel> = na
[ INFO] [1583110317.882069783, 0.240000000]: DiffDrive(ns = //): <tf_prefix> = 
[ INFO] [1583110317.883728481, 0.240000000]: DiffDrive(ns = //): Advertise joint_states
[ INFO] [1583110317.884954389, 0.240000000]: DiffDrive(ns = //): Try to subscribe to cmd_vel
[ INFO] [1583110317.889751895, 0.240000000]: DiffDrive(ns = //): Subscribe to cmd_vel
[ INFO] [1583110317.890882132, 0.240000000]: DiffDrive(ns = //): Advertise odom on odom 
[spawn_urdf-2] process has finished cleanly
log file: /home/nathan/.ros/log/f5668fe2-5bf3-11ea-89cd-0cdd241f094b/spawn_urdf-2*.log

When I run rostopic list on my local machine:

/clock
/cmd_vel
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/set_link_state
/gazebo/set_model_state
/imu
/joint_states
/odom
/rosout
/rosout_agg
/scan
/tf