morse-simulator / morse

The Modular OpenRobots Simulation Engine
http://morse-simulator.github.io/
Other
353 stars 156 forks source link

Document how to run MORSE in headless mode #685

Closed severin-lemaignan closed 8 years ago

severin-lemaignan commented 8 years ago

The following content may be used as a starting point:

Headless MORSE

Brief summary

I stream the pose of the robot with ROS at 60Hz with no display/no GPU at all on a Intel Core i7.

In the same conditions, I stream a camera at 2.7Hz.


First, let's clarify one thing: MORSE requires OpenGL. There is currently no way around, and, as a 3D simulator, we are likely to keep this requirement in the foreseeable future.

So 'headless' MORSE still means that your OS of choice provides an OpenGL implementation.

OpenGL does not mandate a GPU, though. It is hence perfectly possible to run MORSE in the cloud, for instance on a cluster that does not provide GPUs. Obviously, no GPU means no 3D hardware acceleration, but depending on your application, it can still be perfectly ok. Read on for some 'benchmarks'.

In the Linux world, the best option, today, for CPU-based 3D acceleration is LLVMpipe. It is really easy to install (it took me ~5min to compile and test MORSE on the CPU).

Grab the lastest version of Mesa here (tested with 9.2.2): ftp://ftp.freedesktop.org/pub/mesa/

Compile with:

$ scons build=release libgl-xlib

This will result in a new libGL.so that uses the CPU instead of the GPU. Blender runs pretty well with it.

To run MORSE with this library:

LD_LIBRARY_PATH=<path to your Mesa>/build/linux-x86_64/gallium/targets/libgl-xlib morse run <env>

Some quick performance results with the default environment:

$ morse create test

(edit test/default.py and add env.show_framerate() at the end for the FPS)

Intel HD4000
$ morse run test

-> 60 FPS with hardware acceleration (Intel HD4000 IvyBridge)

LLVMpipe
$ LD_LIBRARY_PATH=<mesa>/build/linux-x86_64/gallium/targets/libgl-xlib morse run test

-> 14 FPS with LLVMpipe on a Intel Core i7, 8GB RAM

FASTMODE=True

(edit test/default.py and switch fastmode to True)

In fast mode, you only get the wireframe of the models: this is fine if you do not do any vision-based sensing.

$ LD_LIBRARY_PATH=<mesa>/build/linux-x86_64/gallium/targets/libgl-xlib morse run test

-> 54 FPS with LLVMpipe on a Intel Core i7, 8GB RAM

Last thing: on a headless server, you may want to run Xvfb to create a 'fake' display to run MORSE. You need to create it with a depth of 24bit:

$ Xvfb -screen 0 1024x768x24 :1 &
$ LD_LIBRARY_PATH=<LLVMpipe path> DISPLAY=:1 morse <...>

A quick test shows that I can stream one camera with ROS at 2.7Hz :-/, but in fast mode, I stream the pose of the robot at 60Hz without issue.