MAVSDK Python - Drone losing position

Hey,

I’m testing MAVSDK_Python scripts in a GPS-denied environment on a drone consisting of,

Flight Controller: ModalAI_FCv2
PX4 version: v1.14.3 (Stable)
Companion Computer: RB5 Development Kit
Other sensors: ARK Flow V2

As in my earlier post drone-losing-position-crashing-in-offboard-mode, I’m testing the system now with a different flight controller.

For position estimates I rely on VIO(visual inertial odometry) from companion and Optical Flow.

I used the optical flow sensor for position hold, later I tried position hold only with external vision and position hold is very good, I can navigate seamlessly around using RC in position hold only with external vision(EV), I tried fusing both EV and OF, position hold was good, but in offboard, when I execute a script to move in a straight line, I observe a considerable amount of drift in position while executing the waypoints.

I observe that VIO is running fine, but overall my drone is drifting apart away from waypoints. With respect to Optical Flow, these are the parameters I set under EKF2,

EKF@_GND_MAX_HGT = 5.0 m
SENS_FLOW_MINHGT =0.1 m
EKF@_MIN_RNG =0.01m

For height estimation, I’m using
EKF2_HGT_Mode= Rangefinder

I have attached the logs below for reference.

How can I prevent the drone from physical drifts while passing through the waypoints, maintaining a stable position?

Any help would be much appreciated! @JulianOes @rroche

I haven’t tried this myself in a while. I will ping @dakejahl as he should have experience with ARK Flow.

When you fly using RC what’s happening under the hood is the vehicle is commanding velocity setpoints. When you let off the sticks the vehicle is then using position setpoints to hold the current position. In the first log you shared I see 3 instances of discontinuity in local position/velocity, which makes me think your VIO solution is resetting. You should also increase logging, enable vision and high rate topics in SDLOG_PROFILE