Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Commit 46076a3

Browse files
committed
add orientation data type to markers
1 parent 5eb36c0 commit 46076a3

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

robot/markers.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,45 @@ def rot_y_degrees(self) -> Degrees:
4646
return Degrees(math.degrees(self.rot_y_radians))
4747

4848

49+
_Orientation = NamedTuple('Orientation', (
50+
('rot_x_radians', Radians),
51+
('rot_y_radians', Radians),
52+
('rot_z_radians', Radians),
53+
))
54+
55+
56+
class Orientation(_Orientation):
57+
"""
58+
Represents the orientation in 3d space as rotations around x, y, and z axes.
59+
60+
Rotations around the different axes can be thought of as follows:
61+
- X rotation represents pitch. Positive rotation
62+
around the X axis represents a rotation with the nearest point going downwards,
63+
and furthest going upwards. (i.e. a bowing motion is a positive x rotation)
64+
- Y rotation represents yaw. Positive rotation around the Y axis represents
65+
a rotation with the nearest point going to the left, and the furthest going to the
66+
right.
67+
- Z rotation represents roll. Positive rotation around the Z axis represents
68+
a rotation with the highest point going to the right, and the bottom going to the
69+
left.
70+
"""
71+
72+
@property
73+
def rot_x_degrees(self) -> Degrees:
74+
"""Rotation about the x-axis in degrees."""
75+
return Degrees(math.degrees(self.rot_x_radians))
76+
77+
@property
78+
def rot_y_degrees(self) -> Degrees:
79+
"""Rotation about the y-axis in degrees."""
80+
return Degrees(math.degrees(self.rot_y_radians))
81+
82+
@property
83+
def rot_z_degrees(self) -> Degrees:
84+
"""Rotation about the z-axis in degrees."""
85+
return Degrees(math.degrees(self.rot_z_radians))
86+
87+
4988
class PolarCoord:
5089
"""
5190
Deprecated: represents a point expressed in legacy "polar" co-ordinates.

0 commit comments

Comments
 (0)