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

MC: Fix yaw jump when switching from stabilized to another mode #24297

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

bresch
Copy link
Member

@bresch bresch commented Feb 5, 2025

Solved Problem

When switching from a flight mode that is not a flight task (e.g.: stabilized). In this case, the reset counters were initialized to 0 and deltas were applied to the first setpoints if the EKF had any of its reset counters different from 0.

In the plot below, we can see a “delta_heading” of 89 degrees. Adding 89 to the current heading of 70 gives the setpoint of 159 degrees.
Screenshot from 2025-02-05 11-55-27

Solution

Initialize the reset counters when starting the task instead of passing the ones of the previous task.
Screenshot from 2025-02-05 12-12-34

Test coverage

SITL tests

This fixes a race condition when switching from a flight mode that is
not a flight task (e.g.: stabilized). In this case, the reset counters
were initialized to 0 and deltas were applied to the first setpoints if
the EKF had any of its reset counters different from 0.
@bresch bresch requested a review from dagar February 5, 2025 11:24
@bresch bresch self-assigned this Feb 5, 2025
@bresch bresch changed the title FlightTask: properly initialize EKF reset counters MC: Fix yaw jump when switching from stabilized to another mode Feb 5, 2025
Copy link
Member

@dagar dagar left a comment

Choose a reason for hiding this comment

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

The change looks fine, I just wish the dependency on updated vehicle_local_position was a little more clear.

@dagar
Copy link
Member

dagar commented Feb 5, 2025

I think this would be a lot clearer if all combined with the vehicle_local_position update here.

We could perform both initEkfResetCounters() (if uninitialized) and _checkEkfResetCounters()

@dagar dagar merged commit 8d296a5 into main Feb 5, 2025
61 checks passed
@dagar dagar deleted the pr-flight-task-ekf-reset-init branch February 5, 2025 18:21
Copy link
Member

@MaEtUgR MaEtUgR left a comment

Choose a reason for hiding this comment

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

Aaah 🤦‍♂️ If you didn't have a previous flight task the reset counters would get initialized with zero and then the "next" flight task would assume there was a change compared to the non-existing previous one. Did we really overlook that pretty basic case in review here:
#14692

You're basically reverting ca96289

Are we sure the originally solved problem doesn't come back with this change?
Why did we not find this issue earlier? It should be obvious on any switch from e.g. Manual to Position mode 🤔
I'm just trying to avoid any other side effects. Thanks for looking into the problem!

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.

3 participants