-
Notifications
You must be signed in to change notification settings - Fork 1
protocol
Our team using serial port communicated with ROS.
- 1st Byte - Sync Flag (Value: 0xff)
- 2nd Byte - Device ID (Motor:0xfe)
- 3rd Byte - Message Length (N)
- 4th Byte - Command ID Low Byte
- 5th Byte - Command ID Hight Byte
- N Bytes - Message Data
- Byte N+6 - Checksum from Device ID to Message Data
Length Checksum = (Device_ID + Message_Length + Command_ID + Message_Date) % 256
We establish our device tree from a motor control board
Motor Control Board | 0xFE
The Message Length is count of Message Data number (N).
Every Command and Sendback data has its ID and it build up by 2 bytes. We send lower byte first. The High byte is separated by 0x80, when the high byte is less than 0x80 means it is a command since it bigger than 0x80(including 0x80) means it is a sendback data.
Message Data is quite different in type, length or meaning.
0xff, 0xfe, 0x04, 0x01, 0x00, Left_Wanted_Direction, Left_Wanted_Speed, Right_Wanted_Direction, Right_Wanted_Speed, sum_check
ff fe 04 01 00 01 14 01 14 2D //20cm/s both
ff fe 04 01 00 01 15 01 15 2F //21cm/s both
ff fe 04 01 00 01 18 01 18 35 //24cm/s both
ff fe 04 01 00 01 1B 01 1B 3B //28cm/s both
-
message data is "0x01 0x14 0x01 0x14" and it means both motor set to the forward direction and speed is set to 20cm/s(0x14=20).
-
message length is "0x04" which is after the header "0xff 0xfe".
-
command id is "0x01 0x00" and its high byte is 0x00 and lower byte is 0x01, again we send lower byte first.
-
sum check is "0x2D", 0xfe + 0x04 + 0x01 + 0x00 + 0x01 + 0x14 + 0x01 + 0x14 = 0x12D, 0x12D % 256 = 0x2D.
0xff 0xfe 0x01 0x02 0x00 State sum_check
0xff 0xfe 0x01 0x02 0x00 0x01 0x02
State:
- 0x01----work normally
- 0x00---- stop
- 0x02---- halt
0xff 0xfe 0x00 0x03 0x00 sum_check
0xff 0xfe 0x00 0x03 0x00 0x01
0xff 0xfe 0x03 0x04 0x00 Proportional Integral Derivative sum_check
0xff 0xfe 0x03 0x04 0x00 Proportional Integral Derivative sum_check
0xff 0xfe 0x00 0x05 0x00 sum_check
0xff 0xfe 0x00 0x06 0x00 sum_check
0xff 0xfe 0x00 0x07 0x00 sum_check
0xff 0xfe 0x04 0x01 0x80 Left_Direction Left_Speed Right_Direction Right_speed sum_check
0xff 0xfe 0x04 0x02 0x80 Left_Encoder_Low Left_Encoder_High Right_Encoder_Low Right_Encoder_High sum_check
0xff 0xfe 0x03 0x03 0x80 Proportional Integral Derivative sum_check
0xff 0xfe 0x04 0x04 0x80 Left_Wanted_Direction Left_Wanted_Speed Right_Wanted_Direction Right_Wanted_Speed sum_check