Add more sensors to Gazebo - SITL

Hi, I’m adding 2 lidars to my quadplane in gazebo/sitl/ros. The work you have done is impressive but It’s not clear to me how I can integrate your work with my setup. What is the most relevant video/ page to visit to help solve this issue?

Hi @Pyotyr_Young, the comments above refer to simple proximity / range sensors rather than lidar so wouldn’t be directly applicable to the problem you’re looking to solve.

If you are already using ROS then one approach might be to use mavros to forward the data from Gazebo. There is a discussion here of the approach Gazebo with LiDAR. I’ve yet not attempted this myself so can’t advise on tips and tricks to get it all working.

Update

@Pyotyr_Young I’ve been looking into getting Ignition to work with ROS2, mavros (ros2) and ArduPilot SITL, and it’s finally in a state where I can offer a few pointers for your quadplane.

The example shown above illustrates a simple skid steer rover equipped with a 360 deg laser scanner controlled by ArduPilot SITL.

The code is available here: GitHub - srmainwaring/ros_ign_rover at feature/mavros2. A word of warning - it is all ROS2, and much of it experimental and targeting macOS rather than linux.

  • The ROS environment is ros2 galactic
  • The model is defined in URDF and spawned into Ignition Gazebo using the ros_ign_gazebo node
  • Pose, odometry and sensor data in Ignition is made available to ROS2 using the ros_ign bridge.
  • Laser scan data is forwarded to SITL by mavros
  • Vehicle control is via ArduPilot/ardupilot_gazebo

The basic set up is that you configure the mavros_extras obstacle plugin to forward sensor_msgs/msg/LaserScan data to mavlink as an OBSTACLE_DISTANCE message. Your vehicle must set PRX_TYPE=2 (mavlink). SITL appears to convert this internally to a DISTANCE_SENSOR message for the 8 sectors required by the avoidance code.

The main outstanding issue with the example is the frame transformation for the lidar data. There does not appear to be any transform carried out in the mavros node responsible for forwarding range data via mavlink (so the proximity graph is showing the obstruction on the wrong side of the rover as the body frame conventions in ArduPilot and Gazebo differ by 180 deg about x = forward). I’ll need to add a filter node to flip the scan data about before passing to mavros.

1 Like