Gazebo | Ignition | Community
Ask Your Question

Running a Camera Sensor Headless

asked 2016-10-19 08:02:48 -0500

JLiviero gravatar image

updated 2016-10-24 16:57:20 -0500


We are looking to run a camera sensor headless on a VM, however when we do so several of the camera's image topic (notably, camera/image_raw) are not published. At ROSCon, I spoke briefly with Jose, who indicated that this could be done fairly painlessly, and is actually used for Gazebo's CI tests. How would I go about enabling that capability?

To clarify, we already have a camera plugin that runs just fine on a display-enabled machine. Our robot is defined in a URDF and launched using roslaunch. However, note that the "headless" option exposed by gazebo_ros_pkgsdoesn't actually work - see

I also don't see an explicit "headless" option list in the Gazebo code. The Gazebo devs did mention that such a mode was possible, I just can't figure out how.

(Running Gazebo 7 and ROS Indigo)

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2016-10-31 13:26:14 -0500

JLiviero gravatar image

Thanks guys. I've got a solution, which I'll post here for the benefit of anyone else who comes searching for such a thing later.

Because our VMs aren't running NVidia drivers as a rule, I wanted to explore some other options before attempting Jose's solution. Based on Nate and Jose's comments, I went digging into virtual xservers and found this old comment, which led me to Xvfb. With Xvfb, I was able to do the following:

$ Xvfb :1 -screen 0 1600x1200x16  &
$ export DISPLAY=:1.0
$ roslaunch etc etc.launch

...which let me run the camera plugin headlessly on a VM with no problems. Here's a screen grab from the camera, taken remotely by connecting RQT to the robot on the VM:

image description

(This timely Gazebo fix was also helpful.)

Thanks again!

edit flag offensive delete link more


This solution worked with my launch file. Thank you for sharing your fix!

GL gravatar imageGL ( 2017-01-12 16:41:55 -0500 )edit

answered 2016-10-19 14:06:43 -0500

chutsu gravatar image

updated 2016-10-19 14:07:34 -0500

I think it can be done by running the Gazebo server in Headless mode with the following command

gzserver  # then you can use gz topic -l to verify it is running

By default it doesn't have a camera sensor, so you will have to define your own world SDF file with a camera sensor.

The rest is up to you.

edit flag offensive delete link more


As I noted in the question, we already have a camera plugin that runs just fine on a display-enabled machine. Our robot is defined in a URDF and launched using roslaunch. I should have been more clear, sorry - I've updated my original question accordingly.

JLiviero gravatar imageJLiviero ( 2016-10-24 16:52:16 -0500 )edit

`gzserver` runs headless. Your machine will need an xserver running if you want to render camera data.

nkoenig gravatar imagenkoenig ( 2016-10-25 08:42:55 -0500 )edit

answered 2016-10-26 14:55:40 -0500

Jose Luis Rivero gravatar image

Hello Jordan:

As Nate has mentioned in the comments, you will need an xserver running to be able to render camera data. In order to have an xserver running with a headless setup and assuming that you are using an Nvidia card, you could use (starting with 331.* driver series):

nvidia-xconfig --allow-empty-initial-configuration

This should generate the following configuration in your Xorg.conf file:

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    Option         "AllowEmptyInitialConfiguration" "True"

Hope it helps. Thanks for sharing the feedback in the ROSCon!

edit flag offensive delete link more


Hi Jose, For this to work, do you also need to set up a display server like Xvfb? I am trying to run Gazebo on a Google Compute Engine instance running Ubuntu 16.04 with an Nvidia K80 GPU and have yet to get it working. If you are willing to take a look, I included a few more details in my StackOverflow post:

jsather gravatar imagejsather ( 2018-08-28 00:42:01 -0500 )edit

Question Tools



Asked: 2016-10-19 08:02:48 -0500

Seen: 8,240 times

Last updated: Oct 31 '16