Divergence of local position estimate with optical flow

I’m using EKF2 and trying to develop an autonomous indoor vehicle (GPS denied, offboard mode). I’ve noticed that the local position estimates start off at (0,0,Z) when the quadcopter is on the ground as optical flow is not available. The velocities on the other hand are random and huge which if given about 20-30 seconds settle back to < 0.1.

If at any point optical flow quality is good enough, then the estimates are pretty good. But, if once optical flow is used you lose it due to bad quality (Say for example your mission involves taking off - flying around - landing - taking off again) the estimates shoot off towards really large values until it is re obtained. But in the meantime the quad is completely out of control as the velocity and position estimates that the pixhawk bases its control on are wrong.

Is there a way to combat this as at the moment it seems like luck of the draw and hoping that it doesn’t obtain flow while on the ground (which happens sometimes and throws everything off). Is LPE better than EKF2 for this application?

@vidullan, we’ve run tests with both and LPE always gives us the best results for indoor flights, as shown here. However, you cannot just depend only on the optical flow to autonomously fly the vehicle around (i.e. indoor way-points) since as you pointed out; it’ll go out of control when the optical flow loses quality (< 200). Therefore, you need other mechanisms/sensors for it to localize and maintain the velocity and position estimates under control.

1 Like

@AI_B Thanks for the reply. The problem i’m having is as soon as optical flow is lost, the ekf estimates for velocity start growing even though the quad isn’t moving. This causes the quad to start correcting for velocities in spite of the IMU showing no such large accelerations. This only happens when we land and try to take off again as landing causes optical flow to be lost. Did you encounter a similar problem and is there a way to reset the estimates?