Joint control

For serial multi joint robots, the control of joint space is aimed at the variables of each joint of the robot. The goal is to make each joint of the robot reach the target position at a certain speed.

Note: When setting the angle, the limit of different series of mechanical arms is different. For details, please refer to the parameter introduction of the corresponding model.

1 Single joint control

1.1 set_angle(id, degree, speed)

  • 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
    • speed:It represents the speed of the mechanical arm movement, ranging from 0 to 100 (unit: mms).
  • Return value: None

2 Multi joint control

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_angles(degrees, speed)

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

2.5 get_radians_info()

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

2.6 set_radians(radians, speed)

  • Function: Send radian values to all joints of the mechanical arm
  • Parameter description:
    • radians: List of radian values for each joint( List[float])
    • speed: It represents the speed of the mechanical arm movement, and the range is 0-100 (unit: mms).
  • Return value: None

3 Case

<<<<<<< HEAD

The following is the corresponding code of ultraArmP340.

以下是ultraArmP340相应代码。

482c782c42e70f0b2e44445345f6461e795f9189

  • ultraArmP340:
from pymycobot.ultraArmP340 import ultraArmP340
import time

#The above should be written at the beginning of the code, meaning to import the project package

<<<<<<< HEAD
# ultraArmP340 class initialization requires two parameters: serial port and baud rate
#   The first is the serial port string, such as:
=======
# ultraArmP340 类初始化需要两个参数:串口和波特率
#   第一个是串口字符串, 如:
>>>>>>> 482c782c42e70f0b2e44445345f6461e795f9189
#       linux: "/dev/ttyUSB0"
#       windows: "COM3"
#   The second is the baud rate:115200
#   For example:
#           linux:
#              ua = ultraArmP340("/dev/USB0", 115200)
#           windows:
#              ua = ultraArmP340("COM3", 115200)
#
<<<<<<< HEAD
# Initialize an ultraArmP340 object
# Below is to create object code for Windows version

ua = ultraArmP340("COM3", 115200)
# Ultra Arm must return to zero before performing coordinate movement and angle movement, otherwise it cannot obtain correct angle coordinates
=======
# 初始化一个ultraArmP340对象
# 下面为 windows版本创建对象代码

ua = ultraArmP340("COM3", 115200)
# ultraArmP340进行坐标运动/角度运动之前必须进行回零,否则无法获取到正确的角度/坐标
>>>>>>> 482c782c42e70f0b2e44445345f6461e795f9189
ua.go_zero()
time.sleep(0.5)

# By transferring angle parameters, each joint of the mechanical arm moves to the corresponding position of [0, 0, 0]
ua.set_angles([0, 0, 0], 50)

# Set the waiting time to ensure that the mechanical arm has reached the specified position
time.sleep(2.5)

# Move joint 1 to 90
ua.set_angle(1, 90, 50)
# Set the waiting time to ensure that the mechanical arm has reached the specified position
time.sleep(2)

# The following code can make the mechanical arm swing left and right
# Set the number of cycles
while num > 0:
    # Move joint 2 to position 45
    ua.send_angle(2, 45, 50)

    # Set the waiting time to ensure that the mechanical arm has reached the specified position
    time.sleep(3)

    # Move joint 2 to position - 15
    ua.set_angle(2, -15, 50)

    # Set the waiting time to ensure that the mechanical arm has reached the specified position
    time.sleep(3)

    num -= 1

# Let the mechanical arm retract. You can manually swing the mechanical arm, and then use the get_angles() function to obtain the coordinate array,
# This function enables the robot arm to reach the position you want.
ua.set_angles([88.68, 60, 30], 50)

# Set the waiting time to ensure that the mechanical arm has reached the specified position
time.sleep(2.5)

results matching ""

    No results matching ""