blodow / realtime_urdf_filter

ROS package that can filter geometry defined in URDF models from Kinect depth images. Can also preprocess data for the OpenNI tracker, to remove backgrounds, robots etc.
Other
90 stars 46 forks source link

realtime_urdf_filter

This package provides OpenGL-accelerated, shader-based filtering for depth images. Scene geometry is defined in URDF models, along with parameters defining the camera's location and filtering parameters. Both static environment models and articulated robot models are working beautifully, as long as TF latency is not too high.

Incoming Kinect frames are transferred to the GPU as textures, and the scene is rendered from the same point of view. As a result, we can access the measured as well as the virtual depth map in the shader, where we can define efficient comparison operations.

Example of robot self filtering to preprocess for human skeleton tracking:

Tracker Preprocessing

Robot self filtering for object manipulation:

Robot Self Filtering Robot Self Filtering

Dependencies

This has been verified to run on Ubuntu 14.04 with ROS Indigo.

This package requires the following: 3rd party libraries

NOTE: Trying to use this package with GLEW 1.5 will result in a segmentation fault.

ROS Interface

There are two ROS nodes that can be used out of the box:

Adapting it to different scenarios

There are two example launch files provided that show basic usage and parametrization and are a good starting point.

The following rosparam parameters are supported:

Also, the shaders in include/shaders/ can easily be adapted. The vertex shader is basically just a pass through, so the fragment shader is more interesting for adding features. The shader as of now has access to 4 color attachments, and the red channel of gl_FragData[1] is used to return the filtered image. The other attachments can be used for visualization (see show_gui).

Note: starting remotely

While this package uses offscreen rendering, it does need to connect to a X11 server to get a valid OpenGL context (even with show_gui set to false). When launching one of the nodes in this package remotely via roslaunch or similar mechanisms, it will be necessary to set a DISPLAY variable and possible turn off access control for the X server. In this case, a bash script like the following can be launched from remote::

    #!/bin/bash
    DISPLAY=:0
    xhost +
    roslaunch realtime_urdf_filter tracker.launch

Troubleshooting

Every once in a while, Assimp fails when importing STL files. If the first 5 bytes are "solid", it treats it as ASCII, however there are several binary STL files around that start with "solid". You'll get an error message along the lines of:

    [ERROR] [1360339850.748534073]: Could not load resource [package://pr2_description/meshes/sensors/kinect_prosilica_v0/115x100_swept_back--coarse.STL]: STL: ASCII file is empty or invalid; no data loaded

You can double check with e.g.:

    hexdump -C bad_stl_file.STL | head

In that case, a simple work around (read: "hack") is to replace the "solid" with "rolid", and assimp loads it as a binary file.

    printf 'r' | dd of=bad_stl_file.STL bs=1 seek=0 count=1 conv=notrunc

I'm not exactly sure why RViz does not seem to have this problem.

License

The code is licensed under the BSD License, see the LICENSE file in the project root dir.