This is python API for ElephantRobotics product
We support Python2, Python3.5 or later.
Catalogue:
- pymycobot
- MyCobot / Mypalletizer / MechArm / MyArm
- Overall status
- MDI mode and operation
- JOG mode and operation
- Running status and Settings
- Servo control
- Atom IO
- set_color
- set_pin_mode
- set_digital_output()
- get_digital_input()
- set_pwm_output()
- set_gripper_calibration
- get_gripper_value
- set_gripper_state
- set_gripper_value
- is_gripper_moving
- get_basic_input
- set_basic_output
- set_ssid_pwd
- get_ssid_pwd
- set_server_port
- get_tof_distance
- get_tool_reference
- set_tool_reference
- set_world_reference
- get_world_reference
- set_reference_frame
- get_reference_frame
- set_movement_type
- get_movement_type
- set_end_type
- get_end_type
- get_plan_speed
- get_plan_acceleration
- set_plan_speed
- set_plan_acceleration
- move_round
- get_basic_version
- set_transponder_mode
- get_servo_speeds
- get_servo_currents
- get_servo_voltages
- get_servo_status
- get_servo_temps
- init_eletric_gripper
- set_eletric_gripper
- set_gripper_mode
- get_gripper_mode
- set_encoders_drag
- get_solution_angles
- set_solution_angles
- joint_brake
- get_transponder_mode
- set_transponder_mode
- set_HTS_gripper_torque
- get_HTS_gripper_torque
- get_gripper_protect_current
- init_gripper
- set_gripper_protect_current
- set_four_pieces_zero
- jog_rpy
- set_void_compensate
- Raspberry pi -- GPIO
- Angle
- Coord
- utils (Module)
- MyCobotSocket
- MyBuddy
- base_to_single_coords(base_coords, arm)
- collision(left_angles, right_angles)
- collision_switch(state)
- focus_servo(id, servo_id)
- get_acceleration(id)
- get_angle(id, joint_id)
- get_angles(id)
- get_base_coord(id)
- get_base_coords(*args: int)
- get_coord(id, joint_id)
- get_coords(id)
- get_digital_input(id, pin_no)
- get_encoder(id, joint_id)
- get_encoders(id)
- get_end_type(id)
- get_gripper_value(id)
- get_joint_current(id, joint_id)
- get_joint_max_angle(id, joint_id)
- get_joint_min_angle(id, joint_id)
- get_movement_type(id)
- get_plan_acceleration(id=0)
- get_plan_speed(id=0)
- get_reference_frame(id)
- get_robot_id(id)
- get_robot_version(id)
- get_servo_currents(id)
- get_servo_data(id, servo_no, data_id)
- get_servo_status(id)
- get_servo_spees(id)
- get_servo_temps(id)
- get_servo_voltages(id)
- get_speed(id)
- get_system_version(id)
- get_tool_reference(id)
- get_world_reference(id)
- is_all_servo_enable(id)
- is_collision_on()
- is_controller_connected(id=0)
- is_free_mode(id)
- is_gripper_moving(id)
- is_in_position(id, data, mode)
- is_moving(id)
- is_paused(id)
- is_power_on(id=0)
- is_servo_enable(id, servo_id)
- jog_absolute(id, joint_id, angle, speed)
- jog_angle(id, joint_id, direction, speed)
- jog_coord(id, coord_id, direction, speed)
- jog_inc_coord(axis, increment, speed)
- jog_increment(id, joint_id, increment, speed)
- jog_stop(id)
- joint_brake(id, joint_id)
- pause(id)
- power_off(id=0)
- power_on(id=0)
- read_next_error(id=0)
- release_all_servos(id=0)
- release_servo(id, servo_id)
- resume(id)
- send_angle(id, joint, angle, speed)
- send_angles(id, degrees, speed)
- send_coord(id, coord, data, speed)
- send_coords(id, coords, speed, mode)
- set_acceleration(id, acc)
- set_color(id, r=0, g=0, b=0)
- set_digital_output(id, pin_no, pin_signal)
- set_encoder(id, joint_id, encoder, speed)
- set_encoders(id, encoders, speed)
- set_end_type(id, end)
- set_encoders_drag(id, encoders, speeds)
- set_free_mode(id, value)
- set_fresh_mode(id, mode)
- set_gripper_calibration(id)
- set_gripper_state(id, flag)
- set_gripper_value(id, value, speed)
- set_joint_current(id, joint_id, current)
- set_joint_max(id, joint_id, angle)
- set_joint_min(id, joint_id, angle)
- set_movement_type(id, move_type)
- set_pin_mode(id, pin_no, pin_mode)
- set_plan_acceleration(id, acceleration)
- set_plan_speed(id, speed)
- set_pwm_output()
- set_reference_frame(id, rftype)
- set_robot_id(id, new_id)
- set_servo_calibration(id, servo_no)
- set_servo_data(id, servo_no, data_id, value)
- set_speed(id, speed)
- set_tool_reference(id, coords)
- set_world_reference(id, coords)
- stop(id)
- write_base_coord(id, axis, coord, speed)
- write_base_coords(id, coords, speed)
- get_radians(id)
- send_radians(id, radians, speed)
- set_gpio_input(pin)
- set_gpio_mode(pin_no, mode)
- set_gpio_output(pin, v)
- set_gpio_pwm(pin, baud, dc)
- MyBuddyEmoticon
Import to your project:
# for mycobot
from pymycobot import MyCobot
# for mypalletizer
# from pymycobot import MyPalletizer
# for MechArm
# from pymycobot import MechArm
mc = MyCobot("com10",115200)
# mc = MyPalletizer("com10",115200)
# mc = MechArm("com10",115200)
print(mc.get_angles())
Note: If no parameter is given, there is no parameter; if no return value is given, there is no return value
-
Prototype:
power_on()
-
Description:Atom open communication (default open).
-
Prototype:
power_off()
-
Description: Atom turn off communication.
-
Prototype:
is_power_on()
-
Description: Adjust robot arm whether power on.
-
Returns
1
: power on0
: power off-1
: error
-
Prototype:
read_next_error()
-
Description: Robot Error Detection.
-
Returns list len 7
0
: No abnormality1
: Communication disconnected2
: Unstable communication3
: Servo abnormality
-
Prototype:
release_all_servos()
-
Description: Set robot arm into free moving mode.
-
Prototype:
is_controller_connected()
-
Description: Check if connected with Atom.
-
Returns
1
: connected0
: not connected-1
: error
-
Prototype:
get_error_information()
-
Description: Obtaining robot error information.
-
Returns
0
: No error message.1 ~ 6
: The corresponding joint exceeds the limit position.32
: Kinematics inverse solution has no solution.33 ~ 34
: Linear motion has no adjacent solution.
-
Prototype:
clear_error_information()
-
Description: Clear robot error message.
-
Prototype:
get_angles()
-
Description: Get the degree of all joints.
-
Returns:
list
: A float list of all degree.
Set command refresh mode
-
Parameters
- mode – int 1 - Always execute the latest command first. 0 - Execute instructions sequentially in the form of a queue.
get command refresh mode
- return
- 1 - Always execute the latest command first.
- 0 - Execute instructions sequentially in the form of a queue.
-
Prototype:
send_angles(id, degree, speed)
-
Description: Send one degree of joint to robot arm.
-
Parameters
id
: Joint id(genre.Angle
) / int 1-7degree
: degree value(float
) (about -170 ~ 170)speed
: (int
) 0 ~ 100
-
Example
from pymycobot.mycobot import MyCobot from pymycobot.genre import Angle mycobot = MyCobot('/dev/ttyUSB0') mycobot.send_angle(Angle.J2.value, 10, 50)
-
Prototype:
send_angles(degrees, speed)
-
Description: Send the degrees of all joints to robot arm.
-
Parameters
-
degrees
: a list of degree value(List[float]
), length 7. -
speed
: (int
) 0 ~ 100
-
-
Example
from pymycobot.mycobot import MyCobot from pymycobot.genre import Angle mycobot = MyCobot('/dev/ttyUSB0') mycobot.send_angles([0,0,0,0,0,0], 80)
-
Prototype:
get_radians()
-
Description: Get the radians of all joints.
-
Returns:
list
: A float list of radian.
-
Prototype:
send_radians(radians, speed)
-
Description: Send the radians of all joint to robot arm.
-
Parameters:
radians
: a list of radian value(List[float]
).speed
: (int
) 0 ~ 100
-
Example
from pymycobot.mycobot import MyCobot from pymycobot.genre import Angle mycobot = MyCobot('/dev/ttyUSB0') mycobot.send_angles_by_radian([1,1,1,1,1,1], 70)
-
Prototype:
get_coords()
-
Description: Get the Coords from robot arm, coordinate system based on base.
-
Returns:
list
: A float list of coord -[x, y, z, rx, ry, rz]
-
Prototype:
send_coords(id, coord, speed)
-
Description: Send one coord to robot arm.
-
Parameters
id
: coord id(genre.Coord
) / int 1-6coord
: coord value(float
)speed
: (int
) 0 ~ 100
-
Example
from pymycobot.mycobot import MyCobot from pymycobot.genre import Coord mycobot = MyCobot('/dev/ttyUSB0') mycobot.send_coord(Coord.X.value, -40, 70)
-
Prototype:
send_coords(coords, speed, mode)
-
Description: Send all coords to robot arm.
-
Parameters
coords
: a list of coords value(List[float]
).speed
: (int
) 0 ~ 100mode
: (int
):0
- angular,1
- linear
-
Example
from pymycobot.mycobot import MyCobot from pymycobot.genre import Coord mycobot = MyCobot('/dev/ttyUSB0') mycobot.send_coords([160, 160, 160, 0, 0, 0], 70, 0)
-
Prototype:
sync_send_angles(degrees, speed, timeout=15)
-
Description: Send the angle in synchronous state and return when the target point is reached
-
Parameters
degrees
: a list of degree value(List[float]
).speed
: (int
) 0 ~ 100timeout
: default 7s.
-
Prototype:
sync_send_coords(coords, speed, mode, timeout=15)
-
Description: Send the coord in synchronous state and return when the target point is reached
-
Parameters
coords
: a list of coords value(List[float]
)speed
: (int
) 0 ~ 100mode
: (int
):0
- angular,1
- lineartimeout
: default 7s.
-
Prototype:
is_in_position(data, flag)
-
Description: Judge whether in the position.
-
Parameters
data
: A data list, angles or coords.flag
: Tag the data type,0
- angles,1
- coords.
-
Returns
1
- true0
- false-1
- error
-
Prototype:
is_moving()
-
Description: Detect if the robot is moving.
-
Returns
1
- is moving0
- not moving-1
- error data
-
Prototype:
jog_angle(joint_id, direction, speed)
-
Description: Jog control angle
-
Parameters
joint_id
: (int
) 1 ~ 6direction
:0
- decrease,1
- increasespeed
: 0 ~ 100
-
Prototype:
jog_coord(coord_id, direction, speed)
-
Description: Jog control coord.
-
Parameters
coord_id
: (int
) 1 ~ 6direction
:0
- decrease,1
- increasespeed
: 0 ~ 100
-
Prototype:
jog_absolute(joint_id, angle, speed)
-
Description: Jog absolute angle.
-
Parameters
joint_id
: (int
)- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
direction
:speed
: 0 ~ 100
-
Prototype:
jog_increment(coord_id, direction, speed)
-
Description: Step mode.
-
Parameters
coord_id
: (int
)- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
direction
:speed
: 0 ~ 100
-
Prototype:
jog_stop()
-
Description: Stop jog moving.
-
Prototype:
pause()
-
Description: Pause movement.
-
Prototype:
resume()
-
Description: Recovery movement.
-
Prototype:
stop()
-
Description: Stop moving.
-
Prototype:
is_paused()
-
Description: Judge whether the manipulator pauses or not.
-
Returns :
1
- paused0
- not paused-1
- error
-
Prototype:
set_encoder(joint_id, encoder)
-
Description: Set a single joint rotation to the specified potential value.
-
Parameters
joint_id
: (int
)- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
encoder
: 0 ~ 4096
-
Prototype:
get_encoder(joint_id)
-
Description:Obtain the specified joint potential value.
-
Parameters:
joint_id
: (int
)- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
-
Returns:
encoder
: 0 ~ 4096
-
Prototype:
set_encoders(encoders, sp)
-
Description: Set the six joints of the manipulator to execute synchronously to the specified position.
-
Parameters:
encoders
: A encoder list.sp
: speed 0 - 100
-
Prototype:
get_encoders()
-
Description: Get the six joints of the manipulator.
-
Returns: the list of encoder (
list
)
-
Prototype:
get_speed()
-
Description: Get speed.
-
Returns: speed: (
int
)
-
Prototype:
set_speed(speed)
-
Description: Set speed.
-
Parameters: speed: (
int
) 0 ~ 100
-
Prototype:
set_joint_min(id, angle)
-
Description: Sets the minimum angle for the specified joint.
-
Parameters:
id
: (int
)- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
angle
: 0 - 180.
-
Prototype:
set_joint_max(id, angle)
-
Description: Sets the maximum angle of the specified joint.
-
Parameters:
id
: (int
) joint id- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
angle
: 0 - 180.
-
Prototype:
get_joint_min_angle()
-
Description: Gets the minimum movement angle of the specified joint
-
Parameters:
joint_id
: (int
)- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
-
Returns: angle value (
float
)
-
Prototype:
get_joint_max_angle()
-
Description: Gets the maximum movement angle of the specified joint
-
Parameters:
joint_id
: (int
)- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
-
Returns: angle value (
float
)
-
Prototype:
is_servo_enable(servo_id)
-
Description: Determine whether all steering gears are connected
-
Parameters:
servo_id
(int
)- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
-
Returns
0
: disable1
: enable-1
: error
-
Prototype:
is_all_servo_enable()
-
Description: Determine whether the specified steering gear is connected
-
Returns
0
: disable1
: enable-1
: error
-
Prototype:
set_servo_data(servo_no, data_id, value, mode=None)
-
Description: Set the data parameters of the specified address of the steering gear.
-
Parameters:
servo_no (int)
: Serial number of articulated steering gear.- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
data_id
: Data address.value
: 0 - 4096mode
: 0 - indicates that value is one byte(default), 1 - 1 represents a value of two bytes.
-
Prototype:
get_servo_data(servo_no, data_id)
-
Description: Read the data parameter of the specified address of the steering gear.
-
Parameters:
servo_no
: Serial number of articulated steering gear.- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
data_id
: Data address.
-
Returns:
value
: 0 - 40960
: disable1
: enable-1
: error
-
Prototype:
set_servo_calibration(servo_no)
-
Description: The current position of the calibration joint actuator is the angle zero point, and the corresponding potential value is 2048.
-
Parameters:
servo_no
: Serial number of articulated steering gear.- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
-
Prototype:
release_servo(servo_id)
-
Description: Power off designated servo
-
Parameters:
servo_id
:- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
-
Prototype:
focus_servo(servo_id)
-
Description: Power on designated servo
-
Parameters:
servo_id
:- for mycobot / mecharm: int 1-6.
- for mypalletizer: int 1-4.
- for myArm: int 1 - 7.
-
Prototype:
set_color(r, g, b)
-
Description: Set the color of the light on the top of the robot arm.
-
Parameters
r
: 0 ~ 255g
: 0 ~ 255b
: 0 ~ 255
-
Prototype:
set_pin_mode(pin_no, pin_mode)
-
Description: Set the state mode of the specified pin in atom.
-
Parameters
pin_no
(int): Pin number.pin_mode
(int): 0 - input, 1 - output, 2 - input_pullup
Set the terminal atom io status
-
Parameters
pin_no
(int):pin_signal
(int): 0 / 1
-
Parameters:
pin_no
(int) -
Return: signal value
-
Prototype:
set_pwm_output(channel, frequency, pin_val)
-
Description: PWM control.
-
Parameters
channel
(int
): IO number.frequency
(int
): clock frequencypin_val
(int
): Duty cycle 0 ~ 256; 128 means 50%
-
Prototype:
set_gripper_calibration()
-
Description: Set the current position to zero, set current position value is
2048
.
-
Prototype:
get_gripper_value(gripper_type=None)
-
Description: Get gripper value
-
Parameters
gripper_type
(int
):- 1 - Adaptive gripper.
- 3 - Parallel gripper, this parameter can be omitted, default to adaptive gripper
- 4 - Flexible gripper
-
Return: gripper value (int)
-
Prototype:
set_gripper_state(flag, speed, _type_1=None)
-
Description: Set gripper switch state
-
Parameters
flag
(int
): 0 - open, 1 - closespeed
(int
): 0 ~ 100_type_1
(int
):- 1- Adaptive gripper,
- 2 - 5 finger dexterous hand,
- 3 - Parallel gripper, this parameter can be omitted, default to adaptive gripper
- 4 - Flexible gripper
-
Prototype:
set_gripper_value(value, speed, gripper_type=None)
-
Description: Set gripper value
-
Parameters
value
(int): 0 ~ 100speed
(int): 0 ~ 100gripper_type
(int):- 1 - Adaptive gripper
- 3 - Parallel gripper, this parameter can be omitted, default to adaptive gripper
- 4 - Flexible gripper
-
Prototype:
is_gripper_moving()
-
Description: Judge whether the gripper is moving or not
-
Returns
0
: not moving1
: is moving-1
: error data
-
Prototype:
get_basic_input(pin_no)
-
Description: Get bottom pin.
-
Parameters
pin_no
(int
) Pin number.
-
Return:
pin_signal
(int
) 0 / 1
-
Prototype:
set_basic_output(pin_no, pin_signal)
-
Description: Set bottom pin.
-
Parameters
pin_no
(int
) Pin number.pin_signal
(int
): 0 / 1
-
Prototype:
set_ssid_pwd(account, password)
-
Description: Change connected wifi.(Apply to m5 or seeed)
-
Parameters
account
(str
) new wifi account.password
(str
): new wifi password.
-
Prototype:
get_ssid_pwd()
-
Description: Get connected wifi account and password.(Apply to m5 or seeed)
-
Return:
(account, password)
.
-
Prototype:
set_server_port(port)
-
Description: Change the connection port of the server.
-
Parameters
port
: (int
) The new connection port of the server.
-
Prototype:
get_tof_distance()
-
Description: Get the detected distance (Requires external distance detector).
-
Return:
int
The unit is mm.
-
Prototype:
get_tool_reference()
-
Description: Get tool coordinate system.
-
Return:
list
[x, y, z, rx, ry, rz].
-
Prototype:
set_tool_reference(coords)
-
Description: Set tool coordinate system.
-
Parameters:
coords
: (list
) [x, y, z, rx, ry, rz].
-
Prototype:
set_world_reference(coords)
-
Description: Set world coordinate system.
-
Parameters:
coords
: (list
) [x, y, z, rx, ry, rz].
-
Prototype:
get_world_reference()
-
Description: Get world coordinate system.
-
Return:
list
[x, y, z, rx, ry, rz].
-
Prototype:
set_reference_frame(rftype)
-
Description: Set base coordinate system.
-
Parameters:
rftype
: 0 - base 1 - tool.
-
Prototype:
get_reference_frame()
-
Description: Get base coordinate system.
-
Return: 0 - base 1 - tool.
-
Prototype:
set_movement_type(move_type)
-
Description: Set movement type.
-
Parameters:
move_type
: 1 - movel, 0 - moveJ.
-
Prototype:
get_movement_type()
-
Description: Get movement type.
-
Return: 1 - movel, 0 - moveJ.
-
Prototype:
set_end_type(end)
-
Description: Set end coordinate system.
-
Parameters:
end
: 0 - flange, 1 - tool.
-
Prototype:
get_end_type()
-
Description: Get end coordinate system.
-
Return: 0 - flange, 1 - tool.
-
Prototype:
get_plan_speed()
-
Description: Get planning speed.
-
Return: [
movel planning speed
,movej planning speed
].
-
Prototype:
get_plan_acceleration()
-
Description: Get planning acceleration.
-
Return: [
movel planning acceleration
,movej planning acceleration
].
-
Prototype:
set_plan_speed(speed, is_linear)
-
Description: Set planning speed.
-
Parameters
speed
(int
) 0 - 100.is_linear
(int
): 0 / 1 (0 ->joint, 1 -> line)
-
Prototype:
set_plan_acceleration(acceleration, is_linear)
-
Description: Set planning acceleration.
-
Parameters
acceleration
(int
) 0 - 100.is_linear
(int
): 0 / 1 (0 ->joint, 1 -> line)
-
Prototype:
move_round(angle)
-
Description: Drive the 9g steering gear clockwise for one revolution.
-
Parameters
angle
(int
) 0 - 255. 0 : stop 255 : Keep turning 1 ~ 254: Based on 30° (1->30°, 2->60°)
-
Prototype:
get_basic_version()
-
Description: Get basic firmware version.
-
Return
version
(float
)
-
Prototype:
set_transponder_mode(mode)
-
Description: Set basic communication mode.
-
Parameters
mode
(int
) 0 - Turn off transparent transmission. 1 - Open transparent transmission
-
Prototype:
get_servo_speeds()
-
Description: Get joint velocity.
-
Return:
list
Speed of each joint.
-
Prototype:
get_servo_currents()
-
Description: Get joint current.
-
Return:
list
Current of each joint.
-
Prototype:
get_servo_voltages()
-
Description: Get joint voltage.
-
Return:
list
Voltage of each joint.
-
Prototype:
get_servo_status()
-
Description: Get the state of each joint.
-
Return:
list
the state of each joint.
-
Prototype:
get_servo_temps()
-
Description: Get the temperature of each joint.
-
Return:
list
temperature of each joint.
-
Prototype:
init_eletric_gripper()
-
Description: Electric gripper initialization (it needs to be initialized once after inserting and removing the gripper) (only for 350)
-
Prototype:
set_eletric_gripper(status)
-
Description: Set Electric Gripper Mode (only for 350).
-
Parameters
status
(int
): 0 - open, 1 - close.
-
Prototype:
set_gripper_mode(status)
-
Description: Set gripper mode.
-
Parameters
status
(int
): 0 - transparent transmission. 1 - Port Mode.
-
Prototype:
get_gripper_mode()
-
Description: Get gripper mode.
-
Return
status
(int
): 0 - transparent transmission. 1 - Port Mode.
-
Prototype:
set_encoders_drag(encoders, speeds)
-
Description: Send all encoders and speeds
-
Parameters
encoders
(list
) : encoders list.speeds
: Obtained by the get_servo_speeds() method
-
Prototype:
get_solution_angles()
-
Description: Get zero space deflection angle value.(
This interface is only applicable to MyArm
)
-
Prototype:
set_solution_angles(angle, speed)
-
Description: Set zero space deflection angle value.(
This interface is only applicable to MyArm
) -
Parameters
angle
: Angle of joint 1.speed
: 1 - 100.
-
Prototype:
joint_brake(joint_id)
-
Description: Make it stop when the joint is in motion, and the buffer distance is positively related to the existing speed
-
Parameters
joint_id
: 1 - 7.
-
Prototype:
get_transponder_mode()
-
Description: Obtain the configuration information of serial transmission mode.(
This interface is only applicable to MyArm
) -
Return
0
: Turn off transparent transmission1
: Turn on transparent transmission, verify all data2
: Turn on transparent transmission, only verify communication forwarding mode configuration information (default is 0)
-
Prototype:
set_transponder_mode(mode)
-
Description: Set serial port transmission mode.(
This interface is only applicable to MyArm
) -
Parameters
mode
:0
: Turn off transparent transmission1
: Turn on transparent transmission, verify all data2
: Turn on transparent transmission, only verify communication forwarding mode configuration information
-
Prototype:
set_HTS_gripper_torque(torque)
-
Description: Set new adaptive gripper torque.
-
Parameters
torque (int)
: 150 ~ 980
-
Return
int
: 0 - Set failed. 1 - Set successful
-
Prototype:
get_HTS_gripper_torque()
-
Description: Get gripper torque
-
Return
int
: 150 ~ 980
-
Prototype:
get_gripper_protect_current()
-
Description: Get the gripper protection current.
-
Return
int
: 1 ~ 500
-
Prototype:
init_gripper()
-
Description: Gripper initialization.
-
Return
0
: init failed1
: init successful
-
Prototype:
set_gripper_protect_current(current)
-
Description: Set the gripper protection current.
-
Parameters
torque (int)
: 1 ~ 500
-
Prototype:
set_four_pieces_zero()
-
Description: Set the zero position of the four-piece motor.
-
Return
int
: 1 - Set successful. 0 - Set failed.
-
Prototype:
jog_rpy(end_direction, direction, speed)
-
Description: Rotate the end around a fixed axis in the base coordinate system.
-
Parameters
end_direction (int)
: Roll, Pitch, Yaw (1-3)direction (int)
: 1 - forward rotation, 0 - reverse rotationspeed (int)
: 1 ~ 100
-
Prototype:
set_void_compensate(mode)
-
Description: Set void compensation mode.
-
Parameters
mode (int)
: 0 - close, 1 - open
-
Prototype:
gpio_init()
-
Description: Init GPIO module, and set BCM mode.
-
Prototype:
gpio_output(pin, v)
-
Description: Set GPIO port output value.
-
Parameters
pin
(int
) Pin number.v
(int
): 0 / 1
from pymycobot import Angle
Description
Instance class of joint. It's recommended to use this class to select joint.
from pymycobot import Coord
Description
Instance class of coord. It's recommended to use this class to select coord.
This module support some help method.
Usage:
from pymycobot import utils
-
Prototype:
get_port_list()
-
Description: Get the all serial port list.
-
Return: serial port list (
list
)
-
Prototype:
detect_port_of_basic()
-
Description: Returns the serial port string of the first detected M5 Basic. If it is not found, it returns
None
. -
Return: detected port (
str
) orNone
-
Example:
from pymycobot import MyCobot, utils port = utils.detect_port_of_basic() if port is None: raise Exception('Detection failed.') mycobot = MyCobot(port, 115200)
Note: raspberryPi version Only supports python3 The robotic arm that uses this class of premise has a server and has been turned on.
Use TCP/IP to control the robotic arm
# demo
from pymycobot import MyCobotSocket
# Port 9000 is used by default
mc = MyCobotSocket("192.168.10.10",9000)
res = mc.get_angles()
print(res)
mc.send_angles([0,0,0,0,0,0],20)
...
Server file is in the demo folder
,For details, please check the Server.py file in the demo folder
Note: Most of the methods are the same as the class mycobot, only the new methods are listed here.
-
Prototype:
set_gpio_mode(mode)
-
Description: Set pin coding method.
-
Parameters
mode
(str
) "BCM" or "BOARD".
-
Prototype:
set_gpio_out(pin_no, mode)
-
Description: Set the pin as input or output.
-
Parameters
pin_no
(int
) pin id.mode
(str
) "in" or "out"
-
Prototype:
set_gpio_output(pin_no, state)
-
Description: Set the pin to high or low level.
-
Parameters
pin_no
(int
) pin id.state
(int
) 0 or 1
-
Prototype:
get_gpio_in(pin_no)
-
Description: Get pin level status.
-
Parameters
pin_no
(int
) pin id.
# Set up the demo of the suction pump
import time
from pymycobot import MyCobotSocket
# connect server
m = MyCobotSocket("192.168.10.10", '9000')
m.set_gpio_mode("BCM")
m.set_gpio_out(20, "out")
m.set_gpio_out(21, "out")
# open
m.set_gpio_output(20, 0)
m.set_gpio_output(21, 0)
time.sleep(3)
# close
m.set_gpio_output(20, 1)
m.set_gpio_output(21, 1)
Convert base coordinates to coordinates
-
Parameters
-
coords – a list of base coords value len 6
-
arm – 0 - left. 1 - right
-
-
Returns
coords
Collision detection main program
-
Parameters
-
left_angles – left arm angle len 6.
-
right_angles – right arm angle len 6.
-
-
Returns
int
Collision Detection Switch
-
Parameters
state (int) – 0 - close 1 - open (Off by default)
Power on designated servo
-
Parameters
-
id – 1/2/3 (L/R/W)
-
servo_id – 1 - 6
-
Read acceleration during all moves
-
Parameters
id – 1/2/3 (L/R/W)
Get the angle of a single joint
-
Parameters
-
id (int) – 1/2/3 (L/R/W).
-
joint_id (int) – 1 - 7 (7 is gripper)
-
Get the degree of all joints.
-
Parameters
id – 1/2 (L/R)
-
Returns
A float list of all degree.
-
Return type
list
Get the base coordinates of the single arm
-
Parameters
id – 1/2 (L/R)
Convert coordinates to base coordinates. Pass in parameters or no parameters
-
Parameters
-
coords – a list of coords value(List[float]), length 6 [x(mm), y, z, rx(angle), ry, rz]
-
arm – 0 - left. 1 - right
-
-
Returns
Base coords
Read a single coordinate parameter
-
Parameters
-
id (int) – 1/2/3 (L/R/W).
-
joint_id (int) – 1 - 7 (7 is gripper)
-
Get the coordinates of the robotic arm
-
Parameters
id – 1/2 (L/R).
singal value
-
Parameters
-
id – 1/2 (L/R)
-
pin_no (int) – 1 - 5
-
Obtain the specified joint potential value.
-
Parameters
-
id – 1/2/3 (L/R/W).
-
joint_id – (int) 1 ~ 6
-
-
Returns
0 ~ 4096
Get the six joints of the manipulator
-
Parameters
id – 1/2 (L/R).
-
Returns
The list of encoders
Get end coordinate system
-
Parameters
id – 0/1/2 (ALL/L/R)
-
Returns
0 - flange 1 - tool
Get the value of gripper.
-
Parameters
id – 1/2 (L/R)
-
Returns
gripper value (int)
Get Collision Current
-
Parameters
-
id – 0/1/2 (ALL/L/R)
-
joint_id – 1 - 6
-
Gets the maximum movement angle of the specified joint
-
Parameters
-
id – 1/2/3 (L/R/W)
-
joint_id – (int) 1 - 6
-
-
Returns
angle value(float)
Gets the minimum movement angle of the specified joint
-
Parameters
-
id – 1/2/3 (L/R/W)
-
joint_id – (int) 1 - 6
-
-
Returns
angle value(float)
Get movement type
-
Parameters
id – 0/1/2 (ALL/L/R)
-
Returns
1 - movel 0 - moveJ
Get planning acceleration
-
Parameters
id – 0/1/2/3 (ALL/L/R/W)
-
Returns
[movel planning acceleration, movej planning acceleration].
Get planning speed
-
Parameters
id – 0/1/2/3 (ALL/L/R/W)
-
Returns
[movel planning speed, movej planning speed].
Get the base coordinate system
-
Parameters
id – 0/1/2 (ALL/L/R)
-
Returns
0 - base 1 - tool.
Detect this robot id
-
Parameters
id – 0/1/2/3 (ALL/L/R/W)
Get cobot version
-
Parameters
id – 0/1/2/3 (ALL/L/R/W)
Get joint current
-
Parameters
id – 1/2/3 (L/R/W)
-
Returns
value mA
Read the data parameter of the specified address of the steering gear.
-
Parameters
-
id – 1/2/3 (L/R/W)
-
servo_no – Serial number of articulated steering gear, 1 - 6.
-
data_id – Data address.
-
-
Returns
values (0 - 4096) 0 - disable 1 - enable -1 - error
Get joint status
-
Parameters
id – 1/2/3 (L/R/W)
-
Returns
[voltage, sensor, temperature, current, angle, overload], a value of 0 means no error
Get joint speed
-
Parameters
id – 1/2/ (L/R)
-
Returns
list len 6
Get joint temperature
-
Parameters
id – 1/2/3 (L/R/W)
Get joint voltages
-
Parameters
id – 1/2/3 (L/R/W)
-
Returns
volts < 24 V
Get speed
-
Parameters
id – 1/2/3 (L/R/W).
-
Returns
speed
-
Return type
int
Get cobot version
-
Parameters
id – 0/1/2/3 (ALL/L/R/W)
Get tool coordinate system
-
Parameters
id – 0/1/2 (ALL/L/R)
Get the world coordinate system
-
Parameters
id – 0/1/2 (ALL/L/R)
Determine whether the specified steering gear is connected
-
Parameters
id – 1/2/3 (L/R/W)
-
Returns
0 - disable 1 - enable -1 - error
Get collision detection status
Wether connected with Atom.
-
Parameters
id – 0/1/2/3 (ALL/L/R/W)
Check if it is free mode
-
Parameters
id – 0/1/2/3 (ALL/L/R/W)
-
Returns
0/1
Judge whether the gripper is moving or not
-
Parameters
id – 1/2 (L/R)
-
Returns
0 - not moving 1 - is moving -1 - error data
Judge whether in the position.
-
Parameters
-
id – 0/1/2/3 (ALL/L/R/W).
-
data – A data list, angles or coords. If id is 1/2. data length is 6. If id is 0. data len 13. if id is 3. data len 1
-
mode – 1 - coords, 0 - angles
-
-
Returns
1 - True 0 - False -1 - Error
Detect if the robot is moving
-
Parameters
id – 0/1/2/3 (ALL/L/R/W).
-
Returns
0 - not moving 1 - is moving -1 - error data
Judge whether the manipulator pauses or not.
-
Parameters
id – 0/1/2/3 (ALL/L/R/W).
-
Returns
1 - paused 0 - not paused -1 - error
Adjust robot arm status
-
Parameters
id – 0/1/2/3 (ALL/L/R/W)
-
Returns
1 - power on 0 - power off -1 - error data
Determine whether all steering gears are connected
-
Parameters
-
id – 1/2/3 (L/R/W)
-
servo_id – (int) 1 ~ 6
-
-
Returns
0 - disable 1 - enable -1 - error
Absolute joint control
-
Parameters
-
id – 1/2/3 (L/R/W).
-
joint_id – int 1-6.
-
angle – int
-
speed – int (0 - 100)
-
Jog control angle.
-
Parameters
-
id – 1/2/3 (L/R/W).
-
joint_id – int 1-6.
-
direction – 0 - decrease, 1 - increase
-
speed – int (0 - 100)
-
Jog control coord.
-
Parameters
-
id – 1/2/3 (L/R/W).
-
coord_id – int 1-6 (x/y/z/rx/ry/rz).
-
direction – 0 - decrease, 1 - increase
-
speed – int (0 - 100)
-
Double-arm coordinated coordinate stepping
-
Parameters
-
axis – 1 - 6 (x/y/z/rx/ry/rz)
-
increment –
-
speed – 1 - 100
-
step mode
-
Parameters
-
id – 1/2/3 (L/R/W).
-
joint_id – int 1-6.
-
increment –
-
speed – int (1 - 100)
-
Stop jog moving
-
Parameters
id – 1/2/3 (L/R/W).
Make it stop when the joint is in motion, and the buffer distance is positively related to the existing speed
-
Parameters
-
id – 1/2/3 (L/R/W)
-
joint_id – 1 - 6
-
Pause movement
-
Parameters
id – 0/1/2/3 (ALL/L/R/W).
Close communication with Atom.
-
Parameters
id – 0/1/2/3 (ALL/L/R/W)
Open communication with Atom.
-
Parameters
id – 0/1/2/3 (ALL/L/R/W)
Robot Error Detection
-
Parameters
id – 0/1/2/3 (ALL/L/R/W)
Robot turns off torque output
-
Parameters
id – 0/1/2/3 (ALL/L/R/W)
Power off designated servo
-
Parameters
-
id – 1/2/3 (L/R/W)
-
servo_id – 1 - 6.
-
Recovery movement
-
Parameters
id – 0/1/2/3 (ALL/L/R/W).
Send one degree of joint to robot arm.
-
Parameters
-
id – 1/2/3 (L/R/W)
-
joint – 1 ~ 6
-
angle – int
-
speed – 1 ~ 100
-
Send all angles to the robotic arm
-
Parameters
-
id – 1/2 (L/R).
-
degrees – [angle_list] len 6
-
speed – 1 - 100
-
Send a single coordinate to the robotic arm
-
Parameters
-
id – 1/2/3 (L/R/W).
-
coord – 1 ~ 6 (x/y/z/rx/ry/rz)
-
data – Coordinate value
-
speed – 0 ~ 100
-
Send all coords to robot arm.
-
Parameters
-
id – 1/2 (L/R).
-
coords – a list of coords value(List[float]), length 6, [x(mm), y, z, rx(angle), ry, rz]
-
speed – (int) 0 ~ 100
-
mode – (int) 0 - moveJ, 1 - moveL, 2 - moveC
-
Read acceleration during all moves
-
Parameters
-
id – 1/2/3 (L/R/W)
-
acc – 1 - 100
-
Set the light color on the top of the robot arm.
-
Parameters
-
id – 1/2 (L/R)
-
r (int) – 0 ~ 255
-
g (int) – 0 ~ 255
-
b (int) – 0 ~ 255
-
Set atom IO output level
-
Parameters
-
id – 1/2 (L/R)
-
pin_no (int) – 1 - 5
-
pin_signal (int) – 0 / 1
-
Set a single joint rotation to the specified potential value.
-
Parameters
-
id – 1/2/3 (L/R/W).
-
joint_id – 1 - 6.
-
encoder – The value of the set encoder.
-
Set the six joints of the manipulator to execute synchronously to the specified position.
-
Parameters
-
id – 1/2 (L/R).
-
encoders – A encoder list, length 6.
-
speed – speed 1 ~ 100
-
Set end coordinate system
-
Parameters
-
id – 0/1/2 (ALL/L/R)
-
end – 0 - flange, 1 - tool
-
Send all encoders and speeds
-
Parameters
- encoders - (
list
) : encoders list. - speeds - Obtained by the get_servo_speeds() method
- encoders - (
set free mode
-
Parameters
-
id – 0/1/2/3 (ALL/L/R/W)
-
value – 0 - close 1 - open
-
Set command refresh mode
-
Parameters
-
id – 1/2 (L/R).
-
mode – int 1 - Always execute the latest command first. 0 - Execute instructions sequentially in the form of a queue.
-
Set the current position to zero, set current position value is 2048.
-
Parameters
id – 1/2 (L/R)
Set gripper switch state
-
Parameters
-
id – 1/2 (L/R)
-
flag (int) – 0 - close, 1 - open
-
Set gripper value
-
Parameters
-
id – 1/2 (L/R)
-
value (int) – 0 ~ 100
-
speed (int) – 0 ~ 100
-
Set Collision Current
-
Parameters
-
id – 0/1/2 (ALL/L/R)
-
joint_id – 1 - 6
-
current – current value
-
Set the joint maximum angle
-
Parameters
-
id – 1/2/3 (L/R/W)
-
joint_id – int 1-6.
-
angle – 0 ~ 180
-
Set the joint minimum angle
-
Parameters
-
id – 1/2/3 (L/R/W)
-
joint_id – int 1-6.
-
angle – 0 ~ 180
-
Set movement type
-
Parameters
-
id – 0/1/2 (ALL/L/R)
-
move_type – 1 - movel, 0 - moveJ
-
Set the state mode of the specified pin in atom.
-
Parameters
-
id – 1/2 (L/R)
-
pin_no (int) – pin number (1 - 5).
-
pin_mode (int) – 0 - input, 1 - output
-
Set planning acceleration
-
Parameters
-
id – 0/1/2/3 (ALL/L/R/W)
-
acceleration (int) – (0 ~ 100).
-
Set planning speed
-
Parameters
-
id – 0/1/2/3 (ALL/L/R/W)
-
speed (int) – (0 ~ 100).
-
Set PWM output
Set the base coordinate system
-
Parameters
-
id – 0/1/2 (ALL/L/R)
-
rftype – 0 - base 1 - tool.
-
Set this robot id
-
Parameters
-
id – 0/1/2/3 (ALL/L/R/W)
-
new_id – 1 - 253
-
The current position of the calibration joint actuator is the angle zero point,
and the corresponding potential value is 2048.
-
Parameters
-
id – 1/2/3 (L/R/W)
-
servo_no – Serial number of articulated steering gear, 1 - 6.
-
Set the data parameters of the specified address of the steering gear
-
Parameters
-
id – 1/2/3 (L/R/W)
-
servo_no – Serial number of articulated steering gear, 1 - 6.
-
data_id – Data address.
-
value – 0 - 4096
-
Set speed value
-
Parameters
-
id – 1/2/3 (L/R/W)
-
speed (int) – 0 - 100
-
Set tool coordinate system
-
Parameters
-
id – 0/1/2 (ALL/L/R)
-
coords – a list of coords value(List[float]), length 6. [x(mm), y, z, rx(angle), ry, rz]
-
Set the world coordinate system
-
Parameters
-
id – 0/1/2 (ALL/L/R)
-
coords – a list of coords value(List[float]), length 6 [x(mm), y, z, rx(angle), ry, rz]
-
Stop moving
-
Parameters
id – 0/1/2/3 (ALL/L/R/W).
Base single coordinate movement
-
Parameters
-
id – 1/2 (L/R)
-
axis – 1 - 6 (x/y/z/rx/ry/rz)
-
coord – Coordinate value
-
speed – 1 - 100
-
base coordinate move
-
Parameters
-
id – 1/2 (L/R)
-
coords – coords: a list of coords value(List[float]), length 6, [x(mm), y, z, rx(angle), ry, rz]
-
speed – 1 - 100
-
Get the radians of all joints
-
Parameters
id – 1/2 (L/R)
-
Returns
A list of float radians [radian1, …]
-
Return type
list
Send the radians of all joints to robot arm
-
Parameters
-
id – 1/2 (L/R).
-
radians – a list of radian values( List[float]), length 6
-
speed – (int )1 ~ 100
-
Set GPIO input value.
-
Parameters
pin – (int)pin number.
Init GPIO module, and set BCM mode.
-
Parameters
-
pin_no – (int)pin number.
-
mode – 0 - input 1 - output
-
Set GPIO output value.
-
Parameters
-
pin – (int)pin number.
-
v – (int) 0 / 1
-
Set GPIO PWM value.
-
Parameters
-
pin – (int)pin number.
-
baud – (int) 10 - 1000000
-
dc – (int) 0 - 100
-
API for playing emoticons
- Parameters
-
file_path -
[[path, time],...]
The absolute path of facial expression video and the length of time to play.Time in seconds. -
window_size -
(Length, width)
Size of the playback window (default is full screen). -
loop - Loop playback or not (only once by default).
-
from pymycobot import MyBuddyEmoticon
import time
# playlist
file_path = [
['/home/er/emo/look_happy.mp4', 10],
]
# Initialize the object and set it to loop playback
em = MyBuddyEmoticon(file_path, loop = True)
# Start playing
em.start()
# Pause playback after 3 seconds
# time.sleep(3)
# em.pause()
# Continue playing
# em.run()
# The main thread waits for the completion of playback
em.join()
Add Playback File
-
Parameters
path_time – [path, time] The video address to be added and the running time
Delete the element with the specified subscript in the playlist list
-
Parameters
index – The subscript of the element in the playlist to be deleted
Get Playfile List
-
Returns
list
Wait for the thread playing the video to finish
Pause playback
Continue playing
Start playing
More demo can go to here.