Skip to content

Commit

Permalink
imu roll pitch yaw 이름을 x,y,z로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
boobooboo2 committed Dec 18, 2024
1 parent 1342444 commit 4e8d895
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 52 deletions.
6 changes: 3 additions & 3 deletions examples/basic_usage_examples/imu_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
imu = bundle.imus[0]

while True:
print(f"Pitch: {imu.pitch:<10}"
f"Roll: {imu.roll:<10}"
f"Yaw: {imu.yaw:<10}"
print(f"Angle_y: {imu.angle_y:<10}"
f"Angle_x: {imu.angle_x:<10}"
f"Angle_z: {imu.angle_z:<10}"
f"Vel x: {imu.angular_vel_x:<10}"
f"Vel y: {imu.angular_vel_y:<10}"
f"Vel z: {imu.angular_vel_z:<10}"
Expand Down
4 changes: 2 additions & 2 deletions examples/creation_examples/brush.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def setup(self):

def update(self):
h, w = self.height // 2, self.width // 2
self.cursor.y = h - h * sin(radians(-self.imu.roll))
self.cursor.x = w - w * sin(radians(-self.imu.pitch))
self.cursor.y = h - h * sin(radians(-self.imu.angle_x))
self.cursor.x = w - w * sin(radians(-self.imu.angle_y))
if self.button.pressed:
self.add_object(Brush((self.cursor.x, self.cursor.y), "x"))

Expand Down
6 changes: 3 additions & 3 deletions examples/creation_examples/dodge.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def setup(self):
self.fire.x, self.fire.y = 25, 20

def update(self):
pitch = -self.imu.pitch
if pitch < -5 and self.player.x < 48:
angle_y = -self.imu.angle_y
if angle_y < -5 and self.player.x < 48:
self.player.x += 30 * self.delta_time
elif pitch > 5 and self.player.x > 0:
elif angle_y > 5 and self.player.x > 0:
self.player.x -= 30 * self.delta_time
self.fire.y -= 15 * self.delta_time
if self.fire.y < 0:
Expand Down
26 changes: 13 additions & 13 deletions modi_plus/module/input_module/imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class Imu(InputModule):
PROPERTY_OFFSET_VIBRATION = 0

@property
def roll(self) -> float:
"""Returns the roll angle of the imu
def angle_x(self) -> float:
"""Returns the angle_x angle of the imu
:return: The imu's roll angle.
:return: The imu's angle_x angle.
:rtype: float
"""

Expand All @@ -37,10 +37,10 @@ def roll(self) -> float:
return data

@property
def pitch(self) -> float:
"""Returns the pitch angle of the imu
def angle_y(self) -> float:
"""Returns the angle_y angle of the imu
:return: The imu's pitch angle.
:return: The imu's angle_y angle.
:rtype: float
"""

Expand All @@ -50,10 +50,10 @@ def pitch(self) -> float:
return data

@property
def yaw(self) -> float:
"""Returns the yaw angle of the imu
def angle_z(self) -> float:
"""Returns the angle_zle_z angle of the imu
:return: The imu's yaw angle.
:return: The imu's angle_z angle.
:rtype: float
"""

Expand All @@ -64,17 +64,17 @@ def yaw(self) -> float:

@property
def angle(self) -> Tuple[float, float, float]:
"""Returns the roll, pitch and yaw angle of the imu
"""Returns the angle_x, angle_y and angle_z angle of the imu
:return: The imu's angles of roll, pitch and yaw.
:return: The imu's angles of angle_x, angle_y and angle_z.
:rtype: tuple
"""

return self.roll, self.pitch, self.yaw
return self.angle_x, self.angle_y_y, self.angle_z

@property
def angular_vel_x(self) -> float:
"""Returns the roll angle of the imu
"""Returns the angle_x angle of the imu
:return: The imu's angular velocity the about x-axis.
:rtype: float
Expand Down
18 changes: 9 additions & 9 deletions modi_plus/module/setup_module/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ def time_up(self) -> bool:

@property
@check_connection
def imu_roll(self) -> int:
"""Returns the roll angle of the MODI Play imu
def imu_angle_x(self) -> int:
"""Returns the angle_x angle of the MODI Play imu
:return: Roll angle.
:return: Angle_x angle.
:rtype: int
"""

Expand All @@ -261,10 +261,10 @@ def imu_roll(self) -> int:

@property
@check_connection
def imu_pitch(self) -> int:
"""Returns the pitch angle of the MODI Play imu
def imu_angle_y(self) -> int:
"""Returns the angle_y angle of the MODI Play imu
:return: Pitch angle.
:return: Angle_y angle.
:rtype: int
"""

Expand All @@ -277,10 +277,10 @@ def imu_pitch(self) -> int:

@property
@check_connection
def imu_yaw(self) -> int:
"""Returns the yaw angle of the MODI Play imu
def imu_angle_zle_z(self) -> int:
"""Returns the angle_z angle of the MODI Play imu
:return: Yaw angle.
:return: Angle_z angle.
:rtype: int
"""

Expand Down
6 changes: 3 additions & 3 deletions modi_plus/util/usage_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ def run_imu_manual(self):
imu = bundle.imus[0]
while True:
print(f"Gyro ({imu.id}) roll: {imu.roll}")
print(f"Gyro ({imu.id}) pitch: {imu.pitch}")
print(f"Gyro ({imu.id}) yaw: {imu.yaw}")
print(f"Gyro ({imu.id}) angle_x: {imu.angle_x}")
print(f"Gyro ({imu.id}) angle_y: {imu.angle_y}")
print(f"Gyro ({imu.id}) angle_z: {imu.angle_z}")
print(f"Gyro ({imu.id}) angular_vel_x: {imu.angular_vel_x}")
print(f"Gyro ({imu.id}) angular_vel_y: {imu.angular_vel_y}")
print(f"Gyro ({imu.id}) angular_vel_z: {imu.angular_vel_z}")
Expand Down
20 changes: 10 additions & 10 deletions tests/module/input_module/test_imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@ def tearDown(self):

del self.imu

def test_get_roll(self):
"""Test get_roll method."""
def test_get_angle_x(self):
"""Test get_angle_x method."""

_ = self.imu.roll
_ = self.imu.angle_x
self.assertEqual(
self.connection.send_list[0],
parse_get_property_message(-1, Imu.PROPERTY_ANGLE_STATE, self.imu.prop_samp_freq)
)
self.assertEqual(_, 0.0)

def test_get_pitch(self):
"""Test get_pitch method."""
def test_get_angle_y(self):
"""Test get_angle_y method."""

_ = self.imu.pitch
_ = self.imu.angle_y
self.assertEqual(
self.connection.send_list[0],
parse_get_property_message(-1, Imu.PROPERTY_ANGLE_STATE, self.imu.prop_samp_freq)
)
self.assertEqual(_, 0.0)

def test_get_yaw(self):
"""Test get_yaw method."""
def test_get_angle_z(self):
"""Test get_angle_z method."""

_ = self.imu.yaw
_ = self.imu.angle_z
self.assertEqual(
self.connection.send_list[0],
parse_get_property_message(-1, Imu.PROPERTY_ANGLE_STATE, self.imu.prop_samp_freq)
Expand Down Expand Up @@ -121,7 +121,7 @@ def test_get_vibration(self):
self.assertEqual(_, 0.0)

def test_get_angle(self):
"""Test get_yaw method."""
"""Test get_angle_z method."""

_ = self.imu.angle
self.assertEqual(
Expand Down
18 changes: 9 additions & 9 deletions tests/module/setup_module/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,30 +110,30 @@ def test_time_up(self):
)
self.assertEqual(_, False)

def test_imu_roll(self):
"""Test imu_roll method."""
def test_imu_angle_x(self):
"""Test imu_angle_x method."""

_ = self.network.imu_roll
_ = self.network.imu_angle_x
self.assertEqual(
self.connection.send_list[0],
parse_get_property_message(-1, Network.PROPERTY_NETWORK_IMU, self.network.prop_samp_freq)
)
self.assertEqual(_, 0)

def test_imu_pitch(self):
"""Test imu_pitch method."""
def test_imu_angle_y(self):
"""Test imu_angle_y method."""

_ = self.network.imu_pitch
_ = self.network.imu_angle_y
self.assertEqual(
self.connection.send_list[0],
parse_get_property_message(-1, Network.PROPERTY_NETWORK_IMU, self.network.prop_samp_freq)
)
self.assertEqual(_, 0)

def test_imu_yaw(self):
"""Test imu_yaw method."""
def test_imu_angle_z(self):
"""Test imu_angle_z method."""

_ = self.network.imu_yaw
_ = self.network.imu_angle_z
self.assertEqual(
self.connection.send_list[0],
parse_get_property_message(-1, Network.PROPERTY_NETWORK_IMU, self.network.prop_samp_freq)
Expand Down

0 comments on commit 4e8d895

Please sign in to comment.