3、Safety control of th robot arm

Introduction of API

1、is_power_on()

Function: Determine whether the robot arm is powered.

Return calue:1 indicates powered,0 indicates outage,-1 indicates an error

2、power_on()

Function: Power the robot arm

3、power_off()

Function: Power is lost to the robot arm and all functions will fail.

Note: The robot arm cannot be relaxed after outage,meansset_free_mode() is invalid.

4、pause()

Function: Pause the movement of the robot arm.

5、resume()

Function: Restore the movement of the robot arm.

6、stop()

Function: The robot arm stops moving

7、is_in_position(data,flag)

Function: Determines whether the robot arm has reached the specified position

Parameter Description:

data:A list collection of six elements, representing an angle collection, or a collection of robot arm head data.

flag:1 Represents the head data of the robot arm,0 Represents the angle collection data of the robot arm.

8、is_paused()

Function: Determine if the robot arm is suspended

Return value:1 indicates a pause, 0 indicates that it is not paused, and -1 indicates an error.

Content of code

from pymycobot.mycobot import MyCobot
from pymycobot import PI_PORT, PI_BAUD  # When using the Raspberry Pi version of myCobot, you can refer to these two variables for MyCobot initialization
import time

# Initialize a MyCobot object
mc = MyCobot(PI_PORT, PI_BAUD)
# Determine whether the robot arm is powered or not, and if there is no power supply, it needs to be powered first
if not mc.is_power_on():
    # Power the robot arm
    mc.power_on()
# The robot arm arrive at position[0,0,0,0,0,0] at 30 speeds
mc.send_angles([0, 0, 0, 0, 0, 0], 30)
# Get the current time
start = time.time()
# Check whether the robot arm has arrived at the position [0,0,0,0,0,0] or not
while not mc.is_in_position([0, 0, 0, 0, 0, 0], 0):
    # Restore the robot arm movement
    mc.resume()
    # Let the robot arm move 0.5s
    time.sleep(0.5)
    # Pause the robot arm movement
    mc.pause()
    # Determine if the movement timed out
    if time.time() - start > 9:
        # Stop movement of the robot arm 
        mc.stop()
        break
# Get the current time
start = time.time()
# The robot arm arrive at position[88.68, -138.51, 155.65, -128.05, -9.93, -15.29] at 30 speeds
mc.send_angles([88.68, -138.51, 155.65, -128.05, -9.93, -15.29], 30)
# Check whether the robot arm has arrived at the position [88.68, -138.51, 155.65, -128.05, -9.93, -15.29] or not
while not mc.is_in_position([88.68, -138.51, 155.65, -128.05, -9.93, -15.29], 0):
    # Restore the movement of the robot arm
    mc.resume()
    # Let the robot arm move 0.5s
    time.sleep(0.5)
    # Pause the movement of the robot arm You can use is_paused() to check whether the robot arm is in a pause state or not.
    mc.pause()
    # Check if the movement timed out
    if time.time() - start > 9:
        mc.stop()
        # Stop the movement of the robot arm
        break
# Power off the robot arm after operation
mc.power_off()

Effects as shown

2

results matching ""

    No results matching ""