Optical flow fusion through Mavlink

I am trying to build a gps denied drone using an rpi 4b companion computer that send the calculated flow value back to the flight controller through OPTICAL_FLOW_SEND. In mission planner ekf starts flow fusion and aids flight but then it stops aiding the moment there is any motion.. Why is this happening.

Also Altitude does follow sonar range at all thought i have attached a down rangefinder which reads values in mp and done all the required parameters setup (ek3_src1 _posz,). I also get this error post vert variance(i think its the reason rangfinder fusion fails).. is this the source of the problem how do i fix anything?

Any help is appreciated :sob:

A common error seen around here is setting the min range and ground clearance range incorrectly. Can you try 2cm for the minimum range and 5cm for ground clearance? As far as I know just setting minimum range < ground clearance is enough.

Grnd clearance is 20 (due to my landing gears) and min is 5cm

I tried with 5 and 2 also and have the same error. Are y supposed to use rangefinder as the posz input at all and does mavlink fuse it even if you dont?(To calculate optical flow atleast

No, use baro as posz source unless the ground is flat and completely free of stuff. That said, I don’t know the cause of your posvert error.
Yes, optical flow uses the rangefinder I guess.

Ok i am using baro as source z but i still have the issue of ekf stopping aid and restarting repeatedly