Fix gyroscopic precession sign: roll term (row 0) had the wrong sign#86
Open
Zaffer wants to merge 3 commits into
Open
Fix gyroscopic precession sign: roll term (row 0) had the wrong sign#86Zaffer wants to merge 3 commits into
Zaffer wants to merge 3 commits into
Conversation
The propeller gyroscopic torque had the wrong sign on the ROLL axis (row 0 of torque_inertia), in both dynamics (numeric) and symbolic_dynamics. The gyroscopic torque is -ω × h with net rotor angular momentum h = h_z·ẑ, giving (-q·h_z, +p·h_z, 0): the roll and pitch rows must have OPPOSITE signs. The subtlety is that S = Σ mixing_matrix[-1]·ω_rotor uses the yaw-torque-direction row, i.e. the NEGATIVE of the physical spin, so h_z = -prop_inertia·S. Hence: roll (x) = -q·h_z = +prop_inertia·ang_vel[1]·S (code had a leading '-', the bug) pitch (y) = +p·h_z = -prop_inertia·ang_vel[0]·S (code was already correct) The z (spin-up/down reaction) row is already correct, and is in fact what pins the convention: it is consistent only with spin = -mixing_matrix[-1]. Verified against -ω × h to machine precision on all axes; numeric == symbolic still holds for ang_vel_dot. Only matters for non-negligible prop_inertia / larger quads during yaw-type maneuvers; negligible for a Crazyflie. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
73c96a6 to
42669d9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The propeller gyroscopic torque had the wrong sign on the roll axis (row 0 of
torque_inertia), in bothdynamics(numeric) andsymbolic_dynamicsincrazyflow/dynamics/first_principles/dynamics.py.The gyroscopic torque is
-ω × hwith net rotor angular momentumh = h_z·ẑ, which gives(-q·h_z, +p·h_z, 0)— the roll and pitch rows must have opposite signs (it is a cross product). The code had them with the same leading sign (-q·S,-p·S), so exactly one row is wrong.The subtlety is which row.
S = Σ mixing_matrix[-1]·ω_rotoruses the yaw-torque-direction row, which is the negative of the physical spin direction (the same row that correctly signs the drag reaction and the z spin-up/down term). Soh_z = -prop_inertia·S, and substituting:The z (reaction) row is already correct, and is what pins the convention: it is consistent only with
spin = -mixing_matrix[-1]. So the fix is to flip the sign of the roll row, leaving the pitch row unchanged.Verified numerically against
-ω × hto machine precision on all axes;numeric == symbolicstill holds forang_vel_dot. Only matters for non-negligibleprop_inertia/ larger quads during yaw-type maneuvers; negligible for a Crazyflie.