# Large velocity divergences with optical flow - velocity estimates and setpoints oppose each other causing crashes

**URL:** <https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110>\
**Category:** PX4 Autopilot\
**Created:** [December 12, 2025, 5:48pm UTC](https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110 "2025-12-12T17:48:03Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isaac\_Ahlgren](https://discuss.px4.io/user_avatar/discuss.px4.io/isaac_ahlgren/32/20447_2.png) [@Isaac\_Ahlgren](https://discuss.px4.io/u/Isaac_Ahlgren)\
**Post date:** [December 12, 2025, 5:48pm UTC](https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110/1 "2025-12-12T17:48:03Z")

</div>

I am experiencing what seems to be large instabilities in the velocity estimators. Velocity estimates and setpoints appear to be fighting each other. For both x and y estimates, when the vehicle estimates it’s moving significantly in one direction, the setpoints immediately get set to the opposite direction. The velocities and setpoints appear to be somewhat oscillating as shown in my plots? If they are oscillating then its oscillating larger than then the room causing crashes. Currently, the drone initially goes forward and to the left, then the setpoints bring it back to backwards and to the right. The drone does not seem to know it has reached the setpoints until it crashes into a wall.

Flight Review: [https://review.px4.io/plot\_app?log=009075a3-6b5d-44c6-a97a-f46dc67feeee](https://review.px4.io/plot_app?log=009075a3-6b5d-44c6-a97a-f46dc67feeee)

- I’m running this indoors with only optical flow sensor, no GPS.
- I’m using the Holybro H-Flow optical flow sensor
- Using offboard mode.
- For the logs, flight begins around 385 seconds and crashes around 395 seconds.

Questions:

- The current theory is that the optical flow sensor isn’t picking up enough features to accurately estimate the velocity, probably due to a smudge or a scratch on the lens. I’ve seen [other posts](https://discuss.px4.io/t/optical-flow-oscillations/36455/5) describe taking off the glass covering to the camera of the optical flow sensor as a possible solution. Is this worthwhile to do or would I just be breaking an expensive sensor?
- For the optical flow sensor, how much does the quality metric correspond to optical flow performance? What range should it be in to be considered functional?
- Is there any parameters I can set to mitigate this optical flow issue?
- What else can I look to in order to trouble shoot this?

x velocity vs setpoints:

 ![Screenshot from 2025-12-12 11-37-18](https://discuss.px4.io/uploads/default/original/3X/5/b/5b8262b40ccefe21d1b9a0aa74f42557fcbd4e4e.png)  
y velocity vs setpoints:  
 ![Screenshot from 2025-12-12 11-38-42](https://discuss.px4.io/uploads/default/original/3X/4/c/4c501137ae07bda402b19b3f77df5c5ca1203c01.png)

---

<div class="post-metadata">

**Author:** ![JulianOes](https://discuss.px4.io/user_avatar/discuss.px4.io/julianoes/32/30_2.png) [@JulianOes](https://discuss.px4.io/u/JulianOes)\
**Post date:** [December 13, 2025, 8:08pm UTC](https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110/2 "2025-12-13T20:08:11Z")

</div>

Have you verified the orientation is set correctly?

---

<div class="post-metadata">

**Author:** ![Isaac\_Ahlgren](https://discuss.px4.io/user_avatar/discuss.px4.io/isaac_ahlgren/32/20447_2.png) [@Isaac\_Ahlgren](https://discuss.px4.io/u/Isaac_Ahlgren)\
**Post date:** [December 15, 2025, 4:31am UTC](https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110/3 "2025-12-15T04:31:08Z")

</div>

I appreciate the response!

Yes. Currently, the h-flow has an arrow on the sensor indicating the direction it should be facing, it is facing the same direction as the arrow for my orange cube plus.

---

<div class="post-metadata">

**Author:** ![Isaac\_Ahlgren](https://discuss.px4.io/user_avatar/discuss.px4.io/isaac_ahlgren/32/20447_2.png) [@Isaac\_Ahlgren](https://discuss.px4.io/u/Isaac_Ahlgren)\
**Post date:** [December 15, 2025, 3:53pm UTC](https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110/4 "2025-12-15T15:53:04Z")

</div>

(picture for proof, up is forward for the controller)

 ![IMG_5327](https://discuss.px4.io/uploads/default/original/3X/c/f/cfffb7d8b37e5227a89fe1ec02ec5f7a98bcfc76.jpeg)

---

<div class="post-metadata">

**Author:** ![Isaac\_Ahlgren](https://discuss.px4.io/user_avatar/discuss.px4.io/isaac_ahlgren/32/20447_2.png) [@Isaac\_Ahlgren](https://discuss.px4.io/u/Isaac_Ahlgren)\
**Post date:** [December 15, 2025, 5:32pm UTC](https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110/5 "2025-12-15T17:32:51Z")

</div>

Looks as if the optical flow velocity is uncorrelated with estimated velocity. Also does not seem to correlate to any specific direction as well, which shouldn’t be the case.

 ![Screenshot from 2025-12-15 11-30-48](https://discuss.px4.io/uploads/default/original/3X/5/7/57ab1dfb2fa4813f23ba2390da1ba4123fa95177.png)

---

<div class="post-metadata">

**Author:** ![JulianOes](https://discuss.px4.io/user_avatar/discuss.px4.io/julianoes/32/30_2.png) [@JulianOes](https://discuss.px4.io/u/JulianOes)\
**Post date:** [December 15, 2025, 11:02pm UTC](https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110/6 "2025-12-15T23:02:01Z")

</div>

Have you done a basic hand-held test to check whether the indicated velocities are correct as you move it across some textured surface?

---

<div class="post-metadata">

**Author:** ![Isaac\_Ahlgren](https://discuss.px4.io/user_avatar/discuss.px4.io/isaac_ahlgren/32/20447_2.png) [@Isaac\_Ahlgren](https://discuss.px4.io/u/Isaac_Ahlgren)\
**Post date:** [December 16, 2025, 5:18pm UTC](https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110/7 "2025-12-16T17:18:51Z")

</div>

I think the velocities are incorrect after doing the basic hand held test.

Here is the flight logs from the walk: [https://review.px4.io/plot\_app?log=372811c4-4471-4140-b7b4-0989aca55717](https://review.px4.io/plot_app?log=372811c4-4471-4140-b7b4-0989aca55717)

It was walked in a roughly 1 m square, first right, then forward, then left, and finally downwards. It was walked at around 0.5 to 1 m/s. For the flight review, the hand held test starts around 19:30.

It seems that the positioning estimates are nonsensical (ignoring the positioning estimates generated before the hand held test as thats just stuff that was being done before the test). Which indicates that the velocities are wrong. They do not seem to be going in the wrong directions, but they are incredibly noisy and dampened, particularly the velocity derived by the optical flow.

---

<div class="post-metadata">

**Author:** ![Isaac\_Ahlgren](https://discuss.px4.io/user_avatar/discuss.px4.io/isaac_ahlgren/32/20447_2.png) [@Isaac\_Ahlgren](https://discuss.px4.io/u/Isaac_Ahlgren)\
**Post date:** [December 16, 2025, 5:55pm UTC](https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110/8 "2025-12-16T17:55:13Z")

</div>

Maybe a hint or not, but the divergence of the x and y position before the test are pretty extreme as well without any fluctuations to the velocity. It’s not even in inertial dead reckoning.

 ![Screenshot from 2025-12-16 11-53-21](https://discuss.px4.io/uploads/default/original/3X/6/9/693fcdd0364d7252bccbe46877c70e50a76e0f77.png)

---

<div class="post-metadata">

**Author:** ![Isaac\_Ahlgren](https://discuss.px4.io/user_avatar/discuss.px4.io/isaac_ahlgren/32/20447_2.png) [@Isaac\_Ahlgren](https://discuss.px4.io/u/Isaac_Ahlgren)\
**Post date:** [December 16, 2025, 7:15pm UTC](https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110/9 "2025-12-16T19:15:08Z")

</div>

We tried a hand held test with the ARK flow sensor instead and we still get poor results: [https://review.px4.io/plot\_app?log=1b86f068-c07b-49a2-8d97-1cb53b7acc0c](https://review.px4.io/plot_app?log=1b86f068-c07b-49a2-8d97-1cb53b7acc0c)

Though the gyro dominates the signal for this one (it also kinda did a little for the first as well), but this is probably due to the poor way we mounted the of sensor. Still, it performs fairly poorly which is strange for both optical flow sensors (We might be the common denominator between the two! lol)

---

<div class="post-metadata">

**Author:** ![Isaac\_Ahlgren](https://discuss.px4.io/user_avatar/discuss.px4.io/isaac_ahlgren/32/20447_2.png) [@Isaac\_Ahlgren](https://discuss.px4.io/u/Isaac_Ahlgren)\
**Post date:** [December 16, 2025, 9:12pm UTC](https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110/10 "2025-12-16T21:12:15Z")

</div>

Accidentally had something covering the optical flow sensor for the ARK flow and now the drone can hover all good! For the original optical flow sensor, my guess is that the h-flow optical flow sensor has a smudge or a scratch on the protective glass which is messing up its readings. I am going to remove that piece of glass, and see if that fixes the original problem. I will then close out this thread with a proper solution.

---

<div class="post-metadata">

**Author:** ![system](https://discuss.px4.io/uploads/default/original/3X/7/3/73ce918bdcd64854de904f0c8d9ab70ca9723f2a.png) [@system](https://discuss.px4.io/u/system)\
**Post date:** [March 16, 2026, 9:12pm UTC](https://discuss.px4.io/t/large-velocity-divergences-with-optical-flow-velocity-estimates-and-setpoints-oppose-each-other-causing-crashes/48110/11 "2026-03-16T21:12:29Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
