Bad LIDAR and Optical Flow health - vl53l0x

We have attached a VL53L0X Lidar via I2C on pixhawk cube on copter 4.4.0 and set parameters as below:

RNGFND1_TYPE = 16 (same as VL53L0X)
RNGFND1_ADDR = 41 (The sensor’s default I2C address is 0x29 hexademical which is 41 in decimal)
RNGFND1_SCALING = 1
RNGFND1_MIN_CM = 2
RNGFND1_MAX_CM = 100 (120 for the VL53L0X)
RNGFND1_GNDCLEAR = 15

And we get bad lidar health warning. I can arm the drone in Alt hold but I need the drone to take off autonomously.
Here is a log I got:

Beside that I also have an optical flow problem. I have written a C++ code on raspberry pi 4 to calculate OF and send the data to flight controller via Mavlink using the USB port. The data I see on mission planer looks good but I get bad optical flow massage. after that I attached a SPI sensor to arduino and sent the OF massage with uart to telem1 port and the bad OF massage is gone but the data dose not look accurate. Here is the Log I got while my code was running.

And one more thing, for the drone to take off autonomously using mavlink massages on guided no gps mode OF and rangefinder is all I need?

its possibly a bad sensor. its not uncommon for vl53l0x sensors to be faulty out the box.

optical flow is like counting steps with your eyes closed, its fine for staying still or very short distances but the errors soon add up if you try and do any kind of distance without external correction like GPS. Its normally just used to assist hovering in one spot as it will be more accurate at sub 1m distance than a regular GPS.

The problem is that it’s for indoors and using a GPS is not possible. And exactly I’m using OF to assist hovering in one spot but why do I get “Bad Optical Flow health” massage running my code?
And I have 3 VL53L0X sensors and all of them are faulty? How does it evaluate the sensors being healthy? The data looks pretty good.

how many do you have connected?

One at a time. The vl53l0x connects using I2C and the sensors addresses are the same. Is it even possible to connect 2 or more?

have you changed the lidar orientation to 25?

yes, I have done that already.

Hi @vortex0,

The rangefinder health warning is because the distance reported by the rangefinder is below the RNGFND1_MIN_CM value (currently 50). I think if you set this parameter to 1(cm) then the error will go away.

BTW, the VL53L0X lidar are really not very useful due to their very short range.

The optical flow messages from the RPI are only being sent at less than 3hz. So below is a screenshot from the logs where I’ve filtered for only the OF message. On the left side we can see that we are only getting about 2 or 3 message per second. I think the minimum is 7hz and really you should be aiming for 15hz or higher.

By the way, if you’re happy sharing would it be possible to share the code you’re using on the RPI to calculate the optical flow values? No pressure of course but I have just working on the same thing but using a stabilised drone camera gimbal (the Xacti to be precise) so it would save me some effort.

2 Likes

the VL53l1x is a much better sensor with up to 4m range.

1 Like

I tried reducing RNGFND1_MIN_CM value to 1 but I still get “Bad lidar health”. Are there any other things that lead to this error?
I even tried switching the rangefinder sensor to the srf0f ultra sonic sensor but the problem with that is that I cannot find which servo number corresponds to the aux ports on the pixhawk cube.
I did set up the rngfnd1 pin to 50 and rndfnd1 stop pin to 51 and connected the sensor trig and echo pin but obviously it didn’t work.
I even tried changing the gpio_servo_mask parameter but there were 32 servos and I had no idea which one was the aux port that I was looking for. can anyone help me with that?

Thanks to you the optical flow problem has been solved. Unfortunately at the moment I cannot share the optical flow code online but I’d be happy to email it to you. Just send me an email at Fatemeh1p13@gmail.com.

@vortex0,

You could try lowering RNGFND1_MIN_CM to 0. If that doesn’t clear up the error then it means the lidar itself is reporting that it cannot calculate a distance in which case the only solution may be to raise the lidar, replace the lidar or maybe disable the rangefinder arming check (but leave the others enabled of course).
image