Package: pymycobot
This is Python API for ElephantRobotics productThis is a python API for serial communication with mycobot and controlling it.InstallationNotes:Make sure thatAtomis flashed into the top Atom,Transponderis flashed into the base Basic.The firmwareAtomandTransponderdownload address:https://github.com/elephantrobotics/myCobot/tree/main/SoftwareYou also can use myStudio to flash them, myStudio address:https://github.com/elephantrobotics/myStudio/releasesPippipinstallpymycobot--upgradeSource codegitclonehttps://github.com/elephantrobotics/pymycobot.git<your-path>cd<your-path>/pymycobot# Install[sudo]python2setup.pyinstall# or[sudo]python3setup.pyinstallOr the more modern form:# Install
pip install .
# Uninstall
pip uninstall .

## Usage:

```python
from pymycobot import MyCobot, Angle, Coord
from pymycobot import PI_PORT, PI_BAUD # For raspberry pi version of mycobot.Thedemodirectory stores some test case files.You can find out which interfaces pymycobot provides inpymycobot/README.md.Please go tohere.pymycobotThis is python API for ElephantRobotics productWe support Python2, Python3.5 or later.Catalogue:pymycobotMyCobot / Mypalletizer / MechArm / MyArmOverall statuspower_onpower_offis_power_onread_next_errorrelease_all_servosis_controller_connectedget_error_informationclear_error_informationMDI mode and operationget_anglesset_fresh_mode(mode)get_fresh_mode()send_anglesend_angles()get_radianssend_radiansget_coordssend_coordsend_coordssync_send_anglessync_send_coordsis_in_positionis_movingJOG mode and operationjog_anglejog_coordjog_absolutejog_incrementjog_stoppauseresumestopis_pausedset_encoderget_encoderset_encodersget_encodersRunning status and Settingsget_speedset_speedset_joint_minset_joint_maxget_joint_min_angleget_joint_max_angleServo controlis_servo_enableis_all_servo_enableset_servo_dataget_servo_dataset_servo_calibrationrelease_servofocus_servoAtom IOset_colorset_pin_modeset_digital_output()get_digital_input()set_pwm_output()set_gripper_calibrationget_gripper_valueset_gripper_stateset_gripper_valueis_gripper_movingget_basic_inputset_basic_outputset_ssid_pwdget_ssid_pwdset_server_portget_tof_distanceget_tool_referenceset_tool_referenceset_world_referenceget_world_referenceset_reference_frameget_reference_frameset_movement_typeget_movement_typeset_end_typeget_end_typeget_plan_speedget_plan_accelerationset_plan_speedset_plan_accelerationmove_roundget_basic_versionset_transponder_modeget_servo_speedsget_servo_currentsget_servo_voltagesget_servo_statusget_servo_tempsinit_eletric_gripperset_eletric_gripperset_gripper_modeget_gripper_modeset_encoders_dragget_solution_anglesset_solution_anglesjoint_brakeget_transponder_modeset_transponder_modeset_HTS_gripper_torqueget_HTS_gripper_torqueget_gripper_protect_currentinit_gripperset_gripper_protect_currentset_four_pieces_zeroRaspberry pi -- GPIOgpio_initgpio_outputAngleCoordutils (Module)get_port_listdetect_port_of_basicMyCobotSocketClientServersocket controlset_gpio_modeset_gpio_outset_gpio_outputget_gpio_inMyBuddybase_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)MyBuddyEmoticonMyBuddyEmoticon(file_path: list = [], window_size: tuple = [], loop=False)add_file_path(path_time: list)del_file_path(index: int)file_pathjoin()pause()run()start()MyCobot / Mypalletizer / MechArm / MyArmImport to your project:# for mycobotfrompymycobotimportMyCobot# for mypalletizer# from pymycobot import MyPalletizer# for MechArm# from pymycobot import MechArmmc=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 valueOverall statuspower_onPrototype:power_on()Description:Atom open communication (default open).power_offPrototype:power_off()Description: Atom turn off communication.is_power_onPrototype:is_power_on()Description: Adjust robot arm whether power on.Returns1: power on0: power off-1: errorread_next_errorPrototype:read_next_error()Description: Robot Error Detection.Returnslist len 70: No abnormality1: Communication disconnected2: Unstable communication3: Servo abnormalityrelease_all_servosPrototype:release_all_servos()Description: Set robot arm into free moving mode.is_controller_connectedPrototype:is_controller_connected()Description: Check if connected with Atom.Returns1: connected0: not connected-1: errorget_error_informationPrototype:get_error_information()Description: Obtaining robot error information.Returns0: 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.clear_error_informationPrototype:clear_error_information()Description: Clear robot error message.MDI mode and operationget_anglesPrototype:get_angles()Description: Get the degree of all joints.Returns:list: A float list of all degree.set_fresh_mode(mode)Set command refresh modeParametersmode– int
1 - Always execute the latest command first.
0 - Execute instructions sequentially in the form of a queue.get_fresh_mode()get command refresh modereturn1 - Always execute the latest command first.0 - Execute instructions sequentially in the form of a queue.send_anglePrototype:send_angles(id, degree, speed)Description: Send one degree of joint to robot arm.Parametersid: Joint id(genre.Angle) / int 1-7degree: degree value(float) (about -170 ～ 170)speed: (int) 0 ~ 100Examplefrompymycobot.mycobotimportMyCobotfrompymycobot.genreimportAnglemycobot=MyCobot('/dev/ttyUSB0')mycobot.send_angle(Angle.J2.value,10,50)send_angles()Prototype:send_angles(degrees, speed)Description: Send the degrees of all joints to robot arm.Parametersdegrees: a list of degree value(List[float]), length 7.speed: (int) 0 ~ 100Examplefrompymycobot.mycobotimportMyCobotfrompymycobot.genreimportAnglemycobot=MyCobot('/dev/ttyUSB0')mycobot.send_angles([0,0,0,0,0,0],80)get_radiansPrototype:get_radians()Description: Get the radians of all joints.Returns:list: A float list of radian.send_radiansPrototype: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 ~ 100Examplefrompymycobot.mycobotimportMyCobotfrompymycobot.genreimportAnglemycobot=MyCobot('/dev/ttyUSB0')mycobot.send_angles_by_radian([1,1,1,1,1,1],70)get_coordsPrototype: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]send_coordPrototype:send_coords(id, coord, speed)Description: Send one coord to robot arm.Parametersid: coord id(genre.Coord) / int 1-6coord: coord value(float)speed: (int) 0 ~ 100Examplefrompymycobot.mycobotimportMyCobotfrompymycobot.genreimportCoordmycobot=MyCobot('/dev/ttyUSB0')mycobot.send_coord(Coord.X.value,-40,70)send_coordsPrototype:send_coords(coords, speed, mode)Description: Send all coords to robot arm.Parameterscoords: a list of coords value(List[float]).speed: (int) 0 ~ 100mode: (int):0- angular,1- linearExamplefrompymycobot.mycobotimportMyCobotfrompymycobot.genreimportCoordmycobot=MyCobot('/dev/ttyUSB0')mycobot.send_coords([160,160,160,0,0,0],70,0)sync_send_anglesPrototype:sync_send_angles(degrees, speed, timeout=15)Description: Send the angle in synchronous state and return when the target point is reachedParametersdegrees: a list of degree value(List[float]).speed: (int) 0 ~ 100timeout: default 7s.sync_send_coordsPrototype:sync_send_coords(coords, speed, mode, timeout=15)Description: Send the coord in synchronous state and return when the target point is reachedParameterscoords: a list of coords value(List[float])speed: (int) 0 ~ 100mode: (int):0- angular,1- lineartimeout: default 7s.is_in_positionPrototype:is_in_position(data, flag)Description: Judge whether in the position.Parametersdata: A data list, angles or coords.flag: Tag the data type,0- angles,1- coords.Returns1- true0- false-1- erroris_movingPrototype:is_moving()Description: Detect if the robot is moving.Returns1- is moving0- not moving-1- error dataJOG mode and operationjog_anglePrototype:jog_angle(joint_id, direction, speed)Description: Jog control angleParametersjoint_id: (int) 1 ~ 6direction:0- decrease,1- increasespeed: 0 ~ 100jog_coordPrototype:jog_coord(coord_id, direction, speed)Description: Jog control coord.Parameterscoord_id: (int) 1 ~ 6direction:0- decrease,1- increasespeed: 0 ~ 100jog_absolutePrototype:jog_absolute(joint_id, angle, speed)Description: Jog absolute angle.Parametersjoint_id: (int)for mycobot / mecharm: int 1-6.for mypalletizer: int 1-4.for myArm: int 1 - 7.direction:speed: 0 ~ 100jog_incrementPrototype:jog_increment(coord_id, direction, speed)Description: Step mode.Parameterscoord_id: (int)for mycobot / mecharm: int 1-6.for mypalletizer: int 1-4.for myArm: int 1 - 7.direction:speed: 0 ~ 100jog_stopPrototype:jog_stop()Description: Stop jog moving.pausePrototype:pause()Description: Pause movement.resumePrototype:resume()Description: Recovery movement.stopPrototype:stop()Description: Stop moving.is_pausedPrototype:is_paused()Description: Judge whether the manipulator pauses or not.Returns:1- paused0- not paused-1- errorset_encoderPrototype:set_encoder(joint_id, encoder)Description: Set a single joint rotation to the specified potential value.Parametersjoint_id: (int)for mycobot / mecharm: int 1-6.for mypalletizer: int 1-4.for myArm: int 1 - 7.encoder: 0 ~ 4096get_encoderPrototype: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 ~ 4096set_encodersPrototype: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 - 100get_encodersPrototype:get_encoders()Description: Get the six joints of the manipulator.Returns: the list of encoder (list)Running status and Settingsget_speedPrototype:get_speed()Description: Get speed.Returns: speed: (int)set_speedPrototype:set_speed(speed)Description: Set speed.Parameters: speed: (int) 0 ~ 100set_joint_minPrototype: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.set_joint_maxPrototype:set_joint_max(id, angle)Description: Sets the maximum angle of the specified joint.Parameters:id: (int) joint idfor mycobot / mecharm: int 1-6.for mypalletizer: int 1-4.for myArm: int 1 - 7.angle: 0 - 180.get_joint_min_anglePrototype:get_joint_min_angle()Description: Gets the minimum movement angle of the specified jointParameters:joint_id: (int)for mycobot / mecharm: int 1-6.for mypalletizer: int 1-4.for myArm: int 1 - 7.Returns: angle value (float)get_joint_max_anglePrototype:get_joint_max_angle()Description: Gets the maximum movement angle of the specified jointParameters:joint_id: (int)for mycobot / mecharm: int 1-6.for mypalletizer: int 1-4.for myArm: int 1 - 7.Returns: angle value (float)Servo controlis_servo_enablePrototype:is_servo_enable(servo_id)Description: Determine whether all steering gears are connectedParameters:servo_id(int)for mycobot / mecharm: int 1-6.for mypalletizer: int 1-4.for myArm: int 1 - 7.Returns0: disable1: enable-1: erroris_all_servo_enablePrototype:is_all_servo_enable()Description: Determine whether the specified steering gear is connectedReturns0: disable1: enable-1: errorset_servo_dataPrototype: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.get_servo_dataPrototype: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: errorset_servo_calibrationPrototype: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.release_servoPrototype:release_servo(servo_id)Description: Power off designated servoParameters:servo_id:for mycobot / mecharm: int 1-6.for mypalletizer: int 1-4.for myArm: int 1 - 7.focus_servoPrototype:focus_servo(servo_id)Description: Power on designated servoParameters:servo_id:for mycobot / mecharm: int 1-6.for mypalletizer: int 1-4.for myArm: int 1 - 7.Atom IOset_colorPrototype:set_color(r, g, b)Description: Set the color of the light on the top of the robot arm.Parametersr: 0 ~ 255g: 0 ~ 255b: 0 ~ 255set_pin_modePrototype:set_pin_mode(pin_no, pin_mode)Description: Set the state mode of the specified pin in atom.Parameterspin_no(int): Pin number.pin_mode(int): 0 - input, 1 - output, 2 - input_pullupset_digital_output()Set the terminal atom io statusParameterspin_no(int):pin_signal(int): 0 / 1get_digital_input()Parameters:pin_no(int)Return: signal valueset_pwm_output()Prototype:set_pwm_output(channel, frequency, pin_val)Description: PWM control.Parameterschannel(int): IO number.frequency(int): clock frequencypin_val(int): Duty cycle 0 ~ 256; 128 means 50%set_gripper_calibrationPrototype:set_gripper_calibration()Description: Set the current position to zero, set current position value is2048.get_gripper_valuePrototype:get_gripper_value(gripper_type=None)Description: Get gripper valueParametersgripper_type(int):1 - Adaptive gripper.3 - Parallel gripper, this parameter can be omitted, default to adaptive gripper4 - Flexible gripperReturn: gripper value (int)set_gripper_statePrototype:set_gripper_state(flag, speed, _type_1=None)Description: Set gripper switch stateParametersflag(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 gripper4 - Flexible gripperset_gripper_valuePrototype:set_gripper_value(value, speed, gripper_type=None)Description: Set gripper valueParametersvalue(int): 0 ~ 100speed(int): 0 ~ 100gripper_type(int):1 - Adaptive gripper3 - Parallel gripper, this parameter can be omitted, default to adaptive gripper4 - Flexible gripperis_gripper_movingPrototype:is_gripper_moving()Description: Judge whether the gripper is moving or notReturns0: not moving1: is moving-1: error dataget_basic_inputPrototype:get_basic_input(pin_no)Description: Get bottom pin.Parameterspin_no(int) Pin number.Return:pin_signal(int) 0 / 1set_basic_outputPrototype:set_basic_output(pin_no, pin_signal)Description: Set bottom pin.Parameterspin_no(int) Pin number.pin_signal(int): 0 / 1set_ssid_pwdPrototype:set_ssid_pwd(account, password)Description: Change connected wifi.(Apply to m5 or seeed)Parametersaccount(str) new wifi account.password(str): new wifi password.get_ssid_pwdPrototype:get_ssid_pwd()Description: Get connected wifi account and password.(Apply to m5 or seeed)Return:(account, password).set_server_portPrototype:set_server_port(port)Description: Change the connection port of the server.Parametersport: (int) The new connection port of the server.get_tof_distancePrototype:get_tof_distance()Description: Get the detected distance (Requires external distance detector).Return:intThe unit is mm.get_tool_referencePrototype:get_tool_reference()Description: Get tool coordinate system.Return:list[x, y, z, rx, ry, rz].set_tool_referencePrototype:set_tool_reference(coords)Description: Set tool coordinate system.Parameters:coords: (list) [x, y, z, rx, ry, rz].set_world_referencePrototype:set_world_reference(coords)Description: Set world coordinate system.Parameters:coords: (list) [x, y, z, rx, ry, rz].get_world_referencePrototype:get_world_reference()Description: Get world coordinate system.Return:list[x, y, z, rx, ry, rz].set_reference_framePrototype:set_reference_frame(rftype)Description: Set base coordinate system.Parameters:rftype: 0 - base 1 - tool.get_reference_framePrototype:get_reference_frame()Description: Get base coordinate system.Return: 0 - base 1 - tool.set_movement_typePrototype:set_movement_type(move_type)Description: Set movement type.Parameters:move_type: 1 - movel, 0 - moveJ.get_movement_typePrototype:get_movement_type()Description: Get movement type.Return: 1 - movel, 0 - moveJ.set_end_typePrototype:set_end_type(end)Description: Set end coordinate system.Parameters:end:  0 - flange, 1 - tool.get_end_typePrototype:get_end_type()Description: Get end coordinate system.Return: 0 - flange, 1 - tool.get_plan_speedPrototype:get_plan_speed()Description: Get planning speed.Return: [movel planning speed,movej planning speed].get_plan_accelerationPrototype:get_plan_acceleration()Description: Get planning acceleration.Return: [movel planning acceleration,movej planning acceleration].set_plan_speedPrototype:set_plan_speed(speed, is_linear)Description: Set planning speed.Parametersspeed(int) 0 - 100.is_linear(int): 0 / 1 (0 ->joint, 1 -> line)set_plan_accelerationPrototype:set_plan_acceleration(acceleration, is_linear)Description: Set planning acceleration.Parametersacceleration(int) 0 - 100.is_linear(int): 0 / 1 (0 ->joint, 1 -> line)move_roundPrototype:move_round(angle)Description: Drive the 9g steering gear clockwise for one revolution.Parametersangle(int) 0 - 255.
0 : stop
255 : Keep turning
1 ~ 254: Based on 30° (1->30°, 2->60°)get_basic_versionPrototype:get_basic_version()Description: Get basic firmware version.Returnversion(float)set_transponder_modePrototype:set_transponder_mode(mode)Description: Set basic communication mode.Parametersmode(int) 0 -  Turn off transparent transmission. 1 - Open transparent transmissionget_servo_speedsPrototype:get_servo_speeds()Description: Get joint velocity.Return:listSpeed of each joint.get_servo_currentsPrototype:get_servo_currents()Description: Get joint current.Return:listCurrent of each joint.get_servo_voltagesPrototype:get_servo_voltages()Description: Get joint voltage.Return:listVoltage of each joint.get_servo_statusPrototype:get_servo_status()Description: Get the state of each joint.Return:listthe state of each joint.get_servo_tempsPrototype:get_servo_temps()Description: Get the temperature of each joint.Return:listtemperature of each joint.init_eletric_gripperPrototype:init_eletric_gripper()Description: Electric gripper initialization (it needs to be initialized once after inserting and removing the gripper) (only for 350)set_eletric_gripperPrototype:set_eletric_gripper(status)Description: Set Electric Gripper Mode (only for 350).Parametersstatus(int): 0 - open, 1 - close.set_gripper_modePrototype:set_gripper_mode(status)Description: Set gripper mode.Parametersstatus(int): 0 - transparent transmission. 1 - Port Mode.get_gripper_modePrototype:get_gripper_mode()Description: Get gripper mode.Returnstatus(int): 0 - transparent transmission. 1 - Port Mode.set_encoders_dragPrototype:set_encoders_drag(encoders, speeds)Description: Send all encoders and speedsParametersencoders(list) : encoders list.speeds: Obtained by the get_servo_speeds() methodget_solution_anglesPrototype:get_solution_angles()Description: Get zero space deflection angle value.(This interface is only applicable to MyArm)set_solution_anglesPrototype:set_solution_angles(angle, speed)Description: Set zero space deflection angle value.(This interface is only applicable to MyArm)Parametersangle: Angle of joint 1.speed: 1 - 100.joint_brakePrototype:joint_brake(joint_id)Description: Make it stop when the joint is in motion, and the buffer distance is positively related to the existing speedParametersjoint_id: 1 - 7.get_transponder_modePrototype:get_transponder_mode()Description: Obtain the configuration information of serial transmission mode.(This interface is only applicable to MyArm)Return0: 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)set_transponder_modePrototype:set_transponder_mode(mode)Description: Set serial port transmission mode.(This interface is only applicable to MyArm)Parametersmode:0: Turn off transparent transmission1: Turn on transparent transmission, verify all data2: Turn on transparent transmission, only verify communication forwarding mode configuration informationset_HTS_gripper_torquePrototype:set_HTS_gripper_torque(torque)Description: Set new adaptive gripper torque.Parameterstorque (int): 150 ~ 980Returnint: 0 - Set failed. 1 - Set successfulget_HTS_gripper_torquePrototype:get_HTS_gripper_torque()Description: Get gripper torqueReturnint: 150 ~ 980get_gripper_protect_currentPrototype:get_gripper_protect_current()Description: Get the gripper protection current.Returnint: 1 ~ 500init_gripperPrototype:init_gripper()Description: Gripper initialization.Return0: init failed1: init successfulset_gripper_protect_currentPrototype:set_gripper_protect_current(current)Description: Set the gripper protection current.Parameterstorque (int): 1 ~ 500set_four_pieces_zeroPrototype:set_four_pieces_zero()Description: Set the zero position of the four-piece motor.Returnint: 1 - Set successful. 0 - Set failed.Raspberry pi -- GPIOgpio_initPrototype:gpio_init()Description: Init GPIO module, and set BCM mode.gpio_outputPrototype:gpio_output(pin, v)Description: Set GPIO port output value.Parameterspin(int) Pin number.v(int): 0 / 1AnglefrompymycobotimportAngleDescriptionInstance class of joint. It's recommended to use this class to select joint.CoordfrompymycobotimportCoordDescriptionInstance class of coord. It's recommended to use this class to select coord.utils (Module)This module support some help method.Usage:frompymycobotimportutilsget_port_listPrototype:get_port_list()Description: Get the all serial port list.Return: serial port list (list)detect_port_of_basicPrototype:detect_port_of_basic()Description: Returns the serial port string of the first detected M5 Basic. If it is not found, it returnsNone.Return: detected port (str) orNoneExample:frompymycobotimportMyCobot,utilsport=utils.detect_port_of_basic()ifportisNone:raiseException('Detection failed.')mycobot=MyCobot(port,115200)MyCobotSocketNote:
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 armClient# demofrompymycobotimportMyCobotSocket# Port 9000 is used by defaultmc=MyCobotSocket("192.168.10.10","9000")res=mc.get_angles()print(res)mc.send_angles([0,0,0,0,0,0],20)...ServerServer file is in thedemo folder,For details, please check theServer.pyfile in the demo foldersocket controlNote:
Most of the methods are the same as the class mycobot, only the new methods are listed here.set_gpio_modePrototype:set_gpio_mode(mode)Description: Set pin coding method.Parametersmode(str) "BCM" or "BOARD".set_gpio_outPrototype:set_gpio_out(pin_no, mode)Description: Set the pin as input or output.Parameterspin_no(int) pin id.mode(str) "in" or "out"set_gpio_outputPrototype:set_gpio_output(pin_no, state)Description: Set the pin to high or low level.Parameterspin_no(int) pin id.state(int) 0 or 1get_gpio_inPrototype:get_gpio_in(pin_no)Description: Get pin level status.Parameterspin_no(int) pin id.# Set up the demo of the suction pumpimporttimefrompymycobotimportMyCobotSocket# connect serverm=MyCobotSocket("192.168.10.10",'9000')m.set_gpio_mode("BCM")m.set_gpio_out(20,"out")m.set_gpio_out(21,"out")# openm.set_gpio_output(20,0)m.set_gpio_output(21,0)time.sleep(3)# closem.set_gpio_output(20,1)m.set_gpio_output(21,1)MyBuddybase_to_single_coords(base_coords, arm)Convert base coordinates to coordinatesParameterscoords– a list of base coords value len 6arm– 0 - left. 1 - rightReturnscoordscollision(left_angles, right_angles)Collision detection main programParametersleft_angles– left arm angle len 6.right_angles– right arm angle len 6.Returnsintcollision_switch(state)Collision Detection SwitchParametersstate(int) – 0 - close 1 - open (Off by default)focus_servo(id, servo_id)Power on designated servoParametersid– 1/2/3 (L/R/W)servo_id– 1 - 6get_acceleration(id)Read acceleration during all movesParametersid– 1/2/3 (L/R/W)get_angle(id, joint_id)Get the angle of a single jointParametersid(int) – 1/2/3 (L/R/W).joint_id(int) – 1 - 7 (7 is gripper)get_angles(id)Get the degree of all joints.Parametersid– 1/2 (L/R)ReturnsA float list of all degree.Return typelistget_base_coord(id)Get the base coordinates of the single armParametersid– 1/2 (L/R)get_base_coords(*args: int)Convert coordinates to base coordinates. Pass in parameters or no parametersParameterscoords– a list of coords value(List[float]), length 6 [x(mm), y, z, rx(angle), ry, rz]arm– 0 - left. 1 - rightReturnsBase coordsget_coord(id, joint_id)Read a single coordinate parameterParametersid(int) – 1/2/3 (L/R/W).joint_id(int) – 1 - 7 (7 is gripper)get_coords(id)Get the coordinates of the robotic armParametersid– 1/2 (L/R).get_digital_input(id, pin_no)singal valueParametersid– 1/2 (L/R)pin_no(int) – 1 - 5get_encoder(id, joint_id)Obtain the specified joint potential value.Parametersid– 1/2/3 (L/R/W).joint_id– (int) 1 ~ 6Returns0 ~ 4096get_encoders(id)Get the six joints of the manipulatorParametersid– 1/2 (L/R).ReturnsThe list of encodersget_end_type(id)Get end coordinate systemParametersid– 0/1/2 (ALL/L/R)Returns0 - flange
1 - toolget_gripper_value(id)Get the value of gripper.Parametersid– 1/2 (L/R)Returnsgripper value (int)get_joint_current(id, joint_id)Get Collision CurrentParametersid– 0/1/2 (ALL/L/R)joint_id– 1 - 6get_joint_max_angle(id, joint_id)Gets the maximum movement angle of the specified jointParametersid– 1/2/3 (L/R/W)joint_id– (int) 1 - 6Returnsangle value(float)get_joint_min_angle(id, joint_id)Gets the minimum movement angle of the specified jointParametersid– 1/2/3 (L/R/W)joint_id– (int) 1 - 6Returnsangle value(float)get_movement_type(id)Get movement typeParametersid– 0/1/2 (ALL/L/R)Returns1 - movel
0 - moveJget_plan_acceleration(id=0)Get planning accelerationParametersid– 0/1/2/3 (ALL/L/R/W)Returns[movel planning acceleration, movej planning acceleration].get_plan_speed(id=0)Get planning speedParametersid– 0/1/2/3 (ALL/L/R/W)Returns[movel planning speed, movej planning speed].get_reference_frame(id)Get the base coordinate systemParametersid– 0/1/2 (ALL/L/R)Returns0 - base 1 - tool.get_robot_id(id)Detect this robot idParametersid– 0/1/2/3 (ALL/L/R/W)get_robot_version(id)Get cobot versionParametersid– 0/1/2/3 (ALL/L/R/W)get_servo_currents(id)Get joint currentParametersid– 1/2/3 (L/R/W)Returnsvalue mAget_servo_data(id, servo_no, data_id)Read the data parameter of the specified address of the steering gear.Parametersid– 1/2/3 (L/R/W)servo_no– Serial number of articulated steering gear, 1 - 6.data_id– Data address.Returnsvalues (0 - 4096)
0 - disable
1 - enable
-1 - errorget_servo_status(id)Get joint statusParametersid– 1/2/3 (L/R/W)Returns[voltage, sensor, temperature, current, angle, overload], a value of 0 means no errorget_servo_spees(id)Get joint speedParametersid– 1/2/ (L/R)Returnslist len 6get_servo_temps(id)Get joint temperatureParametersid– 1/2/3 (L/R/W)get_servo_voltages(id)Get joint voltagesParametersid– 1/2/3 (L/R/W)Returnsvolts < 24 Vget_speed(id)Get speedParametersid– 1/2/3 (L/R/W).ReturnsspeedReturn typeintget_system_version(id)Get cobot versionParametersid– 0/1/2/3 (ALL/L/R/W)get_tool_reference(id)Get tool coordinate systemParametersid– 0/1/2 (ALL/L/R)get_world_reference(id)Get the world coordinate systemParametersid– 0/1/2 (ALL/L/R)is_all_servo_enable(id)Determine whether the specified steering gear is connectedParametersid– 1/2/3 (L/R/W)Returns0 - disable
1 - enable
-1 - erroris_collision_on()Get collision detection statusis_controller_connected(id=0)Wether connected with Atom.Parametersid– 0/1/2/3 (ALL/L/R/W)is_free_mode(id)Check if it is free modeParametersid– 0/1/2/3 (ALL/L/R/W)Returns0/1is_gripper_moving(id)Judge whether the gripper is moving or notParametersid– 1/2 (L/R)Returns0 - not moving
1 - is moving
-1 - error datais_in_position(id, data, mode)Judge whether in the position.Parametersid– 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 1mode– 1 - coords, 0 - anglesReturns1 - True
0 - False
-1 - Erroris_moving(id)Detect if the robot is movingParametersid– 0/1/2/3 (ALL/L/R/W).Returns0 - not moving
1 - is moving
-1 - error datais_paused(id)Judge whether the manipulator pauses or not.Parametersid– 0/1/2/3 (ALL/L/R/W).Returns1 - paused
0 - not paused
-1 - erroris_power_on(id=0)Adjust robot arm statusParametersid– 0/1/2/3 (ALL/L/R/W)Returns1 - power on
0 - power off
-1 - error datais_servo_enable(id, servo_id)Determine whether all steering gears are connectedParametersid– 1/2/3 (L/R/W)servo_id– (int) 1 ~ 6Returns0 - disable
1 - enable
-1 - errorjog_absolute(id, joint_id, angle, speed)Absolute joint controlParametersid– 1/2/3 (L/R/W).joint_id– int 1-6.angle– intspeed– int (0 - 100)jog_angle(id, joint_id, direction, speed)Jog control angle.Parametersid– 1/2/3 (L/R/W).joint_id– int 1-6.direction– 0 - decrease, 1 - increasespeed– int (0 - 100)jog_coord(id, coord_id, direction, speed)Jog control coord.Parametersid– 1/2/3 (L/R/W).coord_id– int 1-6 (x/y/z/rx/ry/rz).direction– 0 - decrease, 1 - increasespeed– int (0 - 100)jog_inc_coord(axis, increment, speed)Double-arm coordinated coordinate steppingParametersaxis– 1 - 6 (x/y/z/rx/ry/rz)increment–speed– 1 - 100jog_increment(id, joint_id, increment, speed)step modeParametersid– 1/2/3 (L/R/W).joint_id– int 1-6.increment–speed– int (1 - 100)jog_stop(id)Stop jog movingParametersid– 1/2/3 (L/R/W).joint_brake(id, joint_id)Make it stop when the joint is in motion, and the buffer distance is positively related to the existing speedParametersid– 1/2/3 (L/R/W)joint_id– 1 - 6pause(id)Pause movementParametersid– 0/1/2/3 (ALL/L/R/W).power_off(id=0)Close communication with Atom.Parametersid– 0/1/2/3 (ALL/L/R/W)power_on(id=0)Open communication with Atom.Parametersid– 0/1/2/3 (ALL/L/R/W)read_next_error(id=0)Robot Error DetectionParametersid– 0/1/2/3 (ALL/L/R/W)release_all_servos(id=0)Robot turns off torque outputParametersid– 0/1/2/3 (ALL/L/R/W)release_servo(id, servo_id)Power off designated servoParametersid– 1/2/3 (L/R/W)servo_id– 1 - 6.resume(id)Recovery movementParametersid– 0/1/2/3 (ALL/L/R/W).send_angle(id, joint, angle, speed)Send one degree of joint to robot arm.Parametersid– 1/2/3 (L/R/W)joint– 1 ~ 6angle– intspeed– 1 ~ 100send_angles(id, degrees, speed)Send all angles to the robotic armParametersid– 1/2 (L/R).degrees– [angle_list] len 6speed– 1 - 100send_coord(id, coord, data, speed)Send a single coordinate to the robotic armParametersid– 1/2/3 (L/R/W).coord– 1 ~ 6 (x/y/z/rx/ry/rz)data– Coordinate valuespeed– 0 ~ 100send_coords(id, coords, speed, mode)Send all coords to robot arm.Parametersid– 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 ~ 100mode– (int) 0 - moveJ, 1 - moveL, 2 - moveCset_acceleration(id, acc)Read acceleration during all movesParametersid– 1/2/3 (L/R/W)acc– 1 - 100set_color(id, r=0, g=0, b=0)Set the light color on the top of the robot arm.Parametersid– 1/2 (L/R)r(int) – 0 ~ 255g(int) – 0 ~ 255b(int) – 0 ~ 255set_digital_output(id, pin_no, pin_signal)Set atom IO output levelParametersid– 1/2 (L/R)pin_no(int) – 1 - 5pin_signal(int) – 0 / 1set_encoder(id, joint_id, encoder, speed)Set a single joint rotation to the specified potential value.Parametersid– 1/2/3 (L/R/W).joint_id– 1 - 6.encoder– The value of the set encoder.set_encoders(id, encoders, speed)Set the six joints of the manipulator to execute synchronously to the specified position.Parametersid– 1/2 (L/R).encoders– A encoder list, length 6.speed– speed 1 ~ 100set_end_type(id, end)Set end coordinate systemParametersid– 0/1/2 (ALL/L/R)end– 0 - flange, 1 - toolset_encoders_drag(id, encoders, speeds)Send all encoders and speedsParametersencoders- (list) : encoders list.speeds- Obtained by the get_servo_speeds() methodset_free_mode(id, value)set free modeParametersid– 0/1/2/3 (ALL/L/R/W)value– 0 - close 1 - openset_fresh_mode(id, mode)Set command refresh modeParametersid– 1/2 (L/R).mode– int
1 - Always execute the latest command first.
0 - Execute instructions sequentially in the form of a queue.set_gripper_calibration(id)Set the current position to zero, set current position value is 2048.Parametersid– 1/2 (L/R)set_gripper_state(id, flag)Set gripper switch stateParametersid– 1/2 (L/R)flag(int) – 0 - close, 1 - openset_gripper_value(id, value, speed)Set gripper valueParametersid– 1/2 (L/R)value(int) – 0 ~ 100speed(int) – 0 ~ 100set_joint_current(id, joint_id, current)Set Collision CurrentParametersid– 0/1/2 (ALL/L/R)joint_id– 1 - 6current– current valueset_joint_max(id, joint_id, angle)Set the joint maximum angleParametersid– 1/2/3 (L/R/W)joint_id– int 1-6.angle– 0 ~ 180set_joint_min(id, joint_id, angle)Set the joint minimum angleParametersid– 1/2/3 (L/R/W)joint_id– int 1-6.angle– 0 ~ 180set_movement_type(id, move_type)Set movement typeParametersid– 0/1/2 (ALL/L/R)move_type– 1 - movel, 0 - moveJset_pin_mode(id, pin_no, pin_mode)Set the state mode of the specified pin in atom.Parametersid– 1/2 (L/R)pin_no(int) – pin number (1 - 5).pin_mode(int) – 0 - input, 1 - outputset_plan_acceleration(id, acceleration)Set planning accelerationParametersid– 0/1/2/3 (ALL/L/R/W)acceleration(int) – (0 ~ 100).set_plan_speed(id, speed)Set planning speedParametersid– 0/1/2/3 (ALL/L/R/W)speed(int) – (0 ~ 100).set_pwm_output()Set PWM outputset_reference_frame(id, rftype)Set the base coordinate systemParametersid– 0/1/2 (ALL/L/R)rftype– 0 - base 1 - tool.set_robot_id(id, new_id)Set this robot idParametersid– 0/1/2/3 (ALL/L/R/W)new_id– 1 - 253set_servo_calibration(id, servo_no)The current position of the calibration joint actuator is the angle zero point,and the corresponding potential value is 2048.Parametersid– 1/2/3 (L/R/W)servo_no– Serial number of articulated steering gear, 1 - 6.set_servo_data(id, servo_no, data_id, value)Set the data parameters of the specified address of the steering gearParametersid– 1/2/3 (L/R/W)servo_no– Serial number of articulated steering gear, 1 - 6.data_id– Data address.value– 0 - 4096set_speed(id, speed)Set speed valueParametersid– 1/2/3 (L/R/W)speed(int) – 0 - 100set_tool_reference(id, coords)Set tool coordinate systemParametersid– 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_world_reference(id, coords)Set the world coordinate systemParametersid– 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(id)Stop movingParametersid– 0/1/2/3 (ALL/L/R/W).write_base_coord(id, axis, coord, speed)Base single coordinate movementParametersid– 1/2 (L/R)axis– 1 - 6 (x/y/z/rx/ry/rz)coord– Coordinate valuespeed– 1 - 100write_base_coords(id, coords, speed)base coordinate moveParametersid– 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 - 100get_radians(id)Get the radians of all jointsParametersid– 1/2 (L/R)ReturnsA list of float radians [radian1, …]Return typelistsend_radians(id, radians, speed)Send the radians of all joints to robot armParametersid– 1/2 (L/R).radians– a list of radian values( List[float]), length 6speed– (int )1 ~ 100set_gpio_input(pin)Set GPIO input value.Parameterspin– (int)pin number.set_gpio_mode(pin_no, mode)Init GPIO module, and set BCM mode.Parameterspin_no– (int)pin number.mode– 0 - input 1 - outputset_gpio_output(pin, v)Set GPIO output value.Parameterspin– (int)pin number.v– (int) 0 / 1set_gpio_pwm(pin, baud, dc)Set GPIO PWM value.Parameterspin– (int)pin number.baud– (int) 10 - 1000000dc– (int) 0 - 100MyBuddyEmoticonMyBuddyEmoticon(file_path: list = [], window_size: tuple = [], loop=False)API for playing emoticonsParametersfile_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).frompymycobotimportMyBuddyEmoticonimporttime# playlistfile_path=[['/home/er/emo/look_happy.mp4',10],]# Initialize the object and set it to loop playbackem=MyBuddyEmoticon(file_path,loop=True)# Start playingem.start()# Pause playback after 3 seconds# time.sleep(3)# em.pause()# Continue playing# em.run()# The main thread waits for the completion of playbackem.join()add_file_path(path_time: list)Add Playback FileParameterspath_time– [path, time] The video address to be added and the running timedel_file_path(index: int)Delete the element with the specified subscript in the playlist listParametersindex– The subscript of the element in the playlist to be deletedfile_pathGet Playfile ListReturnslistjoin()Wait for the thread playing the video to finishpause()Pause playbackrun()Continue playingstart()Start playingMore demo can go tohere.