Skip to content

Commit

Permalink
Swap theta and phi in euler rotations
Browse files Browse the repository at this point in the history
  • Loading branch information
EinarUeland authored and EinarUeland committed Apr 6, 2021
1 parent 6a15788 commit 7b99401
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/alitra/frame_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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_
)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_align_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions tests/test_frame_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -78,7 +78,6 @@
],
)
def test_transform_list_of_points(eul_rot, ref_translations, p_expected):

p_robot = PointList.from_array(
np.array(
[
Expand Down

0 comments on commit 7b99401

Please sign in to comment.