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

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 uses UART for communication.

2. Protocol Architecture

The protocol consists of two layers:

  1. Data Link Layer – Ensures data integrity.
  2. Application Layer – Defines the core communication commands.

The Data Link Layer ensures message integrity and completeness.

Frame Format

OffsetSize (bytes)FieldDescription
01frame_lengthTotal packet length including CRC16.
1NpayloadApplication Layer (Layer 2) data.
N+12crc16CRC16 checksum (Modbus polynomial: 0x8005).

2.2 Application Layer

This layer defines the structure of the commands and responses.

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
0x06get_imuRetrieves IMU data (accelerometer, gyroscope, quaternion, magnetometer)

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
11status0 = OK, 1 = Error

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
11status0 = OK, 1 = Error

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)

get_imu (0x06)

Request

OffsetSize (bytes)Field DescriptionValues
01command_id0x06

Response

OffsetSize (bytes)Field DescriptionValues/Format
01command_id0x06
14accel_xAccelerometer X-axis (float, little-endian)
54accel_yAccelerometer Y-axis (float, little-endian)
94accel_zAccelerometer Z-axis (float, little-endian)
134gyro_xGyroscope X-axis (float, little-endian)
174gyro_yGyroscope Y-axis (float, little-endian)
214gyro_zGyroscope Z-axis (float, little-endian)
254mag_xMagnetometer X-axis (float, little-endian)
294mag_yMagnetometer Y-axis (float, little-endian)
334mag_zMagnetometer Z-axis (float, little-endian)
374quat_wQuaternion W component (float, little-endian)
414quat_xQuaternion X component (float, little-endian)
454quat_yQuaternion Y component (float, little-endian)
494quat_zQuaternion Z component (float, little-endian)