Understanding Optical Flow

I’ve been trying out optical flow for my first time with Ardupilot and wanted to ask for a bit of help on interpretation of logs with an optical flow/rangefinder installed on a Holybro X500. I am using the MicoAir MTF-01, mounted facing straight down on a leg-brace mount below the battery on the copter. MTF-01 - Optical&Range Sensor - MicoAir Tech

When I was doing some testing after setting up parameters from here - MicoAir MTF-01 Optical Flow Sensor — Copter documentation

and here

I had multiple EKF failovers to Dead Reckoning, which I understand to be because I was using solely the optical flow module for positioning at those times and it could no longer generate a good position estimate.

When I look at the plot of one of those flights, however, I can’t really tell where the “threshold” is that’s triggering the dead reckoning. I’m looking at OF.Qual on the graph as well as the rangefinder altitude, and it seems like every time I change the EFK source set to the optical flow, I get about 6-15 seconds of flight before dead reckoning starts up again, but the OF.Qual is roughly in the high 120’s to 130s range most of the time. Am I just right at that flow quality threshold the entire time?

While I was flying, I thought this was because I was gaining too much altitude for the rangefinder to see the ground as well as the optical flow, but in the log it seems to show that the rangefinder was out of range for most of the flight, apparently I was flying too high in general, I was flying line-of-sight and apparently overestimated. Am I correct in that the rangefinder is doing essentially nothing during this flight except on takeoff and landing?

If anyone could shed some light on this, that’d be great.

X500OptFlowError.bin

Didn’t check the log but the rangefinder is needed for optical flow. You must fly under its limit

You’ll need to get the range finder working. I”m not seeing any rangefinder data in the log. They say that sensor should be good for 8m …. I have the MTF-01P that’s supposed to be good 12m, but I only get 6-8m. So with this one I’d be expecting 4-5m outside.

SERIAL2_OPTIONS,1024

assuming you’re using serial 2 for the Optical flow.

1 Like

$3/meter isn’t bad :slight_smile:

1 Like

They aren’t bad units. Even when I convert it to the local metric dollars they’re still a good deal.

2 Likes

Yea, I have one I’m going to try out on the latest build.

MTF-01 and MTF-01P rangefinders look exactly the same. From comparing datasheets it looked like the ranges are specified under different lighting conditions. I would have to check the log but IIRC when I was testing my heli on a sunny day I started losing rangefinder at 3.5m or thereabouts over grass.

Are you sure that this not a firmware config issue and is a hardware limitation?
I use a MTF-02 rated upto 2m (max limit of the rangefinder being 2.5m @ 600 lux and 90% reflectivity) and I do get slightly more than 2m indoors although I haven’t tested it outdoors yet.

Direct sunlight plays havoc with these cheaper sensors. The first one I used years ago worked fine indoors, but the first time I tried it outside it didn’t register anything after it got out of it’s own shadow. Turns out the day was clear blue sky and the ground had a fresh layer of untouched snow. I don’t think it could get any brighter.

1 Like

Well, yeah right I read somewhere that these rnagefinders may work better in lower lighting. But optical flow needs more than that so I guess in reality the max altitude is a sweetspot between these two.
You mentioned snow and I guess it was making stuff extra bright due to its reflectance

Thanks for taking at look at this, everyone. I think I do have the rangefinder working, it displays data in Mission Planner on the ground it just only performs at altitudes much lower than what I expected, unfortunately. Am I reading the log correctly below? I can see it in the log at the beginning and end/take-off and landing, but it drops off after detecting up to max 3.8 meters, in RFND.Dist, whereas most of the flight took place around 5-15m as measured by the barometer. So I suppose with this model of rangefinder I just need to fly lower for it to work properly. Luckily I purchased some of the 12m models for future use, which sound like they’re a bit more reasonable to use.

@Allister - did I not have that 1024 bit set? Dang, I thought I did, but that must’ve been on another flight controller. Would that have affected the rangefinder’s function in flight?

Which model rangefinder were you using when you were losing it at about 3.5m? That lines up fairly well with what I think I’m seeing with the 8m model. I flew mine on a semi-cloudy day if memory serves me correctly.

My bad, the range finder was working. I was zoomed in the areas when the failsafes were triggered and there was no range finder data at those points. I do see it at the beginning and end of the flight when you were below 3.5m.

So even though Micoair recommends that serial options setting, to me it looks like it doesn’t matter. I’d set it just to remove it as a variable. Then we’ll all know for sure. :slight_smile:

I think you just hit the limits of the range finder.

Seems consistent with the performance the others were reporting.
That aside, I don’t know your exact use case but maybe you’ll find this helpful if you already didn’t know if this feature? High Altitude Optical Flow -- Testers needed!

1 Like

RFND.Stat 4 = Good

RFND.Stat 2 = Out of Range (low)

Not sure why it’s saying low, but out of range is consistent. If I get some time I might go digging through some of my old logs to see what mine says.

“Out of range (low)” means lesser than the minimum configured altitude?

1 Like

Interesting! How did you determine what RFND.Stat actually means/refers to? Many of the logged parameters are mysterious to me and don’t have much of a description that I’ve ever been able to find.

I’ll look into that! Thanks!

Use this page:

2 Likes

Did another flight and I seemed to have much better results at a lower altitude. Thank you for the tips, everyone. I had one other question though - why did I get a switch into Dead Reckoning/RTL at about 4:07 into the flight? It was right after switching from Optical Flow EKF Source Set back to the default GPS source set. I tried it again multiple times during the flight and didn’t see the same behavior. Can anyone tell why this happened? Thanks!

Log - OptFlow2ndTest.bin