Repository navigation
Fix cs_quat2euler degrees and duplicate CasADi function names - #152
Open
malikdurmus wants to merge 1 commit into
Open
malikdurmus wants to merge 1 commit into
malikdurmus wants to merge 1 commit into
Conversation
- Convert radians to degrees in cs_quat2euler(degrees=True) instead of the inverse - Give the CasADi derivative conversion functions unique names
amacati
requested changes
Nov 3, 2026
Comment on lines
+262
to
+269
| fns = [ | ||
| rotation.cs_ang_vel2rpy_rates, | ||
| rotation.cs_rpy_rates2ang_vel, | ||
| rotation.cs_ang_vel_deriv2rpy_rates_deriv, | ||
| rotation.cs_rpy_rates_deriv2ang_vel_deriv, | ||
| rotation.cs_quat2matrix_func, | ||
| rotation.cs_rpy2matrix_func, | ||
| ] |
Collaborator
There was a problem hiding this comment.
Can we collect these automatically instead?
| @pytest.mark.parametrize("seq", ["xyz", "zyx", "zxz", "XYZ", "ZYX", "ZXZ"]) | ||
| @pytest.mark.parametrize("degrees", [False, True]) | ||
| def test_quat2euler_symbolic(seq: str, degrees: bool): | ||
| rot = R.random(100) |
Collaborator
There was a problem hiding this comment.
This probably never reaches gimbal locks (which have some switching logic), so it would be great to add these as well. E.g.
lock = [0.0, np.pi] if seq[0] == seq[2] else [np.pi / 2, -np.pi / 2]
rot = R.from_euler(seq, [[0.3, angle, 0.4] for angle in lock])
with pytest.warns(UserWarning, match="Gimbal lock"):
reference = rot.as_euler(seq, degrees=degrees)
for q, euler_scipy in zip(rot.as_quat(), reference):
euler_cs = np.array(quat2euler(q)).flatten()
assert np.allclose(euler_cs, euler_scipy, atol=tol), "Symbolic quat->euler differs at lock."This branch has not been deployed
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.
Split from #151.
cs_quat2euler(degrees=True)converts the wrong wayThe degrees branch multiplied by
pi / 180instead of180 / pi(This is a silent error!). The test i added compares against scipy'sas_eulerfor extrinsic, intrinsic and symmetric sequences, in both radians and degrees.Duplicate CasADi function names in
rotation.pycs_ang_vel_deriv2rpy_rates_derivandcs_rpy_rates_deriv2ang_vel_derivwere both created with the name"cs_ang_vel2rpy_rates". I think this doesn't affect simulation results, but it gives misleading names in printouts and error messages.