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

PositionSmoothing: fix corner altitude bug #22331

Merged
merged 1 commit into from
Nov 10, 2023
Merged

Conversation

MaEtUgR
Copy link
Member

@MaEtUgR MaEtUgR commented Nov 7, 2023

Solved Problem

We got multiple reports that the altitude profile between two waypoints is not a diagonal line but changes altitude much quicker when leaving the previous waypoint and getting much flatter after that.

During a round corner the L1 distance calculation
was only done in 2D and the z-axis coordinate
was directly coming from the next waypoint.
This lead to an unpredictable altitude profile
between two waypoints. Sometimes almost all
altitude difference was already covered during
the turn instead of going diagonally.

Fixes #{Github issue ID}

Solution

  • Make the entire L1 distance and intersection calculation 3D
  • Refactor ...

Changelog Entry

Bugfix: Multicopter altitude change sometimes not linear between two waypoints

Test coverage

Simulation testing procedure:

  1. Command to test: PX4_SIM_SPEED_FACTOR=100 make px4_sitl jmavsim
  2. Load plan file for jMAVsim location through QGC: rounded_altitude_change.plan

I still need to verify the 2D only case with no valid altitude works as expected.

Context

Before: https://logs.px4.io/3d?log=45c8f43e-32e7-4c7f-ab30-975e1c8aa32b
image
After: https://logs.px4.io/3d?log=17dd1c3e-bd5e-46b0-abad-3bba6c517e2f
image

During a round corner the L1 distance calculation
was only done in 2D and the z-axis coordinate
was directly coming from the next waypoint.
This lead to an unpredictable altitude profile
between two waypoints. Sometimes almost all
altitude difference was already covered during
the turn instead of going diagonally.
@MaEtUgR MaEtUgR requested a review from bresch November 7, 2023 16:02
@MaEtUgR MaEtUgR self-assigned this Nov 7, 2023
@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 8, 2023

This fix was just real-world tested and worked like expected.
image

@tstastny
Copy link

tstastny commented Nov 8, 2023

@bresch ready for final pass :)

@saengphet
Copy link

Hi @MaEtUgR This bug occurs only in main, v1.14, or also occurs in v1.13.3 too? thank you.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 8, 2023

occurs only in main, v1.14, or also occurs in v1.13.3 too? thank you.

@saengphet I actually just minutes ago tried to find this out but it's not so clear to me yet. The part I changed does the same thing since rounded turns were introduced but possibly it was not a problem before other changes. I'd need to dig more. 1.14 is for sure the same and I'll backport my fix once it's merged.

Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

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

Cool, that's a pretty straightforward fix: 2D -> 3D

Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

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

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 9, 2023

had a fly-away

Is it reproducible? Can you share the plan file that produces it?

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 9, 2023

Same plan works fine for me. On to debugging 👀
https://logs.px4.io/plot_app?log=e1242eb4-e62c-412f-9fb0-0da1cc9ea859

Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

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

I was able to repeat the issue on main, so it's unrelated to this PR

@tstastny
Copy link

tstastny commented Nov 9, 2023

I was able to repeat the issue on main, so it's unrelated to this PR

oof - alrighty - can you make an issue so we track this newfound bug @bresch ?

@bresch
Copy link
Member

bresch commented Nov 9, 2023

Just for completeness, the "flyaway" i had in simulation was due to a landing approach that I did set for a VTOL plane simulation earlier.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 10, 2023

I checked the 2D case which is the one where the altitude is not valid:


Following findings: I don't see how it can ever be the path taken if not by my test code because QGC requires every waypoint to have an altitude, navigator puts altitudes to the waypoints and the flight task puts at least the current altitude to every waypoint. In case there was a valid code path my change would do the same calculation as before iff the z coordinate is really the same altitude for the current position and waypoint. I expect this case to get obsolete in the next refactor.

@MaEtUgR MaEtUgR merged commit 4485c7a into main Nov 10, 2023
86 of 88 checks passed
@MaEtUgR MaEtUgR deleted the maetugr/fix-corner-altitude branch November 10, 2023 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants