Skip to content

Commit 9a1cf19

Browse files
committed
feat: get_pose
1 parent 72cd9c0 commit 9a1cf19

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arduino_alvik.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ def __init__(self):
4242
self.roll = None
4343
self.pitch = None
4444
self.yaw = None
45+
self.x = None
46+
self.y = None
47+
self.theta = None
4548
self.ax = None
4649
self.ay = None
4750
self.az = None
@@ -227,6 +230,13 @@ def reset_pose(self, x: float, y: float, theta: float):
227230
self.packeter.packetC3F(ord('Z'), x, y, theta)
228231
uart.write(self.packeter.msg[0:self.packeter.msg_size])
229232

233+
def get_pose(self) -> (float, float, float):
234+
"""
235+
Returns the current pose of the robot
236+
:return: x, y, theta
237+
"""
238+
return self.x, self.y, self.theta
239+
230240
def set_servo_positions(self, a_position: int, b_position: int):
231241
"""
232242
Sets A/B servomotor angle
@@ -355,6 +365,9 @@ def _parse_message(self) -> int:
355365
elif code == ord('x'):
356366
# robot ack
357367
_, self.last_ack = self.packeter.unpacketC1B()
368+
elif code == ord('z'):
369+
# robot ack
370+
_, self.x, self.y, self.theta = self.packeter.unpacketC3F()
358371
elif code == 0x7E:
359372
# firmware version
360373
_, *self.version = self.packeter.unpacketC3B()

0 commit comments

Comments
 (0)