Use of optical flow

hello @ppoirier
looking at the mode_land I found that there were two modes of landing, with and without GPS
how are used PX4flow and Garmin LidarLiteV3 as optical flow velocity controler ?


Are you referring to Land and Return To Land ?
RTL is a guided mode to home at a predetermined altitude and Land, actually I never tried in OF mode, if it work it might be quite ‘‘fuzzy’’ because of the accumulated error of the Velocity/Inertial Controlers

1 Like

I’m talking about landing using OF for horzontal control and Lidar for vertical control
you have already implemented the landing accurately using these two sensors and a Companion Computer that runs openCV
in my case I do not have Companion Computer that runs openCV
I just want
1- take off the drone then switch to Alt_hold mode or give orders via mission planner
2- to land the drone from any place
I have a question: Is the landing using these two sensors already taken by ardupilot ???

When you hit land, the OF is just keeping the x-y velocity to minima and the rangefinder will be used to get the altitude (with baro if enabled).

1 Like

thank you very much, Mr. Patrick,
just by curiosity
looking at the code ardupilot, I’m trying to figure out where is this treatment is described in the code, but I could not find it
do you know in which file I can find the treatments perform on OF data ?

The OF is fused into EKF and then is injected in to the AHRS, so depends of what you are looking for, there is no direct relation between the Px4Flow driver and the positionning of vehicle.

1 Like

thank you for all those informations

I hate to test it as soon as I get the engines and propellers

is take-off in guided mode using otical flow supported with ardupilot now ?

BTW you can test in simulator :wink:
Yes you can takeoff in guide using OF

1 Like

good idea :ok_hand:
but the default sensors used in the simulator (SITL for example) are the GPS and the barometer, is there any way to disable these two and add in their place the OF & the lidar ?
otherwise what is the best simulator to use that integrates the OF and lidar ?

Its just like the real thing , so you disable GPS and enable OF == for this look on the wiki its pretty weel explained

I wish you good experimentation

1 Like

I have a question, as i’m trying to gain a basic understanding of OpticalFlow.

Could OF actually be used for altitude keeping? Maybe a second sensor which can assist with the BaroAltimeter and prevent big changes when there is a large pressure change? In fact it might even be able to feed back into the Desired_altitude after a pressure change…assuming the drone is staying still. Couldn’t the OF observe altitude changes following this chart? When it notices all pixel on the border have moved “inbound” then it knows it is gaining altitude. And vice versa if the pixels are moving altitude, we know we are losing altitude. Does that make sense?

Have you looked at this ?

That is a new class to support FLOWHOLD mode, which is a position hold mode using optical flow directly, avoiding the need for a rangefinder

Yes, but I believe (if i understand what is going on here) the flowhold isn’t using the optical sensor to maintain altitude, the FLOWHOLD mode takes into account the baroAlt sensor to scale the image tracking algorithms of the opticalFlow module. The optical sensor is still only being used to maintain X/Y and the baroAlt to maintain Z. right? I guess i was just wondering if my thoughts on using the optical flow algorithm to be able to tell if you’re increasing or decreasing altitude was even valid. Obviously, you’d still need baroAlt or something for absolute altitude, but the optical flow sensor might be able to dampen some of the large AltHold swings due to changing baro pressure…

Hi, @ppoirier.
Is it possible to fly in GUIDED mode using only OF and LiDAR, holding the position? Should I use GUIDED or GUIDED_NOGPS?

Yes it is possible to fly GUIDED, but do not expect precision as the OF is not an absolute positioning system so you will experience drift

Okay. The strange thing is that when flying in Loiter, manually controlling using the radio transmitter, the drone is stable like a rock using optical flow. I was hoping to get at least the same result programmatically, but in GUIDED_NOGPS the drift is like I don’t have optical flow. I will try in GUIDED tomorrow morning. Thank you very much for your time. Regards!

Hi @ppoirier,
I want to use optical flow without rangefinder or sometimes disable rangefinder and the barometer’s accuracy is enough for me, is it possible?
In general, I want to know what is the job of a rangefinder? From what I understand its job is in alt accuracy because of the lack of GPS, is it true?


OpticalFlow require a rangefinder in order to process the estimation velocity correctly.

Alternatively you can use FlowHold that is a different method, but less stable and accurate == read the warning :wink:

1 Like

@ppoirier, thank you very much for your fast and complete response :pray:
I have a rough surface and I want to disable the rangefinder with RCx_OPTION=10 but I can connect it to the ardupilot. Will then be also problems with velocity or stability?