Python Development Mode
XGo2 robot can be developed using the Python language.The motion,pose,coordinates,gripper and servo of the XGO2 can be controlled via Python. Download the XGO2.lib via the link XGO.lib Download.The detailed instructions for use of the library are as follows.
UPDATE RECORD
2023.2.1 creat
XGO Class
All functions are implemented by the methods owned by XGO. When instantiating an XGO class object, three parameters need to be passed in. The first one is the physical interface for serial communication between the host computer and the robot dog. It needs to be modified according to the actual situation. The second parameter is the baud rate of 115200, and the third parameter is 'xgomini' or 'xgolite' according to the model. Assuming that the serial communication interface is COM4, the instantiation code is as follows. 1
2
3
4
5
6
7from xgolib import XGO
Debian
dog = XGO('/dev/ttyAMA0','xgomini')
dog = XGO('/dev/ttyAMA0','xgolite')
Windows
dog = XGO('COM4',115200,'xgomini')
dog = XGO('COM4',115200,'xgolite')
Part of movement
action(action_id)
Parameter Name | Value | Description |
---|---|---|
action_id | [] | The ID and the action is shown in the table below |
ID | action | ID | action | ID | action |
---|---|---|---|---|---|
1 | Lie down | 2 | Stand up | 3 | Crawl |
4 | Trun around | 6 | Squat | 7 | Trun roll |
8 | Turn pitch | 9 | Turn yaw | 10 | 3 axis motion |
11 | Take a pee | 12 | Sit down | 13 | Wave hand |
14 | Cive a stretch | 15 | Wave body | 16 | Wave side |
17 | Pray | 18 | Looking for food | 19 | Handshake |
20 | Chicken head | 21 | Push up | 22 | Seek |
23 | Dance | 128 | Grab UP | 129 | Grab Mid |
23 | Grab down |
move(direction, step)
Parameter Name | Value | Description |
---|---|---|
direction | 'x'、'X'、'y'、'Y' | 'x'or'X'move forward or back,'y'or'Y'move left or right |
step | x:[-25,25] y:[-18,18] |
Step is stride,positive represents forward or left shift, negative represents backward or right shift. |
turn(step)
Parameter Name | Value | Description |
---|---|---|
step | [-150,150] | Step represents rotational speed in ° / s, positive is left and negative is right. |
translation(direction,data)
Parameter Name | Value | Description |
---|---|---|
direction | 'x','y','z' | 'x','y','z' are three directions of coordinate system |
data | mini2,'x':[-35,35]'y':[-18,18]'z':[75,115] lite2,'x':[-25,25]'y':[-18,18]'z':[60,110] |
Translation value range |
attitude(direction, data)
Parameter Name | Value | Description |
---|---|---|
direction | 'x','y','z' | 'x','y','z'represent roll pitch yaw |
data | mini2,'x':[-20,+20]'y':[-15,+15]'z'[-11,+11] lite2,'x':[-20,+20]'y':[-10,+10]'z'[-12,+12] |
attitude value range |
leg(leg_id, data)
Parameter Name | Value | Description |
---|---|---|
leg_id | 1,2,3,4 | 'left front','right front','right rear','left rear' |
data | mini2,'x':[-35,35]'y':[-18,18]'z':[75,115] lite2,'x':[-25,25]'y':[-18,18]'z':[60,110] |
toes position value range |
motor(motor_id, data)
Parameter Name | Value | Description |
---|---|---|
motor_id | 11,12,13 21,22,23 31,32,33 41,42,41 51,52,53 |
'left front lower','left front middle','left front upper' 'right front lower','right front middle','right front upper' 'right rear lower','right rear middle','right rear upper' 'left rear lower','left rear middle','left rear upper' 'top of arm','middle of arm','lower of arm' |
data | mini2,11:[-73,+57]12:[-66,93]13:[-31,31] mini2,21:[-73,+57]22:[-66,93]23:[-31,31] mini2,31:[-73,+57]32:[-66,93]33:[-31,31] mini2,41:[-73,+57]42:[-66,93]43:[-31,31] mini2,51:[-75,+90]52:[-85,50]53:[-65,65] lite2,11:[-70,+50]12:[-70,90]13:[-30,30] lite2,21:[-70,+50]22:[-70,90]23:[-30,30] lite2,31:[-70,+50]32:[-70,90]33:[-30,30] lite2,41:[-70,+50]42:[-70,90]43:[-30,30] lite2,51:[-92,+105]52:[-70,60]53:[-30,30] |
servo value range |
1 | #action |
Part of read XGO2 battery,servo angle,value of imu
leg(leg_id, data)
Parameter Name | Value | Description |
---|---|---|
leg_id | 1,2,3,4 | 'left front','right front','right rear','left rear' |
data | mini2,'x':[-35,35]'y':[-18,18]'z':[75,115] lite2,'x':[-25,25]'y':[-18,18]'z':[60,110] |
toes position value range |