@@ -36,6 +36,7 @@ This is the core protocol used in both TCP and UART modes.
3636| ` 0x03 ` | [ ` set_all_motors_speed ` ] ( #set_all_motors_speed-0x03 ) | Sets the speed for all four motors in a single command |
3737| ` 0x04 ` | [ ` get_encoder ` ] ( #get_encoder-0x04 ) | Retrieves the encoder value for a specific motor |
3838| ` 0x05 ` | [ ` get_all_encoders ` ] ( #get_all_encoders-0x05 ) | Retrieves the encoder values for all motors |
39+ | ` 0x06 ` | [ ` connect_udp ` ] ( #connect_udp-0x06 ) | Connects to UDP port and starts sending odometry data |
3940
4041### get_api_version (0x01)
4142Retrieves the firmware/API version.
@@ -116,3 +117,37 @@ Retrieves the encoder values for all motors.
116117| 9 | 4 | encoder_value_motor_3 | Encoder value (signed value, negative value means reverse direction) |
117118| 13 | 4 | encoder_value_motor_4 | Encoder value (signed value, negative value means reverse direction) |
118119
120+ ### connect_udp (0x06)
121+ Connects to a UDP port and starts sending odometry/IMU data. The ECU will send UDP packets to the client's IP address and the specified port.
122+
123+ ** Request**
124+ | Offset | Size (bytes) | Field Description | Values |
125+ | --------| -------------| ------------------| --------|
126+ | 0 | 1 | command_id | 0x06 |
127+ | 1 | 4 | port | UDP port number for odometry data transmission |
128+
129+ ** Response**
130+ | Offset | Size (bytes) | Field Description | Values |
131+ | --------| -------------| ------------------| --------|
132+ | 0 | 1 | command_id | 0x06 |
133+ | 1 | 1 | status | 1 = OK, 0 = Error |
134+
135+ ## 4. UDP Data Format
136+ When connected via UDP (after sending ` connect_udp ` command), the ECU sends IMU/odometry data packets to the client's IP address and specified port.
137+
138+ ** UDP Packet Format**
139+ | Offset | Size (bytes) | Field Description | Values/Format |
140+ | --------| -------------| ------------------| ---------------|
141+ | 0 | 1 | imu_id | IMU sensor ID (uint8_t) |
142+ | 1 | 2 | packet_number | Packet sequence number (uint16_t, big-endian) |
143+ | 3 | 4 | accel_x | Accelerometer X-axis (float, big-endian) |
144+ | 7 | 4 | accel_y | Accelerometer Y-axis (float, big-endian) |
145+ | 11 | 4 | accel_z | Accelerometer Z-axis (float, big-endian) |
146+ | 15 | 4 | gyro_x | Gyroscope X-axis (float, big-endian) |
147+ | 19 | 4 | gyro_y | Gyroscope Y-axis (float, big-endian) |
148+ | 23 | 4 | gyro_z | Gyroscope Z-axis (float, big-endian) |
149+ | 27 | 4 | quat_w | Quaternion W component (float, big-endian) |
150+ | 31 | 4 | quat_x | Quaternion X component (float, big-endian) |
151+ | 35 | 4 | quat_y | Quaternion Y component (float, big-endian) |
152+ | 39 | 4 | quat_z | Quaternion Z component (float, big-endian) |
153+
0 commit comments