gz-sim icon indicating copy to clipboard operation
gz-sim copied to clipboard

Custom lidar sensor

Open rsc9421 opened this issue 1 year ago • 4 comments

Hi, i want to simulate livox lidars (xyz) but they have a special "rosette" type pattern. I've read the documentation but I can't find how to simulate individual GpuRayPlugin as it could be done in gazebo classic.

I have the .csv files that indicate where each lidar should point, so all I need to simulate it is:

  • set the inclination angles of each ray
  • that each ray returns the distance so I can calculate the point (x,y,z)
  • I need to use the gpu because it is 100k points per second

If you can help me with a little example I could make a contribution

rsc9421 avatar Apr 04 '23 05:04 rsc9421

Hi, this is just my guess as to how it might work but it does require quite some changes:

  • Enhance SDF specification for LiDARs to allow different types of patterns
  • Check which pattern type is selected for the LiDAR and store the required type in the class
  • Adjust the array shape of the default LiDAR data for LaserScan messages if your "rosette" pattern is selected
  • GPU LiDAR PointCloudPacked (PointCloud2 in ROS) messages also need support for the new pattern

Also I think it would've been better if you had created the issue in the gz-sensors project so that it would reach the experts for sensor implementations directly :wink:

Bi0T1N avatar Apr 05 '23 20:04 Bi0T1N

Also I think it would've been better if you had created the issue in the gz-sensors project so that it would reach the experts for sensor implementations directly wink

I think just about everybody on the gazebo-dev team is subscribed to all the repos, so it will get seen no matter what :)

mjcarroll avatar Apr 06 '23 12:04 mjcarroll

In addition to what @Bi0T1N said above, from a rendering perspective, the actual implementation changes that will be needed are:

The underlying gz::rendering::Ogre2GpuRays sensor will need to be adjusted to take a new set of "direction vectors" for each ray of your custom pattern.
* The place that this is expanded out is here: https://github.com/gazebosim/gz-rendering/blob/c2e72ee51a7e4dba5156faa96c972c63ca5ab437/ogre2/src/Ogre2GpuRays.cc#L827-L950
* Right now, this assumes a uniform distribution of points over a window (min -> max, stepping with hStep). There is a little bit more work because this is actually handled with multiple rendering cameras arranged in a box, so you have to associate with the correct face of the "cube"

You may want to experiment a bit by implementing a custom sensor before going through the effort of getting it all "standardized" through sdformat and the rest of the libraries.

mjcarroll avatar Apr 06 '23 13:04 mjcarroll

I came across following plugin. Posting here as I assume it could be a solution, or a relevant example: https://robotec.ai/gazebo-lidar-rgl-plugin/

jrutgeer avatar Aug 10 '23 16:08 jrutgeer