Contents
- I. Using the FR5 Robot
- 1.1 Robot Installation and Connection
- 1.2 Example Program
- II. Common FR5 Python APIs
- 2.1 Robot Basics
- 2.2 Robot Motion Control
- 2.3 Robot Parameter Settings
- 2.4 Robot Safety Settings
- 2.5 Querying Robot Status
- 2.6 Robot Kinematics
- 2.7 Gripper Configuration
- III. Using the DH-Robotics AG95 Gripper
- 3.1 RS385 Control Interface
- 3.2 Controlling the Gripper on Ubuntu
Abstract The FR5 is a 6-DoF robotic arm with a configuration similar to the UR5. This article introduces basic motion control with its Python SDK. This article is based on the official documentation.
I. Using the FR5 Robot
1.1 Robot Installation and Connection
(1) Robot installation
Install the robot, then mount and connect the gripper at the end of the robotic arm.
(2) Network configuration
The robot’s default IP address is 192.168.58.2. Change the computer’s IP address to the same subnet, such as 192.168.58.10, before connecting.
After configuring the network, enter 192.168.58.2 in a browser. If the robotic arm’s web control page opens, the connection is successful. The default username is admin, and the default password is 123. (Chrome must be used.)
(3) Python environment
This SDK program is implemented for Python 3.10, so you must create a 3.10 Python environment for it to work properly.
(4) Setting the tool coordinate system
First, open the robot’s browser-based backend, go to Initial Settings - Robot Settings - Tool Coordinates, and select toolcoord1 as the coordinate system name. (The initial default is toolcoord0; avoid modifying it if possible.) The robot’s tool coordinate system is now set to toolcoord1.
If the parameters are known—for example, if the gripper and flange coordinate systems have the same orientation and differ only by a certain distance along the Z-axis—you can set them directly to: [0, 0, 185, 0, 0, 0]
Alternatively, use six-point calibration and select the six points in sequence:
- Point 1: Specify a point in the world and keep the tool tip at that position.
- Point 2: Keep the tool tip at that position (use an orientation that differs as much as possible from the previous point).
- Point 3: Keep the tool tip at that position (use an orientation that differs as much as possible from the previous two points).
- Point 4: Keep the tool tip at that position, with the end-effector Z-axis parallel to the tool-coordinate Z-axis.
- Point 5: Move the tool tip to any point in the positive direction of the tool X-axis.
- Point 6: Move the tool tip to any point in the positive direction of the tool Y-axis.
1.2 Example Program
(1) Robot connection and basic motion
This program connects to the robot, moves it to its initial position (in this setup, the robot is installed at an angle about the Z-axis, so the initial position points the gripper downward), activates the gripper, and closes it.
import Robot
# from libfairino.utils.sdk_error import *
import numpy as np
from scipy.spatial.transform import Rotation as R
import time
###################### 机器人控制器连接测试 ######################
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error = robot.SetRobotInstallAngle(0.0,-20.0) #!!!安装角度设置应与实际一致 (错误安装角度设置会导致拖动模式下机器人失控)
print("设置机器人安装角度错误码",error)
# 查询机器人的SDK版本号
ret,version = robot.GetSDKVersion() #查询SDK版本号
if ret ==0:
print("SDK版本号为", version )
else:
print("查询失败,错误码为",ret)
###################### 机器本体运动测试 ######################
# 获取机器人的关节位置
error, joint_deg = robot.GetActualJointPosDegree()
if error == 0:
print("获取当前关节位置 (角度)", joint_deg)
else:
print("获取当前关节位置(角度)失败,错误码为", error)
error, joint_rad = robot.GetActualJointPosRadian()
if error == 0:
print("获取当前关节位置 (弧度)", joint_rad)
else:
print("获取当前关节位置(弧度)失败,错误码为", error)
# # 机器人关节空间运动
# joint_pos1 = [20., -90., 90., -90., -90., 0.]
# tool = 0 #工具坐标系编号
# user = 0 #工件坐标系编号
# error = robot.MoveJ(joint_pos1, tool, user, vel=10) #关节空间运动
# if error != 0:
# print("关节空间运动失败,错误码为", error)
# 获取机器人的工具坐标 [-432, -265, 477, 180, 0, 110]
error, tcp_pose = robot.GetActualTCPPose()
if error == 0:
print("获取当前工具坐标", tcp_pose)
else:
print("获取当前工具坐标失败,错误码为", error)
# # 机器人直线运动
# pose1 = [-432, -265, 477, 180, 0, 110]
# tool = 0 #工具坐标系编号
# user = 0 #工件坐标系编号
# error = robot.MoveL(pose1, tool, user, vel=10) #直线运动
# if error != 0:
# print("直线运动失败,错误码为", error)
# 机器人点到点运动
pose2 = [-432, -265, 477, 180, 0, 110]
tool = 0 #工具坐标系编号
user = 0 #工件坐标系编号
error = robot.MoveCart(pose2, tool, user, vel=10) #点到点运动
if error != 0:
print("点到点运动失败,错误码为", error)
# 查询机器人运动状态
error, status = robot.GetRobotMotionDone()
if error == 0:
if status == 1:
print("机器人运动已完成")
else:
print("机器人正在运动")
else:
print("查询机器人运动状态失败,错误码为", error)
###################### 机器人夹爪测试 ######################
ret = robot.SetGripperConfig(4,0) # 配置夹爪,大寰夹爪
time.sleep(1)
error, config = robot.GetGripperConfig() # 获取夹爪配置
error = robot.ActGripper(1,0) # 激活夹爪(复位)
time.sleep(1)
# error = robot.ActGripper(1,1) # 激活夹爪(激活)
# time.sleep(2)
# error = robot.MoveGripper(1,100,48,46,30000,0) # 控制夹爪(夹爪编号,位置百分比,速度百分比,力矩百分比,最大等待时间,阻塞)
# time.sleep(3)
error = robot.MoveGripper(1,0,50,0,30000,0) # 控制夹爪
time.sleep(3)
error, state = robot.GetGripperMotionDone() #获取夹爪运动状态
II. Common FR5 Python APIs
2.1 Robot Basics
2.1.1 Instantiating a Robot
RPC(ip): Instantiates a robot object.
- Parameters:
ip: The robot’s IP address. The factory-default IP is “192.168.58.2”.
- Returns
- Robot object
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
2.1.2 Querying the SDK Version
GetSDKVersion(): Queries the SDK version.
- Parameters
- Returns
- [SDK_version, Controller_version]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
ret,version = robot.GetSDKVersion() #查询SDK版本号
if ret ==0:
print("SDK版本号为", version )
else:
print("查询失败,错误码为",ret)
2.1.3 Switching Between Manual and Automatic Modes
Mode(state): Switches the robot between manual and automatic modes.
- Parameters
state: 0-automatic mode, 1-manual mode
- Returns
- Error code
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
#机器人手自动模式切换
ret = robot.Mode(0) #机器人切入自动运行模式
print("机器人切入自动运行模式", ret)
time.sleep(1)
ret = robot.Mode(1) #机器人切入手动模式
print("机器人切入手动模式", ret)
2.1.4 Enabling or Disabling the Robot
RobotEnable(state): Enables or disables the robot.
- Parameters
state: 1-enable, 0-disable
- Returns
- Error code
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
#机器人上使能或下使能
ret = robot.RobotEnable(0) #机器人下使能
print("机器人下使能", ret)
time.sleep(3)
ret = robot.RobotEnable(1) #机器人上使能,机器人上电后默认自动上使能
print("机器人上使能", ret)
2.2 Robot Motion Control
2.2.1 Robot Jogging
(1) Jog
StartJOG(ref,nb,dir,max_dis,vel=20.0,acc=100.0): Starts jogging.
- Parameters
ref: 0-joint jogging, 2-base-coordinate-system jogging, 4-tool-coordinate-system jogging, 8-workpiece-coordinate-system jogging;nb: 1-1 joint (x-axis), 2-2 joint (y-axis), 3-3 joint (z-axis), 4-4 joint (rx), 5-5 joint (ry), 6-6 joint (rz);dir: 0-negative direction, 1-positive direction;max_dis: Maximum angle/distance for a single jog, in ° or mm;vel: Velocity percentage, [0~100], default 20;acc: Acceleration percentage, [0~100], default 100;
- Returns
- Error code
(2) Decelerated stop for jogging
StopJOG(ref): Decelerates and stops jogging.
- Parameters
ref: 1-stop joint jogging, 3-stop base-coordinate-system jogging, 5-stop tool-coordinate-system jogging, 9-stop workpiece-coordinate-system jogging
- Returns
- Error code
(3) Immediate stop for jogging
ImmStopJOG(): Stops jogging immediately.
- Parameters
- Returns
- Error code
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
# 机器人单轴点动
robot.StartJOG(0,1,0,20.0,20.0,30.0) # 单关节运动,StartJOG为非阻塞指令,运动状态下接收其他运动指令(包含StartJOG)会被丢弃
time.sleep(1)
#机器人单轴点动减速停止
ret = robot.StopJOG(1)
print(ret)
#机器人单轴点动立即停止
robot.ImmStopJOG()
robot.StartJOG(0,2,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(0,3,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(0,4,1,20.0,vel=40)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(0,5,1,20.0,acc=50)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(0,6,1,20.0,20.0,30.0)
time.sleep(1)
robot.ImmStopJOG()
# 基坐标
robot.StartJOG(2,1,0,20.0) #基坐标系下点动
time.sleep(1)
# #机器人单轴点动立即停止
robot.ImmStopJOG()
robot.StartJOG(2,1,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(2,2,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(2,3,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(2,4,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(2,5,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(2,6,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
# 工具坐标
robot.StartJOG(4,1,0,20.0,20.0,100.0) #工具坐标系下点动
time.sleep(1)
# #机器人单轴点动立即停止
robot.ImmStopJOG()
robot.StartJOG(4,1,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(4,2,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(4,3,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(4,4,1,20.0,20.0,100.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(4,5,1,20.0,vel=10.0,acc=20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(4,6,1,20.0,acc=40.0)
time.sleep(1)
robot.ImmStopJOG()
# 工件坐标
robot.StartJOG(8,1,0,20.0,20.0,100.0) #工件坐标系下点动
time.sleep(1)
# #机器人单轴点动立即停止
robot.ImmStopJOG()
robot.StartJOG(8,1,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(8,2,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(8,3,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(8,4,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(8,5,1,20.0,vel=30.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(8,6,1,20.0,20.0,acc=90.0)
time.sleep(1)
robot.ImmStopJOG()
2.2.2 Joint-Space Motion
MoveJ(joint_pos, tool, user, desc_pos = [0.0,0.0,0.0,0.0,0.0,0.0], vel = 20.0, acc = 0.0, ovl = 100.0, exaxis_pos = [0.0,0.0,0.0,0.0], blendT = -1.0, offset_flag = 0, offset_pos = [0.0,0.0,0.0,0.0,0.0,0.0]): Joint-space motion
- Parameters
joint_pos: Target joint positions, in [°];tool: Tool number, [0~14];user: Workpiece number, [0~14];desc_pos: Target Cartesian pose, in [mm][°]. The default initial value is [0.0,0.0,0.0,0.0,0.0,0.0]; the default value invokes forward kinematics to obtain the return value;vel: Velocity percentage, [0~100], default 20.0;acc: Acceleration percentage, [0~100], not currently available;ovl: Velocity scaling factor, [0~100], default 100.0;exaxis_pos: Positions of external axes 1 through 4, default [0.0,0.0,0.0,0.0];blendT: [-1.0]-move into position (blocking), [0~500.0]-smoothing time (non-blocking), in [ms], default -1.0;offset_flag: [0]-no offset, [1]-offset in the workpiece/base coordinate system, [2]-offset in the tool coordinate system, default 0;offset_pos: Pose offset, in [mm][°], default [0.0,0.0,0.0,0.0,0.0,0.0];
- Returns
- Error code
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
joint_pos4 = [-83.24, -96.476, 93.688, -114.079, -62, -100]
joint_pos5 = [-43.24, -70.476, 93.688, -114.079, -62, -80]
joint_pos6 = [-83.24, -96.416, 43.188, -74.079, -80, -10]
tool = 0 #工具坐标系编号
user = 0 #工件坐标系编号
ret = robot.MoveJ(joint_pos4, tool, user, vel=30) #关节空间运动
print("关节空间运动点4:错误码", ret)
ret = robot.MoveJ(joint_pos5, tool, user)
print("关节空间运动点5:错误码", ret)
robot.MoveJ(joint_pos6, tool, user, offset_flag=1, offset_pos=[10,10,10,0,0,0])
print("关节空间运动点6:错误码", ret)
2.2.3 Cartesian-Space Linear Motion
MoveL(desc_pos, tool, user, joint_pos = [0.0,0.0,0.0,0.0,0.0,0.0], vel = 20.0, acc = 0.0 , ovl = 100.0, blendR = -1.0, exaxis_pos = [0.0,0.0,0.0,0.0], search = 0, offset_flag = 0, offset_pos = [0.0,0.0,0.0,0.0,0.0,0.0] ): Cartesian-space linear motion
- Parameters
desc_pos: Target Cartesian pose, in [mm][°];tool: Tool number, [0~14];user: Workpiece number, [0~14];joint_pos: Target joint positions, in [°]. The default initial value is [0.0,0.0,0.0,0.0,0.0,0.0]; the default value invokes inverse kinematics to obtain the return value;vel: Velocity percentage, [0~100], default 20.0;acc: Acceleration percentage, [0~100], not currently available, default 0.0;ovl: Velocity scaling factor, [0~100], default 100.0;blendR: blendR: [-1.0]-move into position (blocking), [0~1000]-smoothing radius (non-blocking), in [mm], default -1.0;exaxis_pos: Positions of external axes 1 through 4, default [0.0,0.0,0.0,0.0];search: [0]-no wire search, [1]-wire search;offset_flag: offset_flag: [0]-no offset, [1]-offset in the workpiece/base coordinate system, [2]-offset in the tool coordinate system, default 0;offset_pos: Pose offset, in [mm][°], default [0.0,0.0,0.0,0.0,0.0,0.0]
- Returns
- Error code
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
desc_pos1 = [36.794,-475.119, 65.379, -176.938, 2.535, -179.829]
desc_pos2 = [136.794,-475.119, 65.379, -176.938, 2.535, -179.829]
desc_pos3 = [236.794,-475.119, 65.379, -176.938, 2.535, -179.829]
tool = 0 #工具坐标系编号
user = 0 #工件坐标系编号
ret = robot.MoveL(desc_pos1, tool, user) #笛卡尔空间直线运动
print("笛卡尔空间直线运动点1:错误码", ret)
robot.MoveL(desc_pos2, tool, user, vel=20, acc=100)
print("笛卡尔空间直线运动点2:错误码", ret)
robot.MoveL(desc_pos3, tool, user, offset_flag=1, offset_pos=[10,10,10,0,0,0])
print("笛卡尔空间直线运动点3:错误码", ret)
2.2.4 Cartesian-Space Point-to-Point Motion
MoveCart(desc_pos, tool, user, vel = 20.0, acc = 0.0, ovl = 100.0, blendT = -1.0, config = -1): Cartesian-space point-to-point motion
- Parameters
desc_pos: Target Cartesian position;tool: Tool number, [0~14];user: Workpiece number, [0~14];vel: Velocity, range [0~100], default 20.0;acc: Acceleration, range [0~100], not currently available, default 0.0;ovl: Velocity scaling factor, [0~100], default 100.0;blendT: [-1.0]-move into position (blocking), [0~500]-smoothing time (non-blocking), in [ms], default -1.0;config: Joint configuration, [-1]-solve with reference to the current joint positions, [0~7]-solve based on the joint configuration, default -1
- Returns
- Error code
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
desc_pos7 = [236.794,-475.119, 65.379, -176.938, 2.535, -179.829]
desc_pos8 = [236.794,-575.119, 165.379, -176.938, 2.535, -179.829]
desc_pos9 = [236.794,-475.119, 265.379, -176.938, 2.535, -179.829]
tool = 0 #工具坐标系编号
user = 0 #工件坐标系编号
robot.MoveCart(desc_pos7, tool, user)
print("笛卡尔空间点到点运动点7:错误码", ret)
robot.MoveCart(desc_pos8, tool, user, vel=30)
print("笛卡尔空间点到点运动点8:错误码", ret)
robot.MoveCart(desc_pos9, tool, user,)
print("笛卡尔空间点到点运动点9:错误码", ret)
2.2.5 Servo Motion
(1) Starting servo motion
ServoMoveStart(): Starts servo motion; used together with the ServoJ and ServoCart commands.
- Parameters
- Returns
- Error code
(2) Ending servo motion
ServoMoveEnd(): Starts servo motion; used together with the ServoJ and ServoCart commands.
- Parameters
- Returns
- Error code
(3) Joint-space servo-mode motion
ServoJ(joint_pos, acc = 0.0, vel = 0.0, cmdT = 0.008, filterT = 0.0, gain = 0.0): Joint-space servo-mode motion
- Parameters
joint_pos: Target joint positions, in [°];acc: Acceleration, range [0~100], not currently available, default 0.0;vel: Velocity, range [0~100], not currently available, default 0.0;cmdT: Command transmission period, in s, recommended range [0.001~0.0016], default 0.008;filterT: Filter time, in [s], not currently available, default 0.0;gain: Proportional gain for the target position, not currently available, default 0.0;
- Returns
- Error code
(4) Cartesian-space servo-mode motion
ServoCart(mode, desc_pos, pos_gain = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0] , acc = 0.0, vel = 0.0, cmdT = 0.008, filterT = 0.0, gain = 0.0): Cartesian-space servo-mode motion
- Parameters
mode: [0]-absolute motion (base coordinate system), [1]-incremental motion (base coordinate system), [2]-incremental motion (tool coordinate system);desc_pos: Target Cartesian position/target Cartesian position increment;pos_gain: Pose-increment scaling factor, effective only during incremental motion, range [0~1], default [1.0, 1.0, 1.0, 1.0, 1.0, 1.0];acc: Acceleration, range [0~100], not currently available, default 0.0;vel: Velocity, range [0~100], not currently available, default 0.0;cmdT: Command transmission period, in s, recommended range [0.001~0.0016], default 0.008;filterT: Filter time, in [s], not currently available, default 0.0;gain: Proportional gain for the target position, not currently available, default 0.0;
- Returns
- Error code
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error,joint_pos = robot.GetActualJointPosDegree()
print("机器人当前关节位置",joint_pos)
joint_pos = [joint_pos[0],joint_pos[1],joint_pos[2],joint_pos[3],joint_pos[4],joint_pos[5]]
error_joint = 0
count =100
error = robot.ServoMoveStart() #伺服运动开始
print("伺服运动开始错误码",error)
while(count):
error = robot.ServoJ(joint_pos) #关节空间伺服模式运动
if error!=0:
error_joint =error
joint_pos[0] = joint_pos[0] + 0.1 #每次1轴运动0.1度,运动100次
count = count - 1
time.sleep(0.008)
print("关节空间伺服模式运动错误码",error_joint)
error = robot.ServoMoveEnd() #伺服运动结束
print("伺服运动结束错误码",error)
mode = 2 #[0]-绝对运动(基坐标系),[1]-增量运动(基坐标系),[2]-增量运动(工具坐标系)
n_pos = [0.0,0.0,0.5,0.0,0.0,0.0] #笛卡尔空间位姿增量
error,desc_pos = robot.GetActualTCPPose()
print("机器人当前笛卡尔位置",desc_pos)
count = 100
error_cart =0
error = robot.ServoMoveStart() #伺服运动开始
print("伺服运动开始错误码",error)
while(count):
error = robot.ServoCart(mode, n_pos, vel=40) #笛卡尔空间伺服模式运动
if error!=0:
error_cart =error
count = count - 1
time.sleep(0.008)
print("笛卡尔空间伺服模式运动错误码", error_cart)
error = robot.ServoMoveEnd() #伺服运动开始
print("伺服运动结束错误码",error)
2.3 Robot Parameter Settings
2.3.1 Setting the Global Speed
SetSpeed(vel): Sets the global speed.
- Parameters
vel: Velocity percentage, range [0~100]
- Returns
- Error code
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error = robot.SetSpeed(20)
print("设置全局速度错误码:",error)
2.3.2 Setting a System Variable Value
SetSysVarValue(id,value): Sets a system variable.
- Parameters
id: Variable number, range [1~20];value: Variable value
- Returns
- Error code
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
for i in range(1,21):
error = robot.SetSysVarValue(i,10)
robot.WaitMs(1000)
for i in range(1,21):
sys_var = robot.GetSysVarValue(i)
print("系统变量编号:",i,"值",sys_var)
2.3.3 Setting the Tool Coordinate System
(1) Computing the tool coordinate system—the six-point method
SetToolPoint(point_num): Sets a tool reference point using the six-point method.
- Parameters
point_num: Point number, range [1~6]
- Returns the error code
ComputeTool(): Computes the tool coordinate system using the six-point method (compute it after setting all six tool reference points).
- Parameters
- Returns
- Error code
tcp_pose [x,y,z,rx,ry,rz]: Tool coordinate system
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
t_coord = [1.0,2.0,3.0,4.0,5.0,6.0]
for i in range(1,7):
robot.DragTeachSwitch(1)#切入拖动示教模式
time.sleep(5)
error = robot.SetToolPoint(i) #实际应当控制机器人按照要求移动到合适位置后再发送指令
print("六点法设置工具坐标系,记录点",i,"错误码",error)
robot.DragTeachSwitch(0)
time.sleep(1)
error = robot.ComputeTool()
print("六点法设置工具坐标系错误码",error)
(2) Computing the tool coordinate system—the four-point method
SetTcp4RefPoint(point_num): Sets a tool reference point using the four-point method.
- Parameters
point_num: Point number, range [1~4]
- Returns
- Error code
ComputeTcp4(): Computes the tool coordinate system using the four-point method (compute it after setting all four tool reference points).
- Parameters
- Returns
- Error code
tcp_pose [x,y,z,rx,ry,rz]: Tool coordinate system
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
t_coord = [1.0,2.0,3.0,4.0,5.0,6.0]
for i in range(1,5):
robot.DragTeachSwitch(1)#切入拖动示教模式
time.sleep(5)
error = robot.SetTcp4RefPoint(i) #应当控制机器人按照要求移动到合适位置后再发送指令
print("四点法设置工具坐标系,记录点",i,"错误码",error)
robot.DragTeachSwitch(0)
time.sleep(1)
error,t_coord= robot.ComputeTcp4()
print("四点法设置工具坐标系错误码",error,"工具TCP",t_coord)
(3) Setting the tool coordinate system
SetToolCoord(id,t_coord,type,install): Sets the tool coordinate system.
- Parameters
id: Coordinate-system number, range [0~14];t_coord: [x,y,z,rx,ry,rz], the pose of the tool center point relative to the center of the end flange, in [mm][°];type: 0-tool coordinate system, 1-sensor coordinate system;install: Installation location, 0-robot end, 1-external to the robot
- Returns
- Error code
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
t_coord = [1.0,2.0,3.0,4.0,5.0,6.0]
error = robot.SetToolCoord(10,t_coord,0,0)
print("设置工具坐标系错误码",error)
2.3.4 Setting the External Tool Coordinate System
(1) Setting external-tool reference points
SetExTCPPoint(point_num): Sets an external-tool reference point using the three-point method.
- Parameters
point_num: Point number, range [1~3]
- Returns
- Error code
(2) Computing the external tool coordinate system
ComputeExTCF(point_num): Computes the external tool coordinate system using the three-point method (compute it after setting all three reference points).
- Parameters
point_num: Point number, range [1~3]
- Returns
- Error code
etcp [x,y,z,rx,ry,rz]: External tool coordinate system
(3) Setting the external tool coordinate system
SetExToolCoord(id,etcp ,etool): Sets the external tool coordinate system.
- Parameters
id: Coordinate-system number, range [0~14];etcp: External tool coordinate system, in [mm][°];etool: End-tool coordinate system, in [mm][°];
- Returns
- Error code
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
etcp = [1.0,2.0,3.0,4.0,5.0,6.0]
etool = [21.0,22.0,23.0,24.0,25.0,26.0]
for i in range(1,4):
error = robot.SetExTCPPoint(i) #应当控制机器人按照要求移动到合适位置后再发送指令
print("三点法设置外部工具坐标系,记录点",i,"错误码",error)
time.sleep(1)
error,etcp = robot.ComputeExTCF()
print("三点法设置外部工具坐标系错误码",error,"外部工具TCP",etcp)
error = robot.SetExToolCoord(10,etcp,etool)
print("设置外部工具坐标系错误码",error)
error = robot.SetExToolList(10,etcp,etool)
print("设置外部工具坐标系列表错误码",error)
2.3.5 Setting the Workpiece Coordinate System
(1) Setting workpiece reference points
SetWObjCoordPoint(point_num): Sets a workpiece reference point using the three-point method.
- Parameters
point_num: Point number, range [1~3]
- Returns
- Error code
(2) Computing the workpiece coordinate system
ComputeWObjCoord(): Computes the workpiece coordinate system using the three-point method (compute it after setting all three reference points;
- Parameters
method: Computation method: 0 (origin–x-axis–z-axis), 1 (origin–x-axis–xy-plane)
- Returns
- Error code
wobj_pose [x,y,z,rx,ry,rz]: Workpiece coordinate system
(3) Setting the workpiece coordinate system
SetWObjCoord(id,w_coord): Sets the workpiece coordinate system.
- Parameters
id: Coordinate-system number, range [0~14];w_coord: Relative pose of the coordinate system, in [mm][°];
- Returns
- Error code
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
w_coord = [11.0,12.0,13.0,14.0,15.0,16.0]
robot.SetToolList(0,[0,0,0,0,0,0],0,0)#设置参考点前应当将工具和工件号坐标系切换至0
robot.SetWObjList(0,[0,0,0,0,0,0])
for i in range(1,4):
error = robot.SetWObjCoordPoint(i) #实际应当控制机器人按照要求移动到合适位置后再发送指令
print("三点法设置工件坐标系,记录点",i,"错误码",error)
time.sleep(1)
error, w_coord = robot.ComputeWObjCoord(0)
print("三点法计算工件坐标系错误码",error,"工件坐标系", w_coord)
2.4 Robot Safety Settings
2.4.1 Collision Settings
(1) Setting the collision level
SetAnticollision (mode,level,config): Sets the collision level.
- Parameters
mode: 0-level, 1-percentage;level=[j1,j2,j3,j4,j5,j6]: Collision threshold;config: 0-do not update the configuration file, 1-update the configuration file
- Returns
- Error code
(2) Setting the post-collision strategy
SetCollisionStrategy (strategy): Sets the post-collision strategy.
- Parameters
strategy: 0-report an error and pause, 1-continue running
- Returns
- Error code
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
level = [1.0,2.0,3.0,4.0,5.0,6.0]
error = robot.SetAnticollision(0,level,1)
print("设置碰撞等级错误码:",error)
level = [50.0,20.0,30.0,40.0,50.0,60.0]
error = robot.SetAnticollision(1,level,1)
print("设置碰撞等级错误码:",error)
error = robot.SetCollisionStrategy(1)
print("设置碰撞后策略错误码:",error)
2.4.2 Setting Joint Limits
(1) Positive limits
SetLimitPositive(p_limit): Sets the positive limits.
- Parameters
p_limit=[j1,j2,j3,j4,j5,j6]: Six joint positions
- Returns
- Error code
(2) Negative limits
SetLimitNegative(p_limit): Sets the negative limits.
- Parameters
n_limit=[j1,j2,j3,j4,j5,j6]: Six joint positions
- Returns
- Error code
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
p_limit = [170.0,80.0,150.0,80.0,170.0,160.0]
error = robot.SetLimitPositive(p_limit)
print("设置正限位错误码:",error)
n_limit = [-170.0,-260.0,-150.0,-260.0,-170.0,-160.0]
5error = robot.SetLimitNegative(n_limit)
6print("设置负限位错误码:",error)
2.4.3 Clearing Error States
ResetAllError(): Clears error states; only resettable errors can be cleared.
- Parameters
- Returns
- Error code
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error = robot.ResetAllError()
print("错误状态清除错误码:",error)
2.5 Querying Robot Status
2.5.1 Getting Joint Positions
(1) Getting current joint positions (degrees)
GetActualJointPosDegree(flag = 1): Gets the current joint positions (degrees).
- Parameters
flag: 0-blocking, 1-non-blocking
- Returns
- Error code
joint_pos=[j1,j2,j3,j4,j5,j6]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error, joint_deg = robot.GetActualJointPosDegree()
print("获取当前关节位置 (角度)", joint_deg)
(2) Getting current joint positions (radians)
GetActualJointPosRadian(flag = 1): Gets the current joint positions (radians).
- Parameters
flag: 0-blocking, 1-non-blocking, default 1
- Returns
- Error code
joint_pos=[j1,j2,j3,j4,j5,j6]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error, joint_rad = robot.GetActualJointPosRadian()
print("获取当前关节位置 (角度)", joint_rad)
2.5.2 Getting Joint Feedback Velocities
GetActualJointSpeedsDegree(flag = 1 ): Gets joint feedback velocities (deg/s) (actual velocities).
- Parameters
flag: 0-blocking, 1-non-blocking, default 1
- Returns
- Error code
speed=[j1,j2,j3,j4,j5,j6]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
ret = robot.GetActualJointSpeedsDegree()
print("获取关节反馈速度-deg/s", ret)
2.5.3 Getting Tool-Coordinate-System Velocities
(1) TCP commanded composite speed
GetTargetTCPCompositeSpeed(flag = 1): Gets the TCP commanded composite speed (desired speed).
- Parameters
flag: 0-blocking, 1-non-blocking, default 1
- Returns
- Error code
[tcp_speed,ori_speed]: tcp_speed is the composite linear speed; ori_speed is the composite orientation speed
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
ret = robot.GetTargetTCPCompositeSpeed()
print("获取TCP指令合速度", ret)
(2) TCP feedback composite speed
GetActualTCPCompositeSpeed(flag = 1): Gets the TCP feedback composite speed (actual speed).
- Parameters
flag: 0-blocking, 1-non-blocking, default 1
- Returns
- Error code
[tcp_speed,ori_speed]: tcp_speed is the composite linear speed; ori_speed is the composite orientation speed
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
ret = robot.GetActualTCPCompositeSpeed()
print("获取TCP反馈合速度", ret)
(3) TCP commanded velocity
GetTargetTCPSpeed(flag = 1): Gets the TCP commanded velocity (desired velocity).
- Parameters
flag: 0-blocking, 1-non-blocking, default 1
- Returns
- Error code
speed: [x,y,z,rx,ry,rz]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
ret = robot.GetTargetTCPSpeed()
print("获取TCP指令速度", ret)
(4) TCP feedback velocity
GetActualTCPSpeed(flag = 1): Gets the TCP feedback velocity.
- Parameters
flag: 0-blocking, 1-non-blocking, default 1
- Returns
- Error code
speed: [x,y,z,rx,ry,rz]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
ret = robot.GetActualTCPSpeed()
print("获取TCP反馈速度", ret)
2.5.4 Getting the Tool Pose
GetActualTCPPose(flag = 1): Gets the current tool pose.
- Parameters
flag: 0-blocking, 1-non-blocking, default 1
- Returns
- Error code
tcp_pose=[x,y,z,rx,ry,rz]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
ret = robot.GetActualTCPPose()
print("获取当前工具位姿", ret)
2.5.5 Getting the End-Flange Pose
GetActualToolFlangePose(flag = 1): Gets the current end-flange pose.
- Parameters
flag: 0-blocking, 1-non-blocking, default 1
- Returns
- Error code
flange_pose=[x,y,z,rx,ry,rz]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
ret = robot.GetActualToolFlangePose()
print("获取当前末端法兰位姿", ret)
2.5.6 Getting Joint Torques
GetJointTorques(flag = 1): Gets the current joint torques.
- Parameters
flag: 0-blocking, 1-non-blocking, default 1
- Returns
- Error code
torques=[j1,j2,j3,j4,j5,j6]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
ret = robot.GetJointTorques()
print("获取当前关节转矩", ret)
2.5.7 Getting Joint Soft Limits
GetJointSoftLimitDeg(flag = 1): Gets the joint soft-limit angles.
- Parameters
flag: 0-blocking, 1-non-blocking, default 1
- Returns
- Error code
[j1min,j1max,j2min,j2max,j3min,j3max, j4min,j4max,j5min, j5max, j6min,j6max]: Negative and positive joint limits for axes 1 through 6, in [mm]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
ret = robot.GetJointSoftLimitDeg()
print("获取关节软限位角度", ret)
2.5.8 Checking Whether Robot Motion Is Complete
GetRobotMotionDone(): Checks whether robot motion is complete.
- Parameters
- Returns
- Error code
state: 0-incomplete, 1-complete
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
ret = robot.GetRobotMotionDone()
print("查询机器人运动是否完成", ret)
2.5.9 Getting DH Parameters
GetDHCompensation(): Gets the DH compensation parameters.
- Parameters
- Returns
- Error code
[cmpstD1,cmpstA2,cmpstA3,cmpstD4,cmpstD5,cmpstD6]: dhCompensation values for the robot’s DH parameters (mm)
import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error = robot.GetDHCompensation()
print(error)
2.6 Robot Kinematics
2.6.1 Forward Kinematics
GetForwardKin(joint_pos): Forward kinematics; solves for the tool pose from joint positions.
- Parameters
joint_pos: [j1,j2,j3,j4,j5,j6]: Joint positions, in [°]
- Returns
- Error code
desc_pos=[x,y,z,rx,ry,rz]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
J1=[95.442,-101.149,-98.699,-68.347,90.580,-47.174]
ret = robot.GetForwardKin(J1)
print("正运动学,关节位置求解工具位姿", ret)
2.6.2 Inverse Kinematics
(1) Solving inverse kinematics
GetInverseKin(type,desc_pos,config): Inverse kinematics; solves for joint positions from a Cartesian pose.
- Parameters
type: 0-absolute pose (base coordinate system), 1-relative pose (base coordinate system), 2-relative pose (tool coordinate system)desc_pose: [x,y,z,rx,ry,rz], tool pose, in [mm][°]
- Returns
- Error code
joint_pos=[j1,j2,j3,j4,j5,j6]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
J1=[95.442,-101.149,-98.699,-68.347,90.580,-47.174]
P1=[75.414,568.526,338.135,-178.348,-0.930,52.611]
ret = robot.GetInverseKin(0,P1,config=-1)
print("逆运动学,笛卡尔位姿求解关节位置", ret)
(2) Solving inverse kinematics (with a specified reference position)
GetInverseKinRef(type,desc_pos,joint_pos_ref): Inverse kinematics; solves for joint positions from a tool pose using the specified joint positions as a reference.
- Parameters
type: 0-absolute pose (base coordinate system), 1-relative pose (base coordinate system), 2-relative pose (tool coordinate system)desc_pos: [x,y,z,rx,ry,rz], tool pose, in [mm][°]joint_pos_ref: [j1,j2,j3,j4,j5,j6], reference joint positions, in [°]
- Returns
- Error code
joint_pos=[j1,j2,j3,j4,j5,j6]
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
J1=[95.442,-101.149,-98.699,-68.347,90.580,-47.174]
P1=[75.414,568.526,338.135,-178.348,-0.930,52.611]
ret = robot.GetInverseKinRef(0,P1,J1)
print("逆运动学,工具位姿求解关节位置,参考指定关节位置求解", ret)
(3) Solving inverse kinematics (checking whether a solution exists)
GetInverseKinHasSolution(type,desc_pos,joint_pos_ref): Inverse kinematics; checks whether a solution exists when solving for joint positions from a tool pose.
- Parameters
type: 0-absolute pose (base coordinate system), 1-relative pose (base coordinate system), 2-relative pose (tool coordinate system)desc_pos: [x,y,z,rx,ry,rz], tool pose, in [mm][°]joint_pos_ref: [j1,j2,j3,j4,j5,j6], reference joint positions, in [°]
- Returns
- Error code
result: “True”-a solution exists, “False”-no solution exists
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
J1=[95.442,-101.149,-98.699,-68.347,90.580,-47.174]
P1=[75.414,568.526,338.135,-178.348,-0.930,52.611]
ret = robot.GetInverseKinHasSolution(0,P1,J1)
print("逆运动学,工具位姿求解关节位置是否有解", ret)
2.7 Gripper Configuration
2.7.1 Configuring the Gripper
(1) Getting the gripper configuration
GetGripperConfig(): Gets the gripper configuration.
- Parameters
- Returns
- Error code
[number,company,device,softversion]: number (gripper number, range [1]); company (gripper manufacturer: 1-Robotiq, 2-Huiling, 3-Tianji, 4-DH-Robotics, 5-Zhixing); device (device number: Robotiq (0-2F-85 series), Huiling (0-NK series, 1-Z-EFG-100), Tianji (0-TEG-110), DH-Robotics (0-PGI-140), Zhixing (0-CTPM2F20)); softvesion (software version number, not currently used, default 0);
(2) Configuring the gripper
SetGripperConfig(company,device,softversion,bus): Configures the gripper.
- Parameters
company: Gripper manufacturer: 1-Robotiq, 2-Huiling, 3-Tianji, 4-DH-Robotics, 5-Zhixing;device: Device number: Robotiq (0-2F-85 series), Huiling (0-NK series, 1-Z-EFG-100), Tianji (0-TEG-110), DH-Robotics (0-PGI-140), Zhixing (0-CTPM2F20)softversion: Software version number, not currently used, default 0;bus: Device mounting position on the end bus, not currently used, default 0;
- Returns
- Error code
2.7.2 Gripper Control
Testing showed that when the gripper is connected to the robotic arm, the control box’s integrated gripper control and the robotic arm’s own servo control cause program blocking and cannot be used simultaneously. Consider connecting the gripper directly to the computer and controlling the robotic arm through RS485.
(1) Activating the gripper
ActGripper(index,action): Activates the gripper.
- Parameters
index: Gripper number;action: 0-reset, 1-activate
- Returns
- Error code
(2) Controlling the gripper
MoveGripper(index,pos,speed,force,maxtime,block): Controls the gripper.
- Parameters
index: Gripper number;pos: Position percentage, range [0~100];speed: Velocity percentage, range [0~100];force: Torque percentage, range [0~100];maxtime: Maximum wait time, range [0~30000], in [ms];block: 0-blocking, 1-non-blocking.
- Returns
- Error code
(3) Getting gripper motion status
GetGripperMotionDone(): Gets the gripper motion status.
- Parameters
- Returns
- Error code
[fault,status]: fault (0-no error, 1-error); status (0-motion incomplete, 1-motion complete)
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
desc_pos1=[-333.683,-228.968,404.329,-179.138,-0.781,91.261]
desc_pos2=[-333.683,-100.8,404.329,-179.138,-0.781,91.261]
zlength1 =10
zlength2 =15
zangle1 =10
zangle2 =15
#测试外设指令
ret = robot.SetGripperConfig(4,0) #配置夹爪
print("配置夹爪错误码", ret)
time.sleep(1)
config = robot.GetGripperConfig() #获取夹爪配置
print("获取夹爪配置",config)
error = robot.ActGripper(1,0) #激活夹爪
print("激活夹爪错误码",error)
time.sleep(1)
error = robot.ActGripper(1,1)#激活夹爪
print("激活夹爪错误码",error)
time.sleep(2)
error = robot.MoveGripper(1,100,48,46,30000,0) #控制夹爪
print("控制夹爪错误码",error)
time.sleep(3)
error = robot.MoveGripper(1,0,50,0,30000,0) #控制夹爪
print("控制夹爪错误码",error)
error = robot.GetGripperMotionDone() #获取夹爪运动状态
print("获取夹爪运动状态错误码",error)
III. Using the DH-Robotics AG95 Gripper
3.1 RS385 Control Interface
3.1.1 Default RS485 Configuration
| Parameter | Default |
|---|---|
| Gripper ID | 1 |
| Baud rate | 115200 |
| Data bits | 8 |
| Stop bits | 1 |
| Parity | None |
3.1.2 Command Format
Using the initialization command 01 06 01 00 00 01 49 F6 as an example:
| Address code | Function code | Register address | Register data | CRC checksum |
|---|---|---|---|---|
| 01 | 06 | 01 00 | 00 01 | 49 F6 |
- Address code: Indicates the gripper’s ID number; the default is 1;
- Function code: Describes the read/write operation: 03 (read register), 06 (write register);
- Register address: The address corresponding to a gripper function;
- Register data: Data written to the specified register address;
- CRC checksum: Converted from the preceding data; see http://www.ip33.com/crc.html
3.1.3 Initializing the Gripper
Initialization:
01 06 01 00 00 01 49 F6: Return to the zero position (move to the fully open limit).
01 06 01 00 00 A5 48 4D: Recalibrate + return to the zero point (close the gripper first, then open it and record the total stroke for calibration).
Meaning:
01: Gripper number06: Write register01 00: Gripper initialization register00 01/00 A5: Initialization command49 F6/48 4D: Checksum
Initialization status feedback: Checks whether initialization has been performed.
Send: 01 03 02 00 00 01 85 B2
01: Gripper number03: Read register02 00: Initialization status feedback register00 01: Initialization status feedback command85 B2: Checksum
Return: 01 03 02 00 00 B8 44
00 00: Not initialized; 1 indicates that initialization succeeded, while 2 indicates that initialization is in progress.
3.1.3 Gripper Position Control
Setting the position: Sets the gripper position. Values from 0-1000 can be written to represent the opening/closing percentage; the corresponding hexadecimal (radix 16) range is 00 00 - 03 E8.
01 06 01 03 01 F4 78 21: Sets the gripper position to 500.
01: Gripper number06: Write register01 03: Gripper position register01 F4: Set the gripper position to 50078 21: Checksum
Reading the set position: Reads the configured position.
Send: 01 03 01 03 00 01 75 F6
01: Gripper number03: Read register01 03: Gripper position register00 01: Command to read the set position75 F6: Checksum
Return: 01 03 02 xx xx crc1 crc2
xx xx: Hexadecimal (radix 16) gripper position corresponding to the gripper opening/closing percentage from 0-1000
Reading the real-time position: Reads the gripper’s real-time position.
Send: 01 03 02 02 00 01 24 72
01: Gripper number03: Read register02 02: Gripper real-time position register00 01: Command to read the real-time position24 72: Checksum
Return: 01 03 02 xx xx crc1 crc2
xx xx: Hexadecimal (radix 16) gripper position corresponding to the gripper opening/closing percentage from 0-1000
3.1.4 Gripper Status Feedback
Getting gripper motion status: Reads the gripper’s current status.
Send: 01 03 02 01 00 01 D4 72
01: Gripper number03: Read register02 01: Gripper status register00 01: Command to read gripper status24 72: Checksum
Return: 01 03 02 00 02 39 85
00 02: Indicates that an object is being held
00: The gripper is moving. 01: The gripper has stopped moving and has not detected an object. 02: The gripper has stopped moving and has detected an object. 03: The gripper detected that it was holding an object but then found that the object had fallen.
3.2 Controlling the Gripper on Ubuntu
3.2.1 Connecting the Gripper
(1) Checking the gripper’s serial port
Enter ls -l /dev/ttyUSB* on the command line. If no other USB device is connected, no output will appear.
Connect the RS485-to-USB adapter to the computer and run ls -l /dev/ttyUSB* again. A new /dev/ttyUSB0 entry will appear; this device is the gripper’s serial port.
(2) Assigning a fixed ttyUSB identifier
First, enter lsusb on the command line to check the device ID. You can unplug and reconnect the device once; the newly appearing line is the gripper device. For example, my device ID is 0403:6001, representing idVendor:idProduct, respectively.
Bus 001 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Then create and edit the configuration file with sudo vim /etc/udev/rules.d/usb.rules, and enter the following:
KERNEL=="ttyUSB*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE:="0777", SYMLINK+="dh_gripper"
Where:
KERNEL: Do not modifyATTRS{idVendor}: Enter the part before the colon in the IDATTRS{idProduct}: Enter the part after the colon in the IDMODE: The default value 0777 is sufficient and grants read, write, and execute permissionsSYMLINK: User-defined; this is the fixed name you want to assign to ttyUSB0
Restart udev:
service udev reload
service udev restart
Unplug and reconnect the device, then run ls /dev/; the port name you configured will appear.
3.2.2 Python Serial-Port Control
(1) Installing the dependency
pip install pyserial![[Equipment Guide] Controlling the FAIRINO FR5 Robotic Arm with Python](https://img.mahaofei.com/img/202404102038456.png)
Comments