Lidar angle correction

I try to using lidar and it working perfectly if dron is horizontal ( not moving or slow moving ).
but if change angle ( fly ) then lidar see other point ( away ) and move down and after stop move go up.
If it can be corrected by actual angle ?

The code already assumes that the lidar is pointing down, fixed to the frame and automatically corrects for the pitch and roll angles.
So the feature you want is already there. I am assuming that your parameters are correctly set.
Of course if you did not read the wiki and your parameters are incorrect, it will not work!

Im using this description and shows height good…
And change flight level when changing angle of frame.

Newest Firmware

So if you hold the copter with your hand and keep it 1m above the ground and tilt it slowly the height changes? if it does you found a bug


At this moment i disable it because it was too big and dangerous problem, will check again for some time.


The reported value in sonarrange will change with angle - but that’s not what gets used in AltHold, Loiter, etc. It’s just the raw distance measured by the LiDAR.

If you’re curious, here’s the actual line of code where the correction is applied, and the correction function itself.

1 Like

Thanks. Looks good. I will check again. If i can found in logs data from lidar ? I want to compare it with alt and angle.

I dont know why not good AltHold with lidar and good without lidar. Maybe its problem with switching lidar/baro near lidar range.

Compare the following log items from a dataflash log (tlogs may have some as well, but I don’t know those):

  • CTUN.DSAlt (desired LiDAR altitude, i.e. what the pilot asked for)
  • CTUN.SAlt (actual achieved LiDAR altitude, with the angle correction factored in)
  • RFND.0.Dist (measured rangefinder distance, without the angle correction factored in)
  • ATT.Roll
  • ATT.Pitch

Unfortunately, I haven’t experienced a bad althold with lidar so I can’t give a whole lot of advice there.

same problem for me…
I see the tilt correction but what about the roll correction

It corrects both tilt and roll

1 Like