Skip to main content

Development and use based on serial port protocol

Serial communication protocol

Document Purpose and Object

This document is applicable to the communication protocol for command/data interaction between any upper computer and the XGO series machine dog driver board. Used by advanced developers for secondary development of XGO.

Hardware Connection

Use a hex wrench to unscrew the two screws on the back, left and right, and two screws on the back. Remove the back panel of the machine dog and unplug the switch wire. The motherboard has two serial communication interfaces, which are connected to the upper computer wire sequence according to the motherboard screen printing wire sequence (TX to RX, RX to TX), and can then be debugged. The external power supply voltages of the two terminals are 5V and 3.3V respectively, and cannot be used simultaneously.

Software interface

Using standard TTL serial communication

BAUD115200
Data bits8
stop bit1
Parity bitno

Data Frame

The data frame adopts a fixed format: frame header+frame length+data+checksum+frame tail.

HeaderFixed to 0x55 0x00
frame lengthBytes of the entire data frame
dataDepending on the type of instruction, it has different meanings, as shown in Part 2
checksumAdd all bytes of length and data, take the lowest byte, and then invert it
End of FrameFixed to 0x00 0xAA

Instruct

It is recommended that the interval between each instruction on the upper computer should be at least 1ms to prevent packet loss caused by the machine dog not being able to process the instruction too quickly.

You can refer to [xgolib. py (24 KB)]https://www.elecfreaks.com/download/xgolib.py )The code for send and read in.

Write instruction, no response (0x00)

Frame headerFrame lengthCommand typeFirst addressDataChecksumEnd of frame
0x55 0x000x00data0x00 0xAA

The write command will modify the data starting from the first address, and will not generate a response.

>For example, to modify the forward speed of the robot dog, the forward speed address is 0x30, and the maximum speed is forwarded, that is, the speed content is 0xFF. The specific instructions are as follows:
>0x55 0x00 0x09 0x00 0x30 0xFF 0xC7 0x00 0xAA
>The checksum calculation process is as follows:
>0x09+0x00+0x30+0xFF=0x138,Take the lowest byte 0x38, and get 0xC7 by inversion

Read command, response (0x02)

Frame headerFrame lengthCommand typeFirst addressRead lengthChecksumEnd of frame
0x55 0x000x02uint_80x00 0xAA

The write command will read the data starting from the first address continuously, and no response will be generated.

The format of the returned data packet is:

Frame headerFrame lengthCommand typeFirst addressDateChecksumEnd of frame
0x55 0x000x12data0x00 0xAA
>For example, to read the angles of 12 servos, 0x50 is the address of the first servo position, 0x0C means to read 12 consecutively, the specific instructions are as follows:
>0x55 0x00 0x09 0x02 0x50 0x0C 0x98 0x00 0xAA
>The checksum calculation process is as follows:
>0x09+0x02+0x50+0x0C=0x67,Inverted to get 0x98
>read return packet:
>0x55 0x00 0x14 0x12 0x50 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x89 0x00 0xAA

Machine coordinate system

In the initial standing posture, the origin is directly below the fuselage, the forward direction of the robot dog is the positive direction of the X-axis, the left is the positive direction of the Y-axis, and the upward direction is the positive direction of the Z-axis.

Single leg coordinate system

The single-leg coordinate system is used to describe the position of the foot. The four legs correspond to four independent single-leg coordinate systems. The thigh joint is the origin. The forward direction of the robot dog is the positive direction of the x-axis, the left is the positive direction of the Y-axis, and the bottom is the positive direction of the Z-axis. Towards.

Servo number

shoulder(3)arm(2)elbow(1)
left front leg (1)131211
right front leg(2)232221
right hind leg(3)333231
left hind leg(4)434241

Robot dog memory table

AdressFunctionread and writeinitial valueRemarkmodel
0x00working statusread0x00status information
0x01battery powerread0xffThe range is 0-100, linearly corresponding to the lowest value of power - the highest value
0x03show modewrite0x000x00 normal control mode |0x01 loop action
0x04calibration modewrite0x000x01 Enter the calibration mode 0x00 Exit the calibration mode and complete the calibration
0x05update firmwarewrite0x000x01 enters the update mode, the lower computer sends a same command as a reply, and after a delay of 1s, the upper computer starts to transmit hex
0x07Firmware versionreadreturns a 10-byte string
0x09gaitwrite0x000x00 TROT | 0x01 WALK | 0x02 HIGH WALK
0x20Uninstall the servoread and write0x000x00 servo is in normal working state, 0x01 unloads all servos, 0x11-0x14 unloads legs 1-4 in sequence, 0x21-0x24 restores legs 1-4 in sequencedebug mode
0x21Reset servo zero positionwrite0x000x00 The steering gear is in normal working state 0x01 The current position of all steering gear records is zero. After this register is set to 0x01, it will automatically jump to 0x00
0x30forward and backward moving speedread and write0x80The range is 0x00-0xff, linearly corresponds to the reverse maximum value-forward maximum value, and the positive direction is based on the robot coordinate system, the same below (Note ③)Machine mode
0x31left and right movement speedread and write0x80
0x32Clockwise rotation speedread and write0x80Facing the direction of the z-axis, clockwise corresponds to the direction of the maximum value
0x33body translation distance along the x directionread and write0x80The point of contact between the foot and the ground remains unchanged but the body twists, the same below
0x34body translation distance along the y directionread and write0x80
0x35body heightread and write0x80
0x36Rotation angle of the body around the x-axisread and write0x80Facing the coordinate axis, the direction clockwise corresponds to the maximum value direction, the same below
0x37Rotation angle of the body around the y-axisread and write0x80
0x38Rotation angle of the body around the z-axisread and write0x80
0x39Rotate the body around the x-axis with a certain periodread and write0x000x00 stops, 0x01-0xff linearly corresponds to the minimum-maximum rotation speed, this function and the direct setting of the position register cannot work at the same time
0x3ARotate the body around the y-axis with a certain periodread and write0x00
0x3BRotate the body around the z-axis with a certain periodread and write0x00
0x3CNo progressread and write0x000x00 stops, 0x01-0xff linearly corresponds to the minimum-maximum step height
0x3Dsports moderead and write0x000x00 Normal speed movement 0x01 Slow movement 0x02 High speed movement
0x3Eaction commandwrite0x00For details, see the action instruction table. 255 is to restore the default posture. 1-N is each action (see the right side)
0x80Translational movement along the X-axis direction with a certain periodread and write0x000x00 stops, 0x01-0xff corresponds to the minimum-maximum rotation speed, and the movement range is half of the position limit
0x81Translational movement along the Y-axis direction with a certain periodread and write0x00
0x82Translational movement along the Z-axis direction with a certain periodread and write0x00
0x40The position of the foot end of the left front leg in x directionread and write0x80The range is 0x00-0xff, linearly corresponds to the reverse maximum value-forward maximum value, and the positive direction is based on the robot coordinate system, the same belowsingle leg mode
0x41The position of the foot end of the left front leg in the y directionread and write0x80
0x42The position of the foot end of the left front leg in z directionread and write0x80
0x43The position of the foot end of the right front leg in x directionread and write0x80
0x44The position of the foot end of the front leg in the y directionread and write0x80
0x45The position of the foot end of the right front leg in z directionread and write0x80
0x46Foot end position of right hind leg in x directionread and write0x80
0x47The position of the foot end of the right hind leg in the y directionread and write0x80
0x48The position of the foot end of the right hind leg in z directionread and write0x80
0x49Foot position of left hind leg in x directionread and write0x80
0x4AThe position of the foot end of the left hind leg in the y directionread and write0x80
0x4BThe position of the foot end of the left hind leg in the z directionread and write0x80
0x50ID is 11 servo positionread and write0x80The range is 0x00-0xff, linearly corresponding to the reverse maximum value - forward maximum value, the same belowServo mode
0x51ID is 12 servo positionread and write0x80
0x52ID is 13 servo positionread and write0x80
0x53ID is 21 servo positionread and write0x80
0x54ID is 22 servo positionread and write0x80
0x55ID is 23 servo positionread and write0x80
0x56ID is 31 servo positionread and write0x80
0x57ID is 32 servo positionread and write0x80
0x58ID is 33 servo positionread and write0x80
0x59ID is 41 servo positionread and write0x80
0x5AID is 42 servo positionread and write0x80
0x5BID is 43 servo positionread and write0x80
0x5CSet servo speedread and write0x80The range is 0x00-0xff, linearly corresponding to min-max (valid only in this mode)
0x5DID is 52 servo positionread and write0x80Robotic Arm Forearm Servo
0x5EID is 53 servo positionread and write0x80Robotic Arm Big Arm Servo
0x61IMU statusread and write0x000x00 off 0x01 self-stabilizing mode
0x62ROLL Angleread
0x63pitch angleread
0x64YAW angleread
0x71Gripper statewrite0x800x00-0xFF, 0x00 corresponds to the full opening of the jaws|0xFF corresponds to the full opening of the jaws
0x72Arm Stabilization Modewrite0x000x00 does not enable self-stabilization, 0x01 enables stabilization mode, and the position of the end of the robotic arm in space remains unchanged when the body is moving
0x73Gripper X axis positionwrite0x800x00-0xFF, corresponding to [-80mm, 155mm], the origin of the robot arm coordinate system is at the rotation axis of the arm servo
0x74Gripper Z axis positionwrite0x800x00-0xFF, corresponding to [-95mm, 155mm]

Action content

The action execution process can be interrupted by other commands, and no information will be sent to the host computer after the action execution is completed. If you want to automatically execute the next command after the action is completed, you can manually give a certain delay after sending the action command.

Action ID (decimal)action contentexecution time (seconds)
1get down3
2stand up3
3creep forward5
4circle around5
6squat up4
7Turn Roll4
8Turn Pitch4
9Turn Yaw4
10three-axis rotation7
11pee7
12site down5
13wave7
14stretch10
15wave6
16swing left and right6
17Begging for food4
18looking for food6
19shake hands10
20chicken head9
21push ups8
22look around7
23dance6
24Naughty7
128Catch up10
129Caught10
130Catch10
255Restore default posture1