Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flow gyro bias corrections #22145

Merged
merged 6 commits into from
Oct 5, 2023
Merged

Fix flow gyro bias corrections #22145

merged 6 commits into from
Oct 5, 2023

Conversation

bresch
Copy link
Member

@bresch bresch commented Sep 27, 2023

Solved Problem

Position oscillations with ArkFlow

Solution

  • fix sign in flow gyro bias estimation
  • avoid possibility to remove gyro bias multiple times
  • add Z gyro in flow gyro data to compensate for apparent flow while doing yaw rotations (when the sensor has an X or Y offset)

Changelog Entry

For release notes:

Improve estimation performance when using ArkFlow

@DronecodeBot
Copy link

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/optical-flow-oscillating-position/34470/2

bresch added 3 commits September 28, 2023 16:32
Prevents from applying bias corrections several times if the sample
isn't immediately used.
@bresch bresch force-pushed the pr-flow-fix-gyro-compensation branch from 42df747 to d002826 Compare September 28, 2023 14:35
@bresch bresch marked this pull request as ready for review September 28, 2023 14:35
@bresch bresch changed the base branch from pr-ekf2_optical_flow_log_gyro_bias to main September 28, 2023 14:36
@bresch bresch requested a review from dagar September 28, 2023 14:38
@@ -79,7 +79,7 @@ void UavcanFlowBridge::flow_sub_cb(const uavcan::ReceivedDataStructure<com::hex:
if (PX4_ISFINITE(msg.rate_gyro_integral[0]) && PX4_ISFINITE(msg.rate_gyro_integral[1])) {
flow.delta_angle[0] = msg.rate_gyro_integral[0];
flow.delta_angle[1] = msg.rate_gyro_integral[1];
flow.delta_angle[2] = 0.f;
flow.delta_angle[2] = NAN;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, with this it's still going to replace the entire gyro as it passes through sensors/vehicle_optical_flow.

if (sensor_optical_flow.distance_available && PX4_ISFINITE(sensor_optical_flow.distance_m)) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Should we rather do the gyro Z stitching in VehicleOpticalFlow directly and remove it from EKF2?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what's best overall, but at the moment one reason not to do it in sensors/vehicle_optical_flow is because we're not currently accounting for any optical flow delay there.

@AlexKlimaj
Copy link
Member

AlexKlimaj commented Sep 28, 2023

Flight review is down. But here are two logs. One with GPS and one without. Overall pretty good. Did something a bit funny on the optical flow only flight when I was reversing straight back it veered off course aggressively.

2023-09-28.zip

https://review.px4.io/plot_app?log=6c83b40c-a680-475b-b26b-b2ac2f9fcab6
https://review.px4.io/plot_app?log=9b8e814e-9c89-45b9-8b99-31e27d596886

@DronecodeBot
Copy link

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/optical-flow-oscillating-position/34470/5

Add the autopilot's Z gyro when this is the case
@bresch bresch force-pushed the pr-flow-fix-gyro-compensation branch from d002826 to bf0b369 Compare October 5, 2023 12:07
@bresch
Copy link
Member Author

bresch commented Oct 5, 2023

Bench test showing how the Z angular rate is added to the flow gyro data (in center plot, the Z gyro is NAN)
Screenshot from 2023-10-05 14-04-51

@bresch bresch requested a review from dagar October 5, 2023 12:11
@dagar dagar merged commit d617434 into main Oct 5, 2023
86 of 87 checks passed
@dagar dagar deleted the pr-flow-fix-gyro-compensation branch October 5, 2023 14:51
@DronecodeBot
Copy link

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/holybro-optical-flow-sensor-thoneflow-oscillations-on-main/34768/1

timzarhansen pushed a commit to timzarhansen/PX4-Autopilot that referenced this pull request Sep 3, 2024
* ekf2-flow: fix flow gyro bias compensation
* ekf2-flow: apply flow gyro bias when used
* ekf2: log optical flow gyro bias
* ekf2: optical flow control always use provided flow gyro (with bias applied)
* ekf2-flow: log flow gyro and gyro reference
* ekf2-flow: support senrors with XY flow gyro

---------

Co-authored-by: Daniel Agar <daniel@agar.ca>
Co-authored-by: bresch <[brescianimathieu@gmail.com](mailto:brescianimathieu@gmail.com)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants