Optical flow and rangefinder, need position estimate

I have a 5 inch drone with a Arducopter 4.6.3, a compass only, so no GPS and a Matek 3901-L0X.
This is specific for indoor use.
The rangefinder is working and the optical flow sensor opt_m_x, opt_m_y and opt_qua is producing data.

ALT_HOLD is working I think when using the rangefinder. I’m not 100% sure, because I don’t know how to check this.

But when I try to enable loiter I get this message:

Mode change to LOITER failed: requires position

Why, and how to troubleshoot this?

Set home here => Set EKF origin here

I tried a lot already:

Is there a way to check if EKF3 is using the optical flow sensor and the rangefinder, or why not?

Good infomation is hard to come by, just like the decision making process in EKF3 why and when something does or doesn’t work.

As, @rmackay9 said, just ensure your rangefinder min distance parameter would be lower than what the actual value it is displaying while the drone is on the ground. I would suggest to just set it to 1cm

1cm doesn’t really matter, nothing changes, according to ChatGPT this is the problem:

Why the EKF tries but never succeeds

From the log, this loop happens repeatedly:

:check_mark: What passes

  • Flow messages are present

  • Flow velocity is accepted (velocity_horiz On)

  • Rangefinder height is valid

  • Attitude is valid

:cross_mark: What fails

  • Optical flow innovation magnitude vs variance

  • Optical flow quality threshold

  • Optical flow consistency over time

Because of that:

  • EKF never declares position observable

  • Origin is never “locked in”

  • pos_horiz_rel stays Off forever

That’s why in your screenshot:

  • Velocity bar is green

  • Position (Horiz) bar never goes green

So basically, the Matek 3901-L0X is unusable because of the low quality of the optical flow.

To me paying 30€ for this sensor is a scam, it’s good for nothing really.

The weird thing is that I have seen people on Youtube that is using this exact same sensor with success.

1 Like

Have you tried it on your drone? You had earlier had it set to the default 20cm.

AI is pretty useless in these cases.

I use an MTF-02 which seems to have the same 3901 optical flow sensor and it works pretty well for me

2 Likes

Yes, I tried 1cm, because it says it’s 3cm from the ground measured. It shouldn’t really matter when I switch from ALT_HOLD to POS_HOLD approx. 1 meter from the ground, it still says the same, no posistion estimate.

Can you try arming in loiter?

1 Like

The EK3_SRC1_POSZ,2 should have confirm rangefinder hold height is working.
Do you have another piece of Matek 3901-L0X to confirm where is the issue?

Have you double-checked the orientation mounting? The small arrow near the camera lens should be pointing forwards. Mateksys seems to recommends minimum F7 MCU.

My colleague is unable to confirm the issue he faced and why he switch from speedybeeV4 to MicoAir743v2. he was able to fly indoors with Microair MTF-01 Optical flow & 8m Range 2IN1 Sensor. H7 MCU, SD card slot, more external expansion ports, and overall price are the attractive points he made the switch.

I used MTF-02 on a 2.4.8

I don’t know whether it makes relevant or not, change the mode to loiter and lift the drone manually for about 1 m and try to arm. Set the EKF home location manually from MP. I had the same issue and I did it and it started to take off in opt flow mode.

Hi, I tried your suggestion, didn’t work unfortunately, the flow quality (opt_qua) never gets above 50 it’s always around 40-45 even on 1m height. I think this is the problem, according to ChatGPT it should be >100 before EKF would try to use it.

As I don’t have another reference I can’t tell for sure, could you please tell me your flow quality on average?

Is this ever above 100?

Thanks!

1 Like

where did you place your optical flow sensor? Is it center of the drone gravity? or was it offset from the drone CG? Usually I am unable to mount directly CG of the drone. I have to input the position offset (FLOW_POS_n) and calibrate the FLOW_FnSCALER. I am also curious how does Mateksys recommends -800 scaler for both directions.

Average value I was getting is 127

Hi @Ojwhaaa_Ojwhaaa,

We normally don’t recommend setting RK3_SRC1_POSZ = 2 (Rangefinder). It’s not necessary for the EKF to use rangefinder for altitude in order for it to use the rangefinder for the optical flow based horizontal velocity estimate.

I think providing an updated onboard log would be a good idea.

@Siva_Sudhamsu_Gunti’s suggesting of picking up the vehicle is almost certainly related to the rangefinder being out-of-range which can be resolved by changing RNGFND1_MAX_CM.

1 Like

Hello,

Thanks for the reaction, I have already set the EK3_SRC1_POSZ to 1 and the result is the same.

When I check Mavexplorer, I actually see the rangefinder performing just fine to my interpretation and following the barometer.

What Siva_Sudhamsu_Gunti is showing in his log is significant different than what I see, his average value is 127, way above 100, my value never gets above 50. If this is a value between 1 and 255, than it’s pretty bad I guess.

Can you confirm the minimum value of the opt_qua should be, should this be above 100 for the EKF to start considering using this?

I also see this in the log:

Test: OpticalFlow = FAIL - FAIL: insufficient roll data pointsa

To me all data is pointing towards a crappy optical flow sensor. I have another exact same sensor, I will replace the one on the drone with that one this weekend.

The short log with log bitmask on 65535 is here:

Thanks for your data, extremely helpful, now I have a reference!

1 Like

OK, I changed the Matek 3901-L0X for the second one I had lying around, but the same problem once again, low optical flow quality. I took the drone outside for optimal light, but this didn’t help much, here is the log:

I want to get another sensor, anyone got a 100% working option to advise?

I didn’t have a great experience with the Matek 3901. I was never able to get it to perform as I had hoped.

I have had good luck with the MTF-01P - Optical&Range Sensor - MicoAir Tech . I followed the manufacturers website to get it set up, and then the ardu wiki for the tuning. All worked as expected.

@Ojwhaaa_Ojwhaaa,

The log shows the compass and barometer sensors are unhealthy and there’s a text output from the EKF saying “Need Alt Estimate” which is very unusual. It might be good to revert to using a GPS and see if the simpler setup can be made to work (I suspect it will not work)

I am just speculating and wondering whether it is due to the code for the STM32 F4 chipset. My colleague runs into a similar issue with another optical flow sensor, the Need for position estimation. But the warming message is gone if lifted to around 1m.

1 Like

I have seen this als, when I power of the drone and back on again the problem is gone, I suspect it could be due to the lack of processing power of the F405.

Logging is also an issue I see parts missing in the graphs, I think I order a TBS Lucid H7 FC and a MTF-01P, would that be a good recommended setup?

1 Like