Jetson Serial Communication - Autonomous-Motorsports-Purdue/Electrical_Documentation GitHub Wiki

Overview

The MCU and Jetson are connected via a USB serial connection which is used to send packets of data back and forth between the two devices. The Jetson is responsible for calculating the values to be sent to the motor, steering, brake, etc. This control data is contained in this packet and each byte of the packet is a specific instruction to the MCU. The structure of the packet is laid out below.

Packet Structure

Packet Structure Binary Hex Decimal
Start byte 00000010 02 2
Kart mode 11110000, 11110001, 11110010 f0, f1, f2 241,242,243
Data length 11100011 e3 227
Brake control 00000000-11111111 00-ff 0-255
Throttle control 00000000-11111111 00-ff 0-255
Steering control 00000000-11111111 00-ff 0-255
CRC 00000000-11111111 00-ff 0-255
Stop byte 00000011 03 3

Control Details

The start byte will always be 2

The kart mode enumerates from f0 - f2 which sets the kart to enable, drive and kill states respectively.

The data length packet can be e1, e2, or e3 which will determine how much data is being sent to the kart.

  • e1, only throttle control
  • e2, throttle and steering
  • e3, brake, throttle, and steering

Brake, throttle, and steering control all vary between 0 and 255 for full-on and full-off values. (for steering 0 is left and 255 is right)

The cyclical redundancy check (CRC) is a sum of all of the previous bytes that have been sent, if the number overflows wrap around 255 (sum = (sum + byte) % 255)

The Stop byte will always be 3

Example Packets

Packet Structure Binary Hex Decimal
Start byte 00000010 02 2
Kart mode (control) 11110001 f1 242
Data length (3) 11100011 e3 227
Brake control (set 0) 00000000 00 0
Throttle control (set 0) 00000000 00 0
Steering control (set center) 01111111 7f 127
CRC 01010101 55 85
Stop byte 00000011 03 3
Packet Structure Binary Hex Decimal
Start byte 00000010 02 2
Kart mode (control) 11110001 f1 242
Data length (2) 11100010 e2 226
Throttle control (set max) 11111111 ff 255
Steering control (set right) 11111111 ff 255
CRC 11010011 d3 211
Stop byte 00000011 03 3