Перейти до основного вмісту

Shassis Controller Communication Protocol

1. Overview

This protocol is designed for communication between a ROS2 system running on platforms such as RPI and a chassis controller operating on hardware like BeagleBone Blue or STM32. It supports both TCP and UART, allowing for a seamless future transition between the two communication methods.

2. Protocol Architecture

The protocol consists of two layers:

  1. Frame Layer (Layer 1) – Ensures data integrity, required only for UART.
  2. Protocol Layer (Layer 2) – Defines the core communication commands.

2.1. Frame Layer (Layer 1) – UART Only

(Not used in TCP mode)
The frame layer is only applicable when using UART, as UART does not guarantee message integrity or completeness.

Frame Format (UART Only)

OffsetSize (bytes)FieldDescription
01frame_lengthTotal packet length (including CRC16). Ensures packet boundary detection over UART
1NpayloadProtocol Layer (Layer 2) data
N+12crc16CRC16 checksum. Provides error detection for unreliable UART communication

2.2 Protocol Layer (Layer 2) – Used in TCP & UART

This is the core protocol used in both TCP and UART modes.

Protocol Format

OffsetSize (bytes)FieldDescription
01command_idUnique command identifier
1NpayloadCommand-specific data

3. Command Set

Command IDCommand NameDescription
0x01get_api_versionRetrieves the API version of the system
0x02set_motor_speedSets the speed of a motor
0x03set_all_motors_speedSets the speed for all four motors in a single command
0x04get_encoderRetrieves the encoder value for a specific motor
0x05get_all_encodersRetrieves the encoder values for all motors

get_api_version (0x01)

Retrieves the firmware/API version.

Request

OffsetSize (bytes)Field DescriptionValues
01command_id0x01
11ROS2 Driver Version1-255

Response

OffsetSize (bytes)Field DescriptionValues
01command_id0x01
11API Version1-255

set_motor_speed (0x02)

Sets the speed of a specific motor.

Request

OffsetSize (bytes)Field DescriptionValues
01command_id0x02
11motor_idMotor ID (0-3)
24speedSpeed in RPM multiplied by 100 (signed value, negative value means reverse direction)

Response

OffsetSize (bytes)Field DescriptionValues
01command_id0x02

set_all_motors_speed (0x03)

Sets the speed for all four motors in a single command.

Request

OffsetSize (bytes)Field DescriptionValues
01command_id0x03
14speed_motor_1Speed in RPM multiplied by 100 (signed value, negative value means reverse direction)
54speed_motor_2Speed in RPM multiplied by 100 (signed value, negative value means reverse direction)
94speed_motor_3Speed in RPM multiplied by 100 (signed value, negative value means reverse direction)
134speed_motor_4Speed in RPM multiplied by 100 (signed value, negative value means reverse direction)

Response

OffsetSize (bytes)Field DescriptionValues
01command_id0x03

get_encoder (0x04)

Retrieves the encoder value for a specific motor.

Request

OffsetSize (bytes)Field DescriptionValues
01command_id0x04
11motor_idMotor ID (0-3)

Response

OffsetSize (bytes)Field DescriptionValues
01command_id0x04
14encoder_valueEncoder value (signed value, negative value means reverse direction)

get_all_encoders (0x05)

Retrieves the encoder values for all motors.

Request

OffsetSize (bytes)Field DescriptionValues
01command_id0x05

Response

OffsetSize (bytes)Field DescriptionValues
01command_id0x05
14encoder_value_motor_1Encoder value (signed value, negative value means reverse direction)
54encoder_value_motor_2Encoder value (signed value, negative value means reverse direction)
94encoder_value_motor_3Encoder value (signed value, negative value means reverse direction)
134encoder_value_motor_4Encoder value (signed value, negative value means reverse direction)