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

[WIP] Different Attitude Setpoint Generation Strategy #13535

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

MaEtUgR
Copy link
Member

@MaEtUgR MaEtUgR commented Nov 20, 2019

Describe problem solved by this pull request
Currently, the position controller generates a thrust vector setpoint and forwards the desired yaw heading in the world frame. The setpoint generator then calculates an attitude that aligns the body z axis with the desired thrust (basic multicopter dynamics) and incorporates the world frame yaw heading in a way that the body x axis projected onto the world x-y-plane always point to the desired world yaw heading. This seems like a viable solution depending on the use case of the yaw setpoint but I see one big disadvantage of this solution: The body yaw rate is coupled with a thrust vector

Describe your solution
I calculate the desired attitude by aligning the body z axis with the thrust vector like before but this time directly using quaternion math. See PX4/PX4-Matrix#55 for implementation details. Then yaw is applied on top with a different strategy: If the vehicle is level the yaw is the world frame heading but if the vehicle is tilted it just does the shortest roll/pitch tilting without correcting the body yaw angle to allign the body x-axis in to a world frame projection. This results in no body yaw rate corrections resulting from roll and pitch adjustments.

Note that all the 3-axis gimbals for drones I have tested do the right thing when generating the attitude the way proposed in this pr and yaw off the desired world frame heading when aplying the current PX4 conversion.

Test data / coverage
SITL tested and I adjusted the existing unit tests in the following way:

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 21, 2019

@bkueng Just mentioned an important point to me: The navigator yaw reached checks might fail if the setpoint generation strategy is different from the attitude estimate yaw euler angle interpretation because when the vehicle has a roll/pitch offset e.g. high winds the tracked yaw setpoint might be different from the yaw estimate in euler angles.

I have to find a viable setup to verify the fix for it.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 21, 2019

I just rebased on master

@MaEtUgR MaEtUgR force-pushed the attitude-generation branch 2 times, most recently from d1afaf9 to 2f54968 Compare November 21, 2019 09:43
@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 21, 2019

I found the corner case orientation problem that the new position control unit tests in master detected: https://ci.appveyor.com/project/Dronecode/firmware/builds/28990523/job/tg4c25ljktm2b4p6
And fixed it with interactive rebase in https://github.com/PX4/Firmware/compare/d1afaf906e5d47a61fda5bdc2bbb4e41c354ceaf..2f54968b7ee214f403b95ef8856037ae85cc10ae

JFYI @dagar It seems that Appveyor is running CI on a merged version of the branch seen from the console output of the run linked above:

git fetch -q origin +refs/pull/13535/merge:
git checkout -qf FETCH_HEAD

And that's why it was the only make tests instance which failed.

@MaEtUgR MaEtUgR changed the title Different Attitude Setpoint Generation Strategy [WIP] Different Attitude Setpoint Generation Strategy Nov 24, 2019
@bresch
Copy link
Member

bresch commented Feb 3, 2020

@MaEtUgR Any news on that?

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Feb 27, 2020

I rescheduled to pick this up again since it's fairly significant.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Mar 4, 2020

@dagar's good idea was to clearly distinguish between "yaw" and "heading" since the pilot cares about the "heading" when the multicopter is level (zero roll pitch equivalent of current attitude) and not any x-axis projections with the current tilt that constantly requires yaw corrections on roll pitch changes.

I quickly wrote up a test to show the difference in rate control input with the old and proposed attitude setpoint generation strategy given no yaw changes but only 45° diagonal x,y horizontal displacement: d4cbdc1#diff-b07ac130d43e318a5f9bb3f6518b91b4R48

While the attitude generation currently in use results in a commanded body yaw rate and resulting from that twist also an asymmetric roll pitch rate:

0.607
-0.982
0.375

the proposed attitude generation results in the expected symmetric roll pitch rate and no yaw corrections:

0.816
-0.816
0

I will encorporate the test in this pr but what's still missing is to verify compatibility with navigator ("yaw"/)heading reachability checks.

@MaEtUgR MaEtUgR force-pushed the attitude-generation branch from 2f54968 to 023b257 Compare March 5, 2020 09:02
bresch
bresch previously approved these changes Mar 5, 2020
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.

Nice, this will be especially good for quadplanes

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Mar 12, 2020

Input from discussion with @priseborough : There is no one yaw value that suits all applications. Either the estimator only publishes the quaternion and the receiver needs to do the conversion he wants or the estimator can do the one or two mainly used conversions but they need to be very clearly described in the interface and not misused. Current descriptions are e.g.
https://github.com/PX4/Firmware/blob/a89b69b0eadab3e24d374aba71deda3a056f446d/msg/vehicle_local_position.msg#L40
https://github.com/PX4/Firmware/blob/a89b69b0eadab3e24d374aba71deda3a056f446d/msg/vehicle_global_position.msg#L19
for the same value which should not be considered a heading in a mission sense by the navigator.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Apr 16, 2020

As an update this is still pending because the yaw/heading needs to be updated for yaw reached checks and for the yaw tracking plot otherwise the result will always be that the euler angle that is computed in a different way is not reached.

@stale stale bot added the stale label Oct 12, 2020
@bresch bresch removed the stale label Oct 14, 2020
@PX4 PX4 deleted a comment from stale bot Oct 14, 2020
@dagar dagar requested review from dagar and removed request for Stifael October 19, 2020 14:24
@LorenzMeier
Copy link
Member

Closing this as stale.

@LorenzMeier LorenzMeier deleted the attitude-generation branch January 10, 2021 17:41
@MaEtUgR MaEtUgR restored the attitude-generation branch September 10, 2021 17:18
@MaEtUgR MaEtUgR reopened this Sep 20, 2023
@MaEtUgR MaEtUgR changed the base branch from master to main September 20, 2023 16:43
with simple quaternion calculation.
Difference: The body yaw axis when projected
onto the horizontal plane is not stying in line
with the wold frame heading. This alignment
was generating additional yaw control effort
for any combined roll and pitch rotation.
@MaEtUgR MaEtUgR force-pushed the attitude-generation branch from 785b533 to 40fe570 Compare September 20, 2023 17:39
@MaEtUgR
Copy link
Member Author

MaEtUgR commented Sep 20, 2023

Revived and rebased such that we finally have this in the control interface 🟢
What's left is EKF publishing the new interpretation of heading and e.g. navigator checking for that in the heading reached check.

@MaEtUgR MaEtUgR force-pushed the attitude-generation branch from 40fe570 to 7c8dc3d Compare September 20, 2023 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Backlog
Development

Successfully merging this pull request may close these issues.

4 participants