RGL Gazebo Plugin has been created by Robotec.AI to bring Robotec GPU Lidar to Gazebo.
Key features:
- Point cloud computation using hardware-accelerated raytracing (Nvidia OptiX)
- High performance (~4x improvement over
gpu_lidar
sensor from Gazebo) - Multiple LiDAR pattern configuration methods, including importing a pattern from a binary file
- Realistic presets of the most popular LiDARs
-
OS: Ubuntu 20.04 or Ubuntu 22.04
-
Gazebo: Fortress 6.14
-
GPU: CUDA-enabled
-
Nvidia Driver: See RGL requirements
- Download libraries from release.
- Make RGL plugins visible to Gazebo:
- Move libraries to the plugin's directories.
# If Gazebo installed from apt: cp libRobotecGPULidar.so /usr/lib/x86_64-linux-gnu/ign-gazebo-6/plugins/ cp libRGLServerPluginInstance.so /usr/lib/x86_64-linux-gnu/ign-gazebo-6/plugins/ cp libRGLServerPluginManager.so /usr/lib/x86_64-linux-gnu/ign-gazebo-6/plugins/ cp libRGLVisualize.so /usr/lib/x86_64-linux-gnu/ign-gazebo-6/plugins/gui/
- Or set environment variables:
# Assuming that libraries: # libRGLServerPluginInstance.so, libRGLServerPluginManager.so and libRobotecGPULidar.so # are located in RGLServerPlugin directory, # and libRGLVisualize.so in RGLGuiPlugin. export IGN_GAZEBO_SYSTEM_PLUGIN_PATH=`pwd`/RGLServerPlugin:$IGN_GAZEBO_SYSTEM_PLUGIN_PATH export IGN_GUI_PLUGIN_PATH=`pwd`/RGLGuiPlugin:$IGN_GUI_PLUGIN_PATH
mkdir build
cd build
cmake ..
make -j
make install
cd ..
export IGN_GAZEBO_SYSTEM_PLUGIN_PATH=`pwd`/install/RGLServerPlugin:$IGN_GAZEBO_SYSTEM_PLUGIN_PATH
export IGN_GUI_PLUGIN_PATH=`pwd`/install/RGLVisualize:$IGN_GUI_PLUGIN_PATH
Launch the prepared simulation from test_world
directory:
ign gazebo sonoma_with_rgl.sdf
- Start the simulation by pressing play
- The lidar hits should be visible in the GUI
- You can control the car using the Teleop plugin (preferably changing the steering to the keyboard and upping the speed to 15)
The second sample world (rgl_playground.sdf) contains all supported object types with this plugin. Since the pattern_type is configured as pattern_preset
, it is required to set RGL_PATTERNS_DIR
environment variable before running the simulation:
# From the top-level directory of this repository
export RGL_PATTERNS_DIR=`pwd`/lidar_patterns
ign gazebo test_world/rgl_playground.sdf
RGLServerPlugin contains two plugins: RGLServerPluginManager
and RGLServerPluginInstance
. For the plugin to work properly, we need to include both.
<plugin filename="RGLServerPluginManager" name="rgl::RGLServerPluginManager"></plugin>
This is a global plugin and should be included only once per sdf, preferably inside the world entity. RGLServerPluginManager is responsible for synchronizing the scene between Gazebo and GPU (CUDA). At the moment manager handles all primitive geometry types (Box, Capsule, Cylinder, Ellipsoid, Sphere), planes, meshes and submeshes.
Inside the link entity in your model, add a custom sensor:
<sensor name="UniqueSensorName" type="custom">
<plugin filename="RGLServerPluginInstance" name="rgl::RGLServerPluginInstance">
<range>100</range>
<update_rate>10</update_rate>
<update_on_paused_sim>false</update_on_paused_sim>
<topic>rgl_lidar</topic>
<frame>RGLLidar</frame>
<pattern_preset>Alpha Prime</pattern_preset>
</plugin>
</sensor>
Note: All entities attached to the same <link> as lidar will be ignored from raycasting. This enables an adding visual representation of the sensor.
-
range - the maximum range that the hits will be registered (in meters).
-
update_rate - the frequency at which the lidar will perform raycasting (in Hz).
-
topic - topic on which pointcloud message (ignition::msgs::PointCloudPacked) will be published. A second topic with the
/world
postfix will also be created for visualization purposes. -
frame - frame_id for point cloud message header.
-
update_on_paused_sim - determines whether the lidar is active when the simulation is paused (optional, default: false).
-
pattern_<type> - definition of the lidar firing pattern. Each type has different parameters described below.
-
pattern_uniform
An analog to the gpu_lidar configuration (angles in radians).<pattern_uniform> <horizontal> <samples>1800</samples> <min_angle>-3.14159</min_angle> <max_angle>3.14159</max_angle> </horizontal> <vertical> <samples>128</samples> <min_angle>-0.436332</min_angle> <max_angle>0.261799</max_angle> </vertical> </pattern_uniform>
-
pattern_custom
channels attribute defines the angular position of lidar channels (angles in radians). Horizontal samples are uniformly distributed.<pattern_custom channels="0.69 -0.69 0.26 -0.26"> <horizontal> <samples>3600</samples> <min_angle>-3.14159</min_angle> <max_angle>3.14159</max_angle> </horizontal> </pattern_custom>
-
pattern_preset
We have prepared several lidar presets. You can type in the name of a LiDAR to use its pattern (all available patterns are shown below).<pattern_preset>Alpha Prime</pattern_preset> <pattern_preset>Puck</pattern_preset> <pattern_preset>Ultra Puck</pattern_preset> <pattern_preset>OS1 64</pattern_preset> <pattern_preset>Pandar64</pattern_preset> <pattern_preset>Pandar40P</pattern_preset>
Note: Before launching the simulation it is required to set
RGL_PATTERNS_DIR
environment variable with the path to pattern presets directory (lidar_patterns
from repository).# For example export RGL_PATTERNS_DIR=`pwd`/lidar_patterns
-
pattern_preset_path
If you wish so, You can create your own preset by providing a binary file with the structure below repeated as many times as you fancy. Please note that an absolute path is required./** * Row-major matrix with 3 rows and 4 columns of 32-bit floats. */ typedef struct { float value[3][4]; } rgl_mat3x4f;
<pattern_preset_path>/home/some1/your-preset.mat3x4f</pattern_preset_path>
To enable non-uniform point clouds visualization in Gazebo Fortress that are produced by RGLServerPlugin
, we port PointCloud gui plugin from Gazebo Garden and create RGLVisualize
. It reimplements the minimal functionality of receiving PointCloudPacked messages (in a world coordinate frame) and rendering them in the scene.
After starting the simulation:
- Add
RGLVisualize
gui plugin. - Select topic with
/world
postfix.
At Robotec.AI we care about every little detail of our product, so our presets mimic the patterns exactly. We take into account the fact that in many lidars, the lasers are staggered (not positioned exactly one above another), like in the Ultra Puck according to the manual, page 118.
Ultra Puck one horizontal step pattern | RGL digital twin |
---|---|
RGL uniform pattern | gpu_lidar uniform pattern |
---|---|