Detailed Description of API Method

When using the following function interfaces, please import our API library at the beginning, otherwise the operation cannot succeed, that is, enter the following code:

from pymycobot.ultraArmP340 import ultraArmP340

<<<<<<< HEAD

Note: If our API library is not installed, please refer to Python environment setup section to install。

注意: 若没有安装我们的API库,请参考 README.md 文档进行安装。

482c782c42e70f0b2e44445345f6461e795f9189

1 Overall operation state of mechanical arm

1.1 go_zero()

  • Function: The mechanical arm returns to zero.
  • Return value: None

1.2 power_on()

  • Function: All joints of the mechanical arm are powered on.
  • Return value: None

1.3 release_all_servos()

  • Function: Power failure of all joints of mechanical arm
  • Return value: None

1.4 is_moving_end()

<<<<<<< HEAD

  • Function: Robot movement end flag
  • Return value:
    • 1: Movement end
    • 0: Movement not end

  • 功能: 机械臂运动结束标志
  • 返回值:
    • 1: 运动结束
    • 0: 运动未结束

1.5 set_system_value(id, address, value, mode=None)

  • 功能: 设置系统参数
  • 参数说明:
    • id: int, 电机ID,4 或者 7
    • address: int, 参数寄存器地址,7 ~ 69
    • value: int, 对应寄存器参数取值
    • mode: int, 1 或者 2,可以为空,默认模式为1
      • 1: 设置范围为0-255,可使用地址21(P值)
      • 2: 设置取值范围0-65535,可使用地址56(设置位置)
  • 返回值:

1.6 get_system_value(id, address, mode=None)

  • 功能: 读取系统参数
  • 参数说明:
    • id: int, 电机ID,4 或者 7
    • address: int, 参数寄存器地址,0 ~ 69
    • mode: int, 1 或者 2,可以为空,默认模式为1
      • 1: 读取范围为0-255,可使用地址21(P值)
      • 2: 读取取值范围0-65535,可使用地址56(读取位置)
  • 返回值: int, 对应寄存器参数取值

1.7 get_system_version()

  • 功能: 读取固件主次版本

  • 返回值: float, 固件版本号

1.8 get_modify_version()

  • 功能: 读取固件更正版本号

  • 返回值: int, 更正版本号

    482c782c42e70f0b2e44445345f6461e795f9189

1.5 set_system_value(id, address, value, mode=None)

  • Function: Set system parameters
  • Parameter description:
    • id: int, Motor ID, 4 or 7
    • address: int, Parameter register address, 7 ~ 69
    • value: int, Corresponding register parameter value
    • mode: int, 1 or 2, can be empty, default mode is 1
      • 1: setting range is 0-255, address 21 (P value) can be used
      • 2: setting value range is 0-65535, address 56 (setting position) can be used
  • Return value: None

1.6 get_system_value(id, address,mode=None)

  • Function: Read system parameters
  • Parameter description:
    • id: int, Motor ID, 4 or 7
    • address: int, Parameter register address, 0 ~ 69
    • mode: int, 1 or 2, can be empty, default mode is 1
      • 1: read range is 0-255, address 21 (P value) can be used
      • 2: read value range is 0-65535, address 56 (read position) can be used
  • Return value: int, Corresponding register parameter value

1.7 get_system_version()

  • Function: Read the firmware major and minor versions

  • Return value: float, firmware version number

1.8 get_modify_version()

  • Function: Read the firmware modified version number

  • Return value: int, modified version number

2 Input program control mode (MDI mode)

Note:The limit of different series of mechanical arms is different, and the attitude value can be set is also different. For details, see the parameter introduction of the corresponding model

2.1 get_angles_info()

  • Function: Get the current angle of the mechanical arm.
  • Return value: list a list of floating point values representing the angles of all joints

2.2 set_angle(id, degree, speed)

<<<<<<< HEAD

  • Function: Send the specified single joint motion to the specified angle
  • Parameter description:

    • id: Represents the joint of the mechanical arm. The three axes have three joints, which can be represented by the number 1-3.
    • degree: Represents the angle of the joint

      <tr>
          <th>Joint Id</th>
          <th>Range</th>
      

      =======

  • 功能: 发送指定的单个关节运动至指定的角度
  • 参数说明:

    • id: 代表机械臂的关节,三轴有三个关节,可以用数字1-3来表示。
    • degree: 表示关节的角度

      >>>>>>> 482c782c42e70f0b2e44445345f6461e795f9189 <<<<<<< HEAD ======= >>>>>>> 482c782c42e70f0b2e44445345f6461e795f9189
      关节 Id 范围
      1 -150 ~ 170
      2 -20 ~ 90
      3 -5 ~ 110
      4(Accessories)4(配件) -179 ~ 179

<<<<<<< HEAD

  • speed:It represents the speed of the mechanical arm movement, ranging from 0 to 200 (unit: mm/s).
    • Return value: None

2.3 set_angles(degrees, speed)

  • Function: Send all angles to all joints of the mechanical arm
  • Parameter description:
    • degrees: (List[float]) include angles of all joints ,the three-axis robot has three joints, so the length is 3, and the representation method is: [20, 20, 20]
    • speed: It represents the speed of the mechanical arm movement, and the value range is 0-200 (unit: mm/s).
  • Return value: None

2.4 get_coords_info()

  • Function: Get the current coordinates of the mechanical arm.
  • Return value: list include list of coordinates, θ is Rotation angle at the end

    - Triaxial:The length is 3, which is in turn [x, y, z, θ]

    • speed:表示机械臂运动的速度,范围0~200 (单位:mm/s)。
  • 返回值:

2.3 set_angles(degrees, speed)

  • 功能: 发送所有角度给机械臂所有关节
  • 参数说明:
    • degrees: (List[float])包含所有关节的角度 ,三轴机器人有三个关节,所以长度为3,表示方法为:[20,20,20]
    • speed: 表示机械臂运动的速度,取值范围是0~200 (单位:mm/s)。
  • 返回值:

2.4 get_coords_info()

  • 功能: 获取机械臂当前坐标。
  • 返回值: list包含坐标的列表, θ 为末端的旋转角
    • 三轴:长度为 4,依次为 [x, y, z, θ]

      482c782c42e70f0b2e44445345f6461e795f9189

2.5 set_coord(id,coord,speed)

<<<<<<< HEAD

  • Function: Send a single coordinate value to the mechanical arm for movement
  • Parameter description:

    • id:Represents the coordinates of the mechanical arm. The three axes have three coordinates and have a specific representation method. Representation of X coordinate:"X"or"x".
    • coord: Enter the coordinate value you want to reach

      <tr>
          <th>Coord Id</th>
          <th>Range</th>
      

      =======

  • 功能: 发送单个坐标值给机械臂进行移动
  • 参数说明:

    • id:代表机械臂的坐标,三轴有三个坐标,有特定的表示方法。 X坐标的表示法:"X"或者"x".
    • coord: 输入您想要到达的坐标值

      >>>>>>> 482c782c42e70f0b2e44445345f6461e795f9189
      坐标 Id 范围
      x -360 ~ 365.55
      y -365.55 ~ 365.55
      z -140 ~ 130

<<<<<<< HEAD

  • speed: It represents the speed of the mechanical arm movement, and the range is 0-200 (unit: mm/s).

    - Return value: None

  • speed: 表示机械臂运动的速度,范围是0-200 (单位:mm/s)。
    • 返回值:

      482c782c42e70f0b2e44445345f6461e795f9189

2.6 set_coords(coords, speed)

  • Function: Send the overall coordinates so that the head of the mechanical arm moves from the original point to the point you specify.
  • Parameter description:
    • coords: <<<<<<< HEAD
      • Triaxial:The coordinate value of [x, y, z], with a length of 3
    • speed: It represents the speed of the mechanical arm movement, and the range is 0-200 (unit: mm/s).
  • Return value: None

    • 三轴:[x,y,z] 的坐标值,长度为3
      • speed: 表示机械臂运动的速度,范围是0-200 (单位:mm/s)。
  • 返回值:

    482c782c42e70f0b2e44445345f6461e795f9189

2.7 get_radians_info()

  • Function: Get the current radian value of the mechanical arm.
  • Return value: List list containing all joint radian values

2.8 set_radians(radians, speed)

<<<<<<< HEAD

  • Function: Send radian values to all joints of the mechanical arm
  • Parameter Description

    • radians: List of radian values for each joint( List[float])

      <tr>
          <th>Joint Id</th>
          <th>Range</th>
      

      =======

  • 功能: 发送弧度值给机械臂所有关节
  • 参数说明:

    • radians: 每个关节的弧度值列表( List[float])

      >>>>>>> 482c782c42e70f0b2e44445345f6461e795f9189 <<<<<<< HEAD ======= >>>>>>> 482c782c42e70f0b2e44445345f6461e795f9189
      关节 Id 范围
      1 2.6179 ~ 2.9670
      2 -0.3490 ~ 1.5707
      3 -0.0872 ~ 1.9198
      4 (Accessories)4(配件) -3.1241 ~ + 3.1241

<<<<<<< HEAD

  • speed: It represents the speed of the mechanical arm movement, and the range is 0-200 (unit: mm/s).

    - Return value: None

  • speed: 表示机械臂运动的速度,范围是0-200 (单位:mm/s)。
    • 返回值:

      482c782c42e70f0b2e44445345f6461e795f9189

2.9 set_mode()

  • Function: Set Coordinate Mode
  • Parameter Description
    • 0:Absolute Cartesian mode
    • 1:Relative Cartesian mode
  • Return value: None

2.10 sleep()

  • Function: Delay
  • Parameter Description
    • Time: Time delayed( Inttype),
  • Return value: None

2.12 set_init_pose()

<<<<<<< HEAD

  • Function: Set the current position as a fixed position,for example(0,0,0),set this position to zero
  • Parameter Description
    • coords: All coordinates of mechanical arm
    • speed: It represents the speed of the mechanical arm movement, and the range is 0-200 (unit: mm/s).
  • Return value: None

  • 功能: 设置当前位置为某个固定位置。如(0,0,0)就把这个位置设为零点
  • 参数说明:
    • coords: 机械臂所有坐标
    • speed: 表示机械臂运动的速度,范围是0-200 (单位:mm/s)。
  • 返回值:

    482c782c42e70f0b2e44445345f6461e795f9189

2.13 set_pwm()

  • Function: Set PWM duty cycle
  • Parameter description: P:Duty cycle,Range: 0-255
  • Return value: None

2.14 set_fan_state()

  • Function: Set Fan Status
  • Parameter Description
    • 0: close
    • 1: open
  • Return value: None

2.15 get_switch_state()

  • Function: Get limit switch status
  • Parameter Description
    • X:Whether joint 3 reaches the limit position
    • Y:Whether joint 2 reaches the limit position
    • Z:Whether joint 1 reaches the limit position
  • Return value: Yes

2.16 set_speed_mode(mode)

  • Function: Set speed mode
  • Parameter Description
    • 0: Uniform speed mode
    • 2: Acceleration and deceleration mode
  • Return value: None

3 JOG mode and operation

3.1 set_jog_angle(id, direction, speed)

<<<<<<< HEAD

  • Function: Set inching mode (angle)
  • Parameter Description
    • id: Represents the joint of the mechanical arm, which is represented by 1~3 joint id
    • direction: It mainly controls the moving direction of the machine arm. Input 0 is negative move and input 1 is positive move
    • speed: Speed 0~200 (unit: mm/s)
  • Return value: None

3.2 set_jog_coord(axis, direction, speed)

  • Function: Control the robot to move continuously according to the specified coordinates or attitude values
  • Parameter Description
    • axis: Represents the joint of the mechanical arm, which is represented by the x/y/z given by the axis of the joint
    • direction: It mainly controls the moving direction of the machine arm. Input 0 is negative move and input 1 is positive move
    • speed: Speed 0~200 (unit: mm/s)
  • Return value: None

  • 功能: 设置点动模式(角度)
  • 参数说明:
    • id: 代表机械臂的关节,按照关节id给入1~3来表示
    • direction: 主要控制机器臂移动的方向,给入0 为负值移动,给入1为正值移动
    • speed: 速度 0 ~ 200 (单位:mm/s)。
  • 返回值:

3.2 set_jog_coord(axis, direction, speed)

  • 功能: 控制机器人按照指定的坐标或姿态值持续移动
  • 参数说明:
    • axis: 代表机械臂的关节,按照关节axis给入x/y/z来表示
    • direction: 主要控制机器臂移动的方向,给入0 为负值移动,给入1为正值移动
    • speed: 速度 0 ~ 200 (单位:mm/s)。
  • 返回值:

    482c782c42e70f0b2e44445345f6461e795f9189

3.3 set_jog_stop()

  • Function: Stop continuous movement under the control of jog
  • Return value: None

4 IO control

4.1 set_gpio_state(state)

<<<<<<< HEAD

  • Function: Set suction pump status
  • Parameter Description
    • state (int):Input 1 indicates that the suction pump is started, and input 0 indicates that the suction pump is closed
  • Return value: None

  • 功能: 设置 吸泵状态。
  • 参数说明:
    • state (int):输入1表示开启吸泵,输入0表示关闭吸泵。
  • 返回值:

    482c782c42e70f0b2e44445345f6461e795f9189

4.2 set_gripper_zero()

  • Function: Set gripper zero position(Set the current position to zero)
  • Return value: None

4.3 set_gripper_state(state):

  • Function: Set gripper switch
  • Parameter Description state:Input 0 to open the gripper, and input 1 to close the gripper
  • Return value: None

4.4 get_gripper_angle():

<<<<<<< HEAD

  • 功能: 获取夹爪角度
  • 返回值: 夹爪角度值

    482c782c42e70f0b2e44445345f6461e795f9189

  • Function: Get the gripper angle

  • Return value: Gripper angle value

5 Functional interface

5.1 play_gcode_file(filename)

  • Function: Play imported track files
  • Parameter description:
    • filename :Track file name
  • Return value: None

6 Use Cases

import time
import platform
from pymycobot.ultraArmP340 import ultraArmP340

# Automatically select the system and connect the mechanical arm
if platform.system() == "Windows":
    ua = ultraArmP340('COM6', 115200)
    ua.go_zero()
elif platform.system() == "Linux":
    ua = ultraArmP340('/dev/ttyUSB0', 115200)
    ua.go_zero()

# Position of mechanical arm movement
angles = [
    [-81.71, 0.0, 0.0],
    [-90.53, 21.77, 47.56],
    [-90.53, 0.0, 0.0],
    [-59.01, 21.77, 45.84],
    [-59.01, 0.0, 0.0]
]

# Suck small pieces
ua.set_angles(angles[0], 50)
time.sleep(3)
ua.set_angles(angles[1], 50)
time.sleep(3)

# Start suction pump
ua.set_gpio_state(0)

ua.set_angles(angles[2], 50)
time.sleep(3)
ua.set_angles(angles[3], 50)

# Close the suction pump
ua.set_gpio_state(1)
time.sleep(3)

ua.set_angles(angles[4], 50)

results matching ""

    No results matching ""