Gz_x500_lidar_2d can't publish /scan

Hello everyone. Happy new year!

I installed the new PX4 Toolchain and ran the make px4_sitl gz_x500_lidar_2d simulation.
However, I found out that the /scan topic that came out before is no longer issued.
What is the problem?

$ make px4_sitl gz_x500_lidar_2d
[0/1] cd /home/quad/PX4-Autopilot/build/px4_sitl_default/src/modules...500_lidar_2d /home/quad/PX4-Autopilot/build/px4_sitl_default/bin/px

______  __   __    ___
| ___ \ \ \ / /   /   |
| |_/ /  \ V /   / /| |
|  __/   /   \  / /_| |
| |     / /^\ \ \___  |
\_|     \/   \/     |_/

px4 starting.

INFO  [px4] startup script: /bin/sh etc/init.d-posix/rcS 0
INFO  [init] found model autostart file as SYS_AUTOSTART=4013
INFO  [param] selected parameter default file parameters.bson
INFO  [param] importing from 'parameters.bson'
INFO  [parameters] BSON document size 442 bytes, decoded 442 bytes (INT32:16, FLOAT:6)
INFO  [param] selected parameter backup file parameters_backup.bson
INFO  [dataman] data manager file './dataman' size is 7872608 bytes
INFO  [init] Gazebo simulator
INFO  [init] starting gazebo with world: /home/quad/PX4-Autopilot/Tools/simulation/gz/worlds/default.sdf
WARN  [init] PX4_GZ_MODEL_POSE not set, spawning at origin.
INFO  [gz_bridge] world: default, model name: x500_lidar_2d_0, simulation model: x500_lidar_2d
INFO  [gz_bridge] Requested Model Position: 0,0,0,0,0,0
INFO  [gz_bridge] Model position z is less or equal 0.0, moving upwards
QStandardPaths: wrong permissions on runtime directory /run/user/1000/, 0755 instead of 0700
libEGL warning: MESA-LOADER: failed to open vgem: /usr/lib/dri/vgem_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)

libEGL warning: NEEDS EXTENSION: falling back to kms_swrast
libEGL warning: MESA-LOADER: failed to open vgem: /usr/lib/dri/vgem_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)

libEGL warning: NEEDS EXTENSION: falling back to kms_swrast
INFO  [lockstep_scheduler] setting initial absolute time to 12000 us
INFO  [commander] LED: open /dev/led0 failed (22)
INFO  [tone_alarm] home set
INFO  [uxrce_dds_client] init UDP agent IP:127.0.0.1, port:8888
INFO  [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18570 remote port 14550
INFO  [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14580 remote port 14540
INFO  [mavlink] partner IP: 172.21.64.1
INFO  [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14280 remote port 14030
INFO  [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13030 remote port 13280
INFO  [logger] logger started (mode=all)
INFO  [logger] Start file log (type: full)
INFO  [logger] [logger] ./log/2025-01-28/08_26_08.ulg
INFO  [logger] Opened full log file: ./log/2025-01-28/08_26_08.ulg
INFO  [mavlink] MAVLink only on localhost (set param MAV_{i}_BROADCAST = 1 to enable network)
INFO  [mavlink] MAVLink only on localhost (set param MAV_{i}_BROADCAST = 1 to enable network)
INFO  [px4] Startup script returned successfully
pxh> WARN  [health_and_arming_checks] Preflight Fail: No connection to the ground control station
INFO  [commander] Ready for takeoff!
$ gz topic -l
/clock
/gazebo/resource_paths
/gui/camera/pose
/gui/currently_tracked
/gui/track
/model/x500_lidar_2d_0/command/gimbal_pitch
/model/x500_lidar_2d_0/command/gimbal_roll
/model/x500_lidar_2d_0/command/gimbal_yaw
/model/x500_lidar_2d_0/command/motor_speed
/model/x500_lidar_2d_0/servo_0
/model/x500_lidar_2d_0/servo_1
/model/x500_lidar_2d_0/servo_2
/model/x500_lidar_2d_0/servo_3
/model/x500_lidar_2d_0/servo_4
/model/x500_lidar_2d_0/servo_5
/model/x500_lidar_2d_0/servo_6
/model/x500_lidar_2d_0/servo_7
/sensors/marker
/stats
/world/default/clock
/world/default/dynamic_pose/info
/world/default/model/x500_lidar_2d_0/link/base_link/sensor/air_pressure_sensor/air_pressure
/world/default/model/x500_lidar_2d_0/link/base_link/sensor/imu_sensor/imu
/world/default/model/x500_lidar_2d_0/link/base_link/sensor/navsat_sensor/navsat
/world/default/model/x500_lidar_2d_0/link/link/sensor/lidar_2d_v2/scan
/world/default/model/x500_lidar_2d_0/link/link/sensor/lidar_2d_v2/scan/points
/world/default/pose/info
/world/default/scene/deletion
/world/default/scene/info
/world/default/state
/world/default/stats
/x500_lidar_2d_0/command/motor_speed
/model/x500_lidar_2d_0/odometry_with_covariance
/world/default/light_config
/world/default/material_color
/world/default/model/x500_lidar_2d_0/link/airspeed_link/sensor/air_speed/air_speed
/world/default/model/x500_lidar_2d_0/link/camera_link/sensor/camera_imu/imu
/world/default/model/x500_lidar_2d_0/link/lidar_sensor_link/sensor/lidar/scan
/world/default/wrench
/world/default/wrench/clear
/world/default/wrench/persistent

The topic is there:
/world/default/model/x500_lidar_2d_0/link/lidar_sensor_link/sensor/lidar/scan

1 Like

I got it.
Thank you.

How can I send LiDAR data to QGroundControl for obstacle avoidance, as I can’t see it, and need it properly transmitted and displayed using MAVLink?

1 Like

As I know,
You will need to use the appropriate MAVLink message to send LiDAR data. The most common message for obstacle data is DISTANCE_SENSOR. This message allows you to send distance readings from the LiDAR.

Here’s an example of how to populate the DISTANCE_SENSOR message:

mavlink_distance_sensor_t distance_sensor_msg;
distance_sensor_msg.time_boot_ms = millis(); // Time in milliseconds since system boot
distance_sensor_msg.min_distance = 0; // Minimum distance of the sensor
distance_sensor_msg.max_distance = 100; // Maximum distance of the sensor
distance_sensor_msg.current_distance = measured_distance; // The current distance measured by the LiDAR
distance_sensor_msg.type = MAV_DISTANCE_SENSOR_LASER; // Type of the sensor
distance_sensor_msg.id = 0; // Sensor ID
distance_sensor_msg.orientation = MAV_SENSOR_ORIENTATION_PITCH_90; // Orientation of the sensor
distance_sensor_msg.covariance = 0; // Covariance
distance_sensor_msg.horizontal_fov = 0; // Horizontal field of view
distance_sensor_msg.vertical_fov = 0; // Vertical field of view
distance_sensor_msg.signal_strength = 0; // Signal strength (if applicable)

// Send the message
mavlink_msg_distance_sensor_send(chan, &distance_sensor_msg);

Hi.
When I check this topic, there is no message.

$ gz topic --echo --topic /world/default/model/x500_lidar_2d_0/link/lidar_sensor_link/sensor/lidar/scan

and when I check through gz sim same result.
What is the problem?

OBSTACLE_DISTANCE message is more suitable, I know.