Coordinate control
It is mainly used to realize intelligent route planning and let the mechanical arm move from one position to another. It is divided into [x, y, z]
, where [x, y, z]
represents the position of the head of the mechanical arm in space (the coordinate system is rectangular coordinate system), The implementation of the algorithm requires some academic knowledge, and it will not be explained too much here. We can use this function as long as we understand the rectangular coordinate system.
Note: When setting coordinates, the joint structures of different series of manipulators are different. For the same set of coordinates, different series of manipulators will show different attitudes.
1 Single parameter coordinates
1.1 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 x : -260-300mm y :-300-300mm z : -130-135mmspeed
: It represents the speed of the mechanical arm movement, and the range is 0-100 (unit: mm/s).
Return value: None
- 功能: 发送单个坐标值给机械臂进行移动
- 参数说明:
id
:代表机械臂的坐标,三轴有三个坐标,有特定的表示方法。 X坐标的表示法:"X"或者"x"
.coord
: 输入您想要到达的坐标值 x : -260-300mm y :-300-300mm z : -130-135mmspeed
: 表示机械臂运动的速度,范围是0-100 (单位:mm/s)。
- 返回值: 无
482c782c42e70f0b2e44445345f6461e795f9189
2 Multi parameter coordinates
2.1 get_coords_info()
- Function: Get the current coordinates of the mechanical arm.
- Return value:
List
containing coordinates list- Triaxial:The length is 3, which is in turn
[x, y, z]
- Triaxial:The length is 3, which is in turn
2.2 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 x : -260-300mm y :-300-300mm z : -130-135mm
speed
: It represents the speed of the mechanical arm movement, and the range is 0-100 (unit: mm/s).
Return value: None
- 三轴:[x,y,z] 的坐标值,长度为3
x : -260-300mm
y :-300-300mm
z : -130-135mm
speed
: 表示机械臂运动的速度,范围是0-100 (单位:mm/s)。
- 三轴:[x,y,z] 的坐标值,长度为3
x : -260-300mm
y :-300-300mm
z : -130-135mm
- 返回值: 无
482c782c42e70f0b2e44445345f6461e795f9189
3 Case
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
# 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)
# Get the coordinates and posture of the current head
coords = ua.get_coords_info()
time.sleep(2)
print(coords)
<<<<<<< HEAD
# # Let the mechanical arm reach the coordinates [205, 0, -40], and the speed is 80 mm/s
=======
# 让机械臂到达[205, 0, -40]这个坐标,速度为80mm/s
>>>>>>> 482c782c42e70f0b2e44445345f6461e795f9189
ua.set_coords([205, 0, -40], 80)
# Set the waiting time of 2 seconds
time.sleep(2)
<<<<<<< HEAD
# Let the mechanical arm reach the coordinates [180, -50, -40], and the speed is 80mm/s
=======
# 让机械臂到达[180, -50, -40]这个坐标,速度为80mm/s
>>>>>>> 482c782c42e70f0b2e44445345f6461e795f9189
ua.set_coords([180, -50, -40], 80)
# Set the waiting time of 2 seconds
time.sleep(2)
<<<<<<< HEAD
# Only change the x-coordinate of the head, set the x-coordinate of the head to 190, and the speed to 70 mm/s
=======
# 仅改变x坐标,设置x坐标为190,速度为70mm/s
>>>>>>> 482c782c42e70f0b2e44445345f6461e795f9189
ua.set_coord(X, 190, 70)