[toc]
API (Application Programming Interface), also known as Application Programming Interface functions, are predefined functions. When using the following function interfaces, please import our API library at the beginning by entering the following code, otherwise it will not run successfully:
# Example
from pymycobot import Mercury
ml = Mercury('/dev/left_arm')
mr = Mercury('/dev/right_arm')
# The first time you start the machine, you must power it on before you can control the robot.
ml.power_on()
mr.power_on()
print(ml.get_angles())
print(mr.get_angles())
- function: get system version
- Return value: system version
-
function: get robot id
-
Return value: Definition Rule: Actual machine model. For example, the Mercury A1 model is 4500
- function: Get the end version number
- Return value: End parameters(
float
)
- function: Upper computer error security status
- Return value: 0 - Normal. other - Robot triggered collision detection
-
function: atom open communication (default open)
- Attentions: After executing poweroff or pressing emergency stop, it takes 7 seconds to power on and restore power
-
Return value:
1
- Power on completed.0
- Power on failed
-
function: Power off of the robotic arm
-
Return value:
1
- Power on completed.0
- Power on failed
-
function: judge whether robot arms is powered on or not
-
Return value:
1
: power on0
: power off-1
: error
- function: release all robot arms
- Attentions:After the joint is disabled, it needs to be enabled to control within 1 second
- Parameters:
data
(optional):The way to relax the joints. The default is damping mode, and if the 'data' parameter is provided, it can be specified as non damping mode (1- Undamping). - Return value:
1
- release completed.0
- release failed
-
function: Turn on robot torque output
- Return value:
1
: complete0
: failed-1
: error
- Return value:
- function: get the degree of all joints
- Return value:
list
a float list of all degree
- function: Get single joint angle
- Parameters: joint_id (int): 1 ~ 7
- Return value: Array of angles corresponding to joints
- function: send one degree of joint to robot arm
- Parameters:
-
id
: Joint id(genre.Angle
), range int 1-7 -
degree
: degree value(float
) Arm joint range of motionJoint Id range 1 -178 ~ 178 2 -74 ~ 130 3 -178 ~ 178 4 -180 ~ 10 5 -178 ~ 178 6 -20 ~ 273 7 -180 ~ 180 Body joint range of motion. Joint 11 is the chin camera. Joint 12 is the neck. Joint 13 is the lumbar joint
Joint Id range 11 -60 ~ 0 12 -138 ~ 188 13 -118 ~ 118 -
speed
:the speed and range of the robotic arm's movement 1~100
-
- function: Send all angles to all joints of the robotic arm
- Parameters:
angles
: a list of degree value(List[float]
), length 7speed
: (int
) 1 ~ 100
- function: Obtain robot arm coordinates from a base based coordinate system
- Return value: a float list of coord:[x, y, z, rx, ry, rz]
- function: send one coord to robot arm
- Parameters:
id
:send one coord to robot arm, 1-6 corresponds to [x, y, z, rx, ry, rz]coord
: coord value(float
)Coord Id range 1 -466 ~ 466 2 -466 ~ 466 3 -240 ~ 531 4 -180 ~ 180 5 -180 ~ 180 6 -180 ~ 180 speed
: (int
) 1-100
- function:: Send overall coordinates and posture to move the head of the robotic arm from its original point to your specified point
- Parameters:
- coords: : a list of coords value
[x,y,z,rx,ry,rz]
,length6 - speed
(int)
: 1 ~ 100
- coords: : a list of coords value
- function: Control the instruction to pause the core and stop all movement instructions
- function: Check if the program has paused the move command
- Return value:
1
- paused0
- not paused-1
- error
- function: resume the robot movement and complete the previous command
- function: stop all movements of robot
- Return value:
1
- stopped0
- not stop-1
- error
- function : judge whether in the position.
- Parameters:
- data: Provide a set of data that can be angles or coordinate values. If the input angle length range is 7, and if the input coordinate value length range is 6
- flag data type (value range 0 or 1)
0
: angle1
: coord
- Return value:
1
- true0
- false-1
- error
- function: judge whether the robot is moving
- Return value:
1
moving0
not moving-1
error
- function: jog control angle
- Parameters:
joint_id
: Represents the joints of the robotic arm, represented by joint IDs ranging from 1 to 7direction(int)
: To control the direction of movement of the robotic arm, input0
as negative value movement and input1
as positive value movementspeed
: 1 ~ 100
- function: jog control coord.
- Parameters:
coord_id
: (int
) Coordinate range of the robotic arm: 1~6direction
:(int
) To control the direction of machine arm movement,0
- negative value movement,1
- positive value movementspeed
: 1 ~ 100
- function: Single joint angle increment control
- Parameters:
joint_id
: 1-7increment
: Incremental movement based on the current position anglespeed
: 1 ~ 100
- function: Single joint angle increment control
- Parameters:
joint_id
: axis id 1 - 6.increment
: Incremental movement based on the current position coordspeed
: 1 ~ 100
- function: Obtain the value of zero space deflection angle
- Return value:Zero space deflection angle value
-
function: Obtain the value of zero space deflection angle
-
Parameters:
-
angle
: Input the angle range of joint 1, angle range -90 to 90 -
speed
: 1 - 100.
-
- function: Read the minimum joint angle
- Parameters:
joint_id
: Enter joint ID (range 1-7)
- Return value:
float
Angle value
- function: Read the maximum joint angle
- Parameters:
joint_id
: Enter joint ID (range 1-7)
- Return value:
float
Angle value
- function: Set minimum joint angle limit
- Parameters:
id
: Enter joint ID (range 1-7)angle
: Refer to the limit information of the corresponding joint in the send_angle() interface, which must not be less than the minimum value
- function: Set minimum joint angle limit
- Parameters:
id
: Enter joint ID (range 1-7)angle
: Refer to the limit information of the corresponding joint in the send_angle() interface, which must not be greater than the maximum value
- function: Detecting joint connection status
- Parameters:
servo id
1-7 - Return value:
1
: Connection successful0
: not connected-1
: error
- function: Detect the status of all joint connections
- Return value:
1
: Connection successful0
: not connected-1
: error
- function: The current position of the calibration joint actuator is the angle zero point
- Parameters:
servo_id
: 1 - 7
- function: Set the specified joint torque output to turn off
- Parameters:
servo_id
: 1 ~ 7
- Return value:
1
: release successful0
: release failed-1
: error
- function: Set the specified joint torque output to turn on
- Parameters:
servo_id
: 1 ~ 7 - Return value:
1
: focus successful0
: focus failed-1
: error
- function: Set break point
- Parameters:
joint_id
: int. joint id 1 - 7value
: int. 0 - disable, 1 - enable
- Return value: 0 : faile; 1 : success
- function:Get the movement speed of all joints
- Return value: unit step/s
- function:Get the movement current of all joints
- Return value: 0 ~ 5000 mA
- function:Get the movement status of all joints
- Return value: a value of 0 means no error
- function:Clear joint abnormalities
- Parameters:
joint_id
: int. joint id 1 - 7
- function: set IO statue
- Parameters
pin_no
(int): Pin numberpin_signal
(int): 0 / 1
- function: read IO statue
- Parameters:
pin_no
(int) - Return value: signal
-
function: Adaptive gripper enable
-
Parameters:
-
flag (int)
: 0 - open 1 - close, 254 - release -
speed (int)
: 1 ~ 100 -
_type_1 (int)
:-
1
: Adaptive gripper (default state is 1) -
2
: A nimble hand with 5 fingers -
3
: Parallel gripper -
4
: Flexible gripper
-
-
-
function: Set the gripper value
-
Parameters:
-
gripper_value (int)
: 0 ~ 100 -
speed (int)
: 1 ~ 100 -
gripper_type (int)
:-
1
: Adaptive gripper (default state is 1) -
2
: A nimble hand with 5 fingers -
3
: Parallel gripper -
4
: Flexible gripper
-
-
- function: Set the current position of the gripper to zero
- function: Adaptive gripper enable setting
- Parameters:
value
1: Enable 0: Release
- function: Set gripper mode
- Parameters:
value
:- 0: Transparent transmission mode
- 1: normal mode
- function: Get gripper mode
- Return value:
- 0: Transparent transmission mode
- 1: normal mode
- Function:: Initialize the electric gripper. This interface needs to be called for initialization before the electric gripper is powered on for the first time.
- Function:: Setting the electric gripper mode
- Parameters:
mode
:- 0: Closed gripper
- 1: Open gripper
- function: Get the status of the button at the end of the robot arm
- Return value:
- 0: no clicked
- 1: clicked
-
function: Set the color of the end light of the robotic arm
-
Parameters:
-
r (int)
: 0 ~ 255 -
g (int)
: 0 ~ 255 -
b (int)
: 0 ~ 255
-
- function: Start recording and dragging teaching points.
- Note: In order to display the best sports effect, the recording time should not exceed 90 seconds
- function: Pause sampling
- function: Start dragging the teach-in point, executing it only once.
- function: clear sample.
- function: Set tool coordinate system.
- Parameters:
coords
: (list
) [x, y, z, rx, ry, rz]. - Return value: NULL
- function: Get tool coordinate system.
- Return value:
oords
: (list
) [x, y, z, rx, ry, rz]
- function: Set world coordinate system.
- Parameters:
coords
: (list
) [x, y, z, rx, ry, rz]. - Return value: NULL
- function: Get world coordinate system.
- Return value:
list
[x, y, z, rx, ry, rz].
- function: Set base coordinate system.
- Parameters:
rftype
: 0 - base 1 - tool.
- function: Set base coordinate system.
- Return value:
0
- base1
- tool.
- function: Set movement type.
- Parameters:
move_type
: 1 - movel, 0 - moveJ.
- function: Get movement type.
- Return value:
1
- movel0
- moveJ
- function: Get end coordinate system
- Parameters:
end (int)
:0
- flange,1
- tool
- function: Obtain the end coordinate system
- Return value:
0
- flange1
- tool
- function:Arc trajectory motion
- Parameters:
transpoint(list)
:Arc passing through point coordinatesendpoint (list)
:Arc endpoint coordinatesspeed(int)
: 1 ~ 100
- function:Set Base IO Output
- Parameters:
pin_no
(int
) Pin port number, range 1 ~ 6pin_signal
(int
): 0 - low. 1 - high
- function: Read base IO input, range 1 ~ 6
- Parameters:
pin_no
(int
) pin number
- Return value: 0 - low. 1 - high
- function:485 factory reset
- function: Set up 485 communication
- Return value: 0 : not set 1 : Setup completed
- function: Set up 485 communication
- Return value: 0-Normal 1-Robot triggered collision detection
- function: Read fixed length data. Before reading, read the buffer length first. After reading, the data will be cleared
- Parameters: data_len (int): The number of bytes to be read, range 1 ~ 45
- Return value: 0 : not set 1 : Setup completed
- function: End 485 sends data, Data length range is 1 ~ 45 bytes
- Return value: 0-Normal 1-Robot triggered collision detection
- function: Clear 485 buffer
- Return value: 0-Normal 1-Robot triggered collision detection
- function: View the first data in the buffer, the data will not be cleared
- Return value: 1 byte data
- function: Set 485 baud rate, default 115200
- Parameters: baud (int): baud rate
- Return value: NULL
- function: Set 485 timeout in milliseconds, default 30ms
- Parameters
max_time
: (int): timeout
- Return value: NULL
API Usage Instructions
# demo
from pymycobot import ChassisControl
mc = ChassisControl()
# Get battery voltage
voltage = mc.get_power_voltage()
print(voltage)
# Set the chassis RGB light strip to green
mc.set_color(255, 0, 0)
- Function: Get the battery voltage.
- Return value: Battery voltage (floating point type), unit: Volt
- Function: Get all ultrasonic data.
- Return value: List of all ultrasonic data, unit: millimeter.
- Function: Control the chassis to move forward.
- Parameters:
- speed: (floating point type) the speed of chassis movement, the range is
0 ~ 1
, unit: m/s.
- speed: (floating point type) the speed of chassis movement, the range is
- Function: Control chassis to move backward.
- Parameters:
- speed: (floating point type) chassis movement speed, range is
-1 ~ 0
, unit: m/s.
- speed: (floating point type) chassis movement speed, range is
- Function: Control the chassis to rotate to the left.
- Parameters:
- speed: (floating point type) the speed of chassis movement, ranging from
0 ~ 1
, unit: m/s.
- speed: (floating point type) the speed of chassis movement, ranging from
- Function: Control chassis to rotate right.
- Parameters:
- speed: (floating point type) chassis movement speed, range is
-1 ~ 0
, unit: m/s.
- speed: (floating point type) chassis movement speed, range is
- Function: Stop motion.
- Function: Set the color of the chassis RGB light strip.
- Parameters:
- r (int): 0 ~ 255
- g (int): 0 ~ 255
- b (int): 0 ~ 255