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

Remove euler angles from attitude setpoint #23482

Merged
merged 3 commits into from
Aug 12, 2024
Merged

Remove euler angles from attitude setpoint #23482

merged 3 commits into from
Aug 12, 2024

Conversation

Jaeyoung-Lim
Copy link
Member

@Jaeyoung-Lim Jaeyoung-Lim commented Aug 1, 2024

Solved Problem

The VehicleAttitudeSetpoint message has two different attitude setpoint fields.
a) The desired attitude quaternion q_d

float32 roll_body # body angle in NED frame (can be NaN for FW)
float32 pitch_body # body angle in NED frame (can be NaN for FW)
float32 yaw_body # body angle in NED frame (can be NaN for FW)
float32 yaw_sp_move_rate # rad/s (commanded by user)
# For quaternion-based attitude control
float32[4] q_d # Desired quaternion for quaternion control

b) Euler angles roll_body, pitch_body, yaw_body

I think the initial intention was that to use the euler angles for logging, and the quaternions for the controllers. However, this seems to have gotten quite abused, and the fixed wing controllers especially use it as a primary place for storing setpoints.

This has the following problems

  • When both euler angles and quaternions are in the message, but the two contain different attitude information, there is no information in the message telling which one is the valid message to be used.
  • The way currently the euler angles are used make the code become quite hard to read. Especially the fixedwing position controller, since the euler angles of global variable _att_sp is modified everywhere in the code. This makes it hard to grasp where the setpoints are changing and which euler angles are actually sent to the attitude controller
  • The field names (e.g. roll_body) has nothing to do with the body frame at all.
  • When using the attitude setpoints from an external process (e.g. ROS2), it is not clear which one will be used, or how limited information can be provided. For example, the sender might invalidate all setpoints and set a roll_body. This is not a valid setpoint and therefore should simply not be allowed from the message definitions itself.

Fixes #23481

Solution

  • Remove euler angles from attitude setpoint, and compute the euler angles locally when needed

Changelog Entry

For release notes:

Feature/Bugfix Removed euler angles from attitude setpoint message.

Test coverage

  • Test plane in SITL

@Jaeyoung-Lim Jaeyoung-Lim force-pushed the pr-attitude-frames branch 3 times, most recently from 528b53b to 103e0ce Compare August 1, 2024 20:13
@Jaeyoung-Lim Jaeyoung-Lim requested review from dagar and removed request for KonradRudin August 1, 2024 20:13
@Jaeyoung-Lim Jaeyoung-Lim force-pushed the pr-attitude-frames branch 2 times, most recently from cf1e0c5 to f35d43d Compare August 1, 2024 20:29
@Jaeyoung-Lim Jaeyoung-Lim marked this pull request as draft August 1, 2024 20:32
@Jaeyoung-Lim Jaeyoung-Lim marked this pull request as ready for review August 1, 2024 20:42
dagar
dagar previously approved these changes Aug 1, 2024
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.

Let's do it, this is long overdue.

@Jaeyoung-Lim
Copy link
Member Author

Jaeyoung-Lim commented Aug 2, 2024

Not sure if the CI failures are relevent. SITL tests say that the tests passed, but still fails anyway.

bresch
bresch previously approved these changes Aug 5, 2024
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

@sfuhrer
Copy link
Contributor

sfuhrer commented Aug 6, 2024

Not sure if the CI failures are relevent. SITL tests say that the tests passed, but still fails anyway.

No they're unrelated, see #23457

bresch
bresch previously approved these changes Aug 8, 2024
@Jaeyoung-Lim
Copy link
Member Author

@bresch Sorry, I had a format error during the rebase

sfuhrer
sfuhrer previously approved these changes Aug 8, 2024
Copy link
Contributor

@sfuhrer sfuhrer left a comment

Choose a reason for hiding this comment

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

This was really long overdue, thanks a lot!
I just love my consts too much - would you mind going through and const everything you can? I stopped making comments after a while, there's lots of them.

@Jaeyoung-Lim Jaeyoung-Lim force-pushed the pr-attitude-frames branch 2 times, most recently from ca381e2 to 7d9dbc7 Compare August 10, 2024 13:30
@Jaeyoung-Lim
Copy link
Member Author

@sfuhrer Addressed your comments

This commit removes the usage of euler angles in the vehicle_attitude_setpoint messages
Copy link
Contributor

@sfuhrer sfuhrer left a comment

Choose a reason for hiding this comment

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

Looks all clean now, thanks!

@sfuhrer sfuhrer merged commit e008ca2 into main Aug 12, 2024
95 checks passed
@sfuhrer sfuhrer deleted the pr-attitude-frames branch August 12, 2024 14:42
bkueng added a commit to Auterion/px4-ros2-interface-lib that referenced this pull request Aug 20, 2024
bkueng added a commit to Auterion/px4-ros2-interface-lib that referenced this pull request Aug 20, 2024
vertiq-jordan pushed a commit to iq-motion-control/PX4-Autopilot that referenced this pull request Aug 21, 2024
* Remove euler angles from attitude setpoint message

* Remove usage of euler angles in attitude setpoint messages

This commit removes the usage of euler angles in the vehicle_attitude_setpoint messages

* Fix standard vtol
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.

[Bug] Mixed attitude setpoint descriptions
4 participants