From 7b994015f564294ba18e7d274f85aa9fc2946aa1 Mon Sep 17 00:00:00 2001 From: EinarUeland Date: Tue, 6 Apr 2021 10:34:40 +0200 Subject: [PATCH] Swap theta and phi in euler rotations --- src/alitra/frame_dataclasses.py | 10 +++++----- tests/test_align_frames.py | 4 ++-- tests/test_frame_transform.py | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/alitra/frame_dataclasses.py b/src/alitra/frame_dataclasses.py index 3158b0a..cdfc391 100644 --- a/src/alitra/frame_dataclasses.py +++ b/src/alitra/frame_dataclasses.py @@ -103,17 +103,17 @@ def from_array( @dataclass class Euler: - """Euler angles where (psi,phi,theta) is rotation about the z-,y-, and x- axis respectively. as_array and from_array - are both ordered by rotation about z,y,x. That is [psi,phi,theta]""" + """Euler angles where (psi,theta,phi) is rotation about the z-,y-, and x- axis respectively as_array and from_array + are both ordered by rotation about z,y,x. That is [psi,theta,phi]""" from_: Literal["robot", "asset"] to_: Literal["robot", "asset"] psi: float = 0 - phi: float = 0 theta: float = 0 + phi: float = 0 def as_np_array(self) -> np.ndarray: - return np.array([self.psi, self.phi, self.theta], dtype=float) + return np.array([self.psi, self.theta, self.phi], dtype=float) @staticmethod def from_array( @@ -124,7 +124,7 @@ def from_array( if rotations.shape != (3,): raise ValueError("Coordinate_list should have shape (3,)") return Euler( - psi=rotations[0], phi=rotations[1], theta=rotations[2], from_=from_, to_=to_ + psi=rotations[0], theta=rotations[1], phi=rotations[2], from_=from_, to_=to_ ) diff --git a/tests/test_align_frames.py b/tests/test_align_frames.py index fca7914..af7bbec 100644 --- a/tests/test_align_frames.py +++ b/tests/test_align_frames.py @@ -33,7 +33,7 @@ "z", ), ( - Euler(theta=np.pi * 0.9, from_="robot", to_="asset"), + Euler(phi=np.pi * 0.9, from_="robot", to_="asset"), Translation(x=1, y=10, from_="robot", to_="asset"), PointList.from_array( np.array([[10, 0, 0], [5, 2, 0], [7, 5, 0], [3, 5, 0]]), frame="robot" @@ -65,7 +65,7 @@ "z", ), ( - Euler(phi=np.pi * 0.2, from_="robot", to_="asset"), + Euler(theta=np.pi * 0.2, from_="robot", to_="asset"), Translation(x=1, y=10, z=2, from_="robot", to_="asset"), PointList.from_array( np.array([[0, 1, 2], [5, 2, 0], [7, 5, 0], [3, 5, 0]]), frame="robot" diff --git a/tests/test_frame_transform.py b/tests/test_frame_transform.py index 6dc26ee..b7e1431 100644 --- a/tests/test_frame_transform.py +++ b/tests/test_frame_transform.py @@ -61,7 +61,7 @@ ), ), ( - Euler(phi=1 * 0.2, theta=1, psi=0.4, from_="robot", to_="asset"), + Euler(theta=1 * 0.2, phi=1, psi=0.4, from_="robot", to_="asset"), Translation(x=0, y=10, z=2, from_="robot", to_="asset"), PointList.from_array( np.array( @@ -78,7 +78,6 @@ ], ) def test_transform_list_of_points(eul_rot, ref_translations, p_expected): - p_robot = PointList.from_array( np.array( [