Optical Flow oscillating position

Hallo,
I’m currently working on a fully actuated hexarotor that’s aimed to fly in indoor environments. It’s only using optical flow (Ark Flow module) to enable position mode for the fully actuated (3d thrust) position controller. I observed that its x and y positions oscillate slowly around the setpoint while hovering. The amplitude increases with height. While at roughly 1m the drone only moves ~20cm, at a height of 3m this movement already increases to about a meter. Due to the phase offset of x and y movements the drone basically orbits around the setpoint. Because of the rather narrow indoor environments, one meter of deviation from the position is already quite a lot.

Analysing the plots, like suggested in this post, showed that the optical flow velocity tends to be higher than the fused velocity, especially when hovering at higher altitudes. These are the plots for x and y velocities for this flight log where I took off to a height of about 2,5m and hovered there for some time.


While the high optical flow velocity explains the oscillating position, I’m still struggling to find a reason for the high optical flow velocities. So far I tried to add some structure to the ground, but it didn’t help much. The EKF2_OF_POS parameters are all set, as well as the offset parameters for the LiDAR.

My system:
Fully Actauted Hexarotor, custom frame, 4’’ props
Custom firmware based on a recent release/v1.14 branch
Ark Flow optical flow module
Pixhawk 6X Flightcontroller

Some further log files of hovering tests:
https://review.px4.io/plot_app?log=283e35b0-fc7c-49cd-b772-7aa963ef47fe
https://review.px4.io/plot_app?log=c518bbf2-a64e-42e4-8fa5-7d7fa76755aa
https://review.px4.io/plot_app?log=704f3b2b-5c1a-4974-b9c8-8116812ec039

A flight log of a test with commanded movement:
https://review.px4.io/plot_app?log=767d6108-e9d6-43da-83bf-45dcfa427963

I saw the same oscillations with my setup. We already fixed part of it: drivers/optical_flow/paw3902: backup scheduling to fetch 0 flow by dagar · Pull Request #22086 · PX4/PX4-Autopilot · GitHub (requires to re-flash the ArkFlow) and I found more improvements to do (not fully ready yet): Fix flow gyro bias corrections by bresch · Pull Request #22145 · PX4/PX4-Autopilot · GitHub

I recommend building main as of today for the ARK Flow and giving it a try.

@bresch @AlexKlimaj Thanks a lot for the help. This morning I made a fresh build for ark flow and px4 from the most recent main, with only the necessary changes for 3d thrust. The flight as well as the corresponding logs looked a lot better now. The drone is able to hold a very stable position, even at higher altitudes, with maximum position deviations of around 10-20cm in each direction.

Log File: https://review.px4.io/plot_app?log=fe60b628-8997-4af9-aa67-d735ecb868c4
The large position errors during landing can be ignored.

I also had a look at the plot from the initial post again. The optical flow velocity still has spikes with higher amplitude, but amplitude and quantity decreased significantly. Could this be related to something like the quality of the ground or vibrations?

1 Like

Give this PR a try on the flight controller now.

I will give it a try once it’s merged (seems to be still open). Nevertheless, even since the previous fixes the drone holds its position very stable, especially at altitudes above 2m. So once it’s merged I will do some test flights and see if it improves even more.

Today I managed to do some flight tests again, using a more recent main including the new fix. The position during hovering is very stable. Sometimes when stopping from a horizontal movement the drone moves a bit back towards its starting position. However I think this is primarily caused by the repetitive pattern of the floor that’s underneath the drone (I try to add a picture of it later).

Flight Logs:
First Flight: https://review.px4.io/plot_app?log=1c4668f6-9ad0-4cfd-a1c0-5c0017b712fa
Second Flight: https://review.px4.io/plot_app?log=4b765fd1-19a9-4b6b-b709-e07e1e8d0d08

This is what the floor looks like:

1 Like

The PR was merged, give it a try.

I did with the flight tests from today.

I’m seeing the same behavior with the holybro pmw3901 and thoneflow driver. This isn’t just an ark flow issue @bresch ?

@SAlex24 Thanks for the flight tests!

@dirksavage88 Did you set the flow sensor position offsets correctly (EKF2_OF_POS_X/Y/Z)?

@bresch i haven’t tried setting OF position params but the sensor is very centered on the quad frame. It’s a very small <220mm frame.

I can send logs. The client I’m working with can compensate for your time if needed.

What’s the best way to get a hold of you? Email/discord/slack?

@dirksavage88 Unfortunately I’m not doing any freelancing work but I could help you if you open a new issue on the forum with a log file and some description of the setup.

@bresch thank you for your time, I’ve created a separate issue here where I swap the ark can flow (which worked well) for the thoneflow (bad oscillations) to rule out setup component issues; Holybro Optical Flow sensor (thoneflow) oscillations (on main)