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

AC_AttitudeControl: keep _euler_angle_target up to date with _attitude_target quaternion in attitude_controller_run_quat #26253

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

IamPete1
Copy link
Member

This ensures _euler_angle_target is updated to stay in sync with the _attitude_target quaternion in the attitude_controller_run_quat call.

This should mean its a better representation of what is actually going on, otherwise the _euler_angle_target is updated in the "input..." methods meaning its actually the target from the last loop when fetched for logging ect.

Really I think we should look to remove the _euler_angle_target completely, and pull it out of the quaternion when we need it. But that is a much bigger re-work that will also cost some extra computation each time. It will however guarantee both values are always in sync.

@IamPete1 IamPete1 requested a review from lthall February 18, 2024 12:58
Copy link
Contributor

@lthall lthall left a comment

Choose a reason for hiding this comment

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

@IamPete1 IamPete1 force-pushed the Attitude_Control_euler_target branch from 0f8d03a to 6af433f Compare February 19, 2024 20:01
@IamPete1
Copy link
Member Author

@lthall This is a more complete re-work. I'm fairly sure we now keep _euler_angle_target upto date whenever _attitude_target is changed. Either immediately or in the call to attitude_controller_run_quat.

There are a couple of places in your list where we can't remove completely as the value is used in ang_vel_to_euler_rate or euler_rate_to_ang_vel but we can move down into the no input shaping case since it is the only one to change _attitude_target.

Copy link
Contributor

@lthall lthall left a comment

Choose a reason for hiding this comment

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

Sorry it took me a while to review this. Great work.

libraries/AC_AttitudeControl/AC_AttitudeControl.cpp Outdated Show resolved Hide resolved
libraries/AC_AttitudeControl/AC_AttitudeControl.cpp Outdated Show resolved Hide resolved
libraries/AC_AttitudeControl/AC_AttitudeControl.cpp Outdated Show resolved Hide resolved
@IamPete1 IamPete1 force-pushed the Attitude_Control_euler_target branch from 6af433f to 3647ad0 Compare May 7, 2024 14:47
…e_target quaternion in attitude_controller_run_quat
@IamPete1
Copy link
Member Author

IamPete1 commented May 7, 2024

Thanks to #26266 this now a much smaller change. We just set _euler_angle_target at the end of the possible outcomes this adds the set in attitude_controller_run_quat or reset_yaw_target_and_rate, the other paths already keep it up to date correctly.

@IamPete1
Copy link
Member Author

IamPete1 commented May 7, 2024

Added a minor tidy up to use the vector method for euler to quaternion. So:

_attitude_target.from_euler(_euler_angle_target.x, _euler_angle_target.y, _euler_angle_target.z);

becomes:

_attitude_target.from_euler(_euler_angle_target);

@IamPete1 IamPete1 requested a review from lthall May 7, 2024 15:04
@IamPete1
Copy link
Member Author

IamPete1 commented May 12, 2024

I have spotted a bug in this (I removed a update that we need). I think it might be clearer to just remove the copy in one go. To make that a little easyer I have done this PR which removes a lots of uses of the euler target in heli.

#27052

@IamPete1 IamPete1 marked this pull request as draft May 12, 2024 21:44
@IamPete1
Copy link
Member Author

I have marked as draft for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants