Servers by jDrones

Tilt compensation for lidar

(Pierre Louis Delmas) #1

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 : Copter-3.4 tilt compensates all range finders now
Could you help a poor french user ? thk

(MagicRuB) #2

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

(Pierre Louis Delmas) #3

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

(ppoirier) #4

Here is the code (Thanks to @OXINARF) for QuadCopter :
// 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)

(Pierre Louis Delmas) #5

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

(ppoirier) #6

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:

(Thorsten) #7

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?

(Pierre Louis Delmas) #8

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 ?

(ppoirier) #9

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

(Pierre Louis Delmas) #10


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

(ppoirier) #11

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

(ppoirier) #12

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:

(Pierre Louis Delmas) #13

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 ???

(ppoirier) #14

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

(Pierre Louis Delmas) #15

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 !

(ppoirier) #16

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

(Pierre Louis Delmas) #17

time to learn for me !
i begin with linux today