Skip to content

Commit

Permalink
Add new message type
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperTails committed Apr 5, 2024
1 parent 337e95f commit 987ccf6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions rb_ws/src/buggy/scripts/serial/host_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def update(self, b):
MSG_TYPE_STEERING = b'ST'
MSG_TYPE_BRAKE = b'BR'
MSG_TYPE_ALARM = b'AL'
MSG_TYPE_BNYATEL = b'BT'

@dataclass
class Odometry:
Expand All @@ -71,6 +72,15 @@ class Odometry:
radio_seqnum: int
gps_seqnum: int

@dataclass
class BnyaTelemetry:
x: float
y: float
velocity: float # In METERS / SECOND
steering: float # In DEGREES
heading: float # In RADIANS
heading_rate: float # In RADIANS / SECOND

class IncompletePacket(Exception):
pass

Expand Down Expand Up @@ -183,6 +193,9 @@ def read_packet(self):
debug = struct.unpack('<fff??B?BBxx', payload)
# print(debug)
return debug
elif msg_type == MSG_TYPE_BNYATEL:
x, y, vel, steering, heading, heading_rate = struct.unpack('<ffffff', payload)
return BnyaTelemetry(x, y, vel, steering, heading, heading_rate)
else:
return None
# print(f'Unknown packet type {msg_type}')
Expand Down

0 comments on commit 987ccf6

Please sign in to comment.