Tilt compensation for lidar

hi community
trying a sf11 lidar on my hexacopter with pixhawk
connected to MP i put the copter horizontally at 1 meter above the ground, and of course sonar range is "1m00"
But when tilting to 45 degrees sonar range become 1m40 !!!
However, reading this discussion : https://github.com/ArduPilot/ardupilot/issues/2377 Copter-3.4 tilt compensates all range finders now
Could you help a poor french user ? thk

45 degrees is extreme, you may not be getting a very solid reflection depending on the surface material. How does the data look < 45deg?

it is proportional to the cosine, even at 30 degrees the error is large !

Here is the code (Thanks to @OXINARF) for QuadCopter : https://github.com/ArduPilot/ardupilot/blob/master/ArduCopter/sensors.cpp#L53
// correct alt for angle of the rangefinder
temp_alt = (float)temp_alt * MAX(0.707f, ahrs.get_rotation_body_to_ned().c.z);

So the tilt compensation is automatically enabled when there is an active rangefinder and the same method apply to any technologies (sonar - lidar - radar)

hi, thank you ppoirier !
Unfortunately my programming skills are weak, i don’t know what to do with this code…
help me please !!

it should works until you get a bank angle of 45 degree (cos 45 degrees =0.707) , just like you describe.

You can certainly get over 45 degree (like 60 deg = replace 0.707 for 0.5 and recompile), but I suspect you will get marginal reading from laser.

In order to do that you have to edit the file and recompile: http://ardupilot.org/dev/

A little OT:
Regarding a LIDAR such as the LightWare LW20 it would be great if the xy ground coordiantes could also be calculated in addition to the altitude compensation. The Lidar data could then be used to build a DSM (first return) and a DEM (last return) without a stabilzed gimbal.
Has anyone tested this?

thanks again ppoirier
but it doesn’t work even in the range 0 to 45 degrees !
i’m unable to edit end recompile the code …
an idea for me ?

Please answer:
Fliight Controler Model
Firmware release
RangeFinder Type = 7 LightWareI2C / 8 LightWareSerial
Describe how you test it, what number you are looking at, an preferably include a log file


Fliight Controler Model = Pixhawk
Firmware release = 3.4.6
RangeFinder Type = 8 LightWareSerial (SF11/c)
testing copter in my hand ,1 meter above the ground and tilting between 0 and 45 degrees, looking at sonar range in Mission Planner

Hummm, I suspect that the sonar range is raw distance and not the corrected altitude.

Try testing with the rangefinder as the primary altitude sensor (note that EK2 must be enabled)

on alt hold, the vehicle should keep altitude , and you can check looking at http://ardupilot.org/copter/docs/altholdmode.html#verifying-althold-performance-with-dataflash-logs

I tested it and yes it show altitude variation on sonar range while tilting the quad manually.
On alt hold, the altitude remains stable regardless of attitude (and look how much more stable is a rangefinder signal compared to the noisy barometer):

…et en prime, vous avez le terrain following :wink:

thank you very very very much for your assistance ppoirier
I’ll try testing sunday if the rain stop !
waiting next fly , here is a piece of last log

do you speak french ???

Cool, enjoy the fly :slight_smile:
Oui je sus de Québec

fantastic !!!
please can you explain to me in french (in a few words) the basics of programming ?
je voudrai juste savoir si c’est mieux de se mettre sous linux, avec quoi on compile et comment on upload vers le controleur
encore merci d’avoir pris de votre temps, c’est une super communauté ici !

You need to “read the book” :slight_smile:
In few words, you set the environment on a linux system , clone ardupilot code, edit your mods, and compile using WAF and finally upload on the FC

time to learn for me !
i begin with linux today