Why z position does not match with lidar distance sensor data?

I am using SF20C Lightware Lidar. I have set EKF2_HGT_REF to Range Finder. I am using PX4 1.16.0. I have done other parameter configuration for enabling the lidar. As i am doing bench test, i have disbabled GPS. Why is the agl reading on QGC not matching with the data shown in the distance_sensor- current_distance topic?

First thought is that EKF transforms the distance from distance_sensor taking into account current attitude (roll and pitch) of the drone.
Also you should set position of the IMU, distance sensor and GPS relative to the CoG using EKF2_IMU_POS_X/Y/Z etc…

It’s best to compare vehicle_local_positionwith raw distance_sensor data. It would be helpful to attach some plots or logs as without it it’s just guesing.


Will this plot help in the analysis? I had attached the lidar to the side of the autopilot.

It looks like your rangefinder has some troubles. Seeing the straight horizontal lines in the distance_sensor readings, I would assume no new value has been reported or has not been reported with enough accuracy. Please check your distance sensor physically, it might be obstructed or not firmly mounted. I had similar issues because of a slight obstruction.