from fairino import Robot
import time
robot = Robot.RPC('192.168.58.2')
rtn = robot.JointSensitivityEnable(0)
rtn = robot.JointSensitivityEnable(1)
print(f"JointSensitivityEnable rtn is {rtn}")
curJPos = [0.0] * 6
rtn, curJPos = robot.GetActualJointPosDegree(0)
epos = [0.0] * 4
offset_pos = [0.0] * 6
jointPos1 = [curJPos[0], 0.0, 0.0, -90.0, 0.02, curJPos[5]]
descPos1 = [0.0] * 6
rtn, descPos1 = robot.GetForwardKin(jointPos1)
robot.MoveJ(joint_pos=jointPos1, desc_pos=descPos1, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.2)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 1 rtn is {rtn}")
time.sleep(0.1)
jointPos2 = [curJPos[0], -30.0, 0.0, -90.0, 0.02, curJPos[5]]
descPos2 = [0.0] * 6
rtn, descPos2 = robot.GetForwardKin(jointPos2)
robot.MoveJ(joint_pos=jointPos2, desc_pos=descPos2, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.1)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 2 rtn is {rtn}")
time.sleep(0.1)
jointPos3 = [curJPos[0], -60.0, 0.0, -90.0, 0.02, curJPos[5]]
descPos3 = [0.0] * 6
rtn, descPos3 = robot.GetForwardKin(jointPos3)
robot.MoveJ(joint_pos=jointPos3, desc_pos=descPos3, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.1)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 3 rtn is {rtn}")
time.sleep(0.1)
jointPos4 = [curJPos[0], -90.0, 0.0, -90.0, 0.02, curJPos[5]]
descPos4 = [0.0] * 6
rtn, descPos4 = robot.GetForwardKin(jointPos4)
robot.MoveJ(joint_pos=jointPos4, desc_pos=descPos4, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.1)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 4 rtn is {rtn}")
time.sleep(0.1)
jointPos5 = [curJPos[0], -120.0, 0.0, -90.0, 0.02, curJPos[5]]
descPos5 = [0.0] * 6
rtn, descPos5 = robot.GetForwardKin(jointPos5)
robot.MoveJ(joint_pos=jointPos5, desc_pos=descPos5, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.1)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 5 rtn is {rtn}")
time.sleep(0.1)
jointPos6 = [curJPos[0], -150.0, 0.0, -90.0, 0.02, curJPos[5]]
descPos6 = [0.0] * 6
rtn, descPos6 = robot.GetForwardKin(jointPos6)
robot.MoveJ(joint_pos=jointPos6, desc_pos=descPos6, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.1)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 6 rtn is {rtn}")
time.sleep(0.1)
jointPos7 = [curJPos[0], -180.0, 0.0, -90.0, 0.02, curJPos[5]]
descPos7 = [0.0] * 6
rtn, descPos7 = robot.GetForwardKin(jointPos7)
robot.MoveJ(joint_pos=jointPos7, desc_pos=descPos7, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.1)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 7 rtn is {rtn}")
time.sleep(0.1)
robot.MoveJ(joint_pos=jointPos6, desc_pos=descPos6, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.1)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 8 rtn is {rtn}")
time.sleep(0.1)
robot.MoveJ(joint_pos=jointPos5, desc_pos=descPos5, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.1)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 9 rtn is {rtn}")
time.sleep(0.1)
robot.MoveJ(joint_pos=jointPos4, desc_pos=descPos4, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.1)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 10 rtn is {rtn}")
time.sleep(0.1)
robot.MoveJ(joint_pos=jointPos3, desc_pos=descPos3, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.1)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 11 rtn is {rtn}")
time.sleep(0.1)
robot.MoveJ(joint_pos=jointPos2, desc_pos=descPos2, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.1)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 12 rtn is {rtn}")
time.sleep(0.1)
robot.MoveJ(joint_pos=jointPos1, desc_pos=descPos1, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
time.sleep(0.2)
rtn = robot.JointSensitivityCollect()
print(f"JointSensitivityCollect 13 rtn is {rtn}")
time.sleep(0.1)
calibResult = [0.0] * 6
linearity = [0.0] * 6
rtn,calibResult, linearity = robot.JointSensitivityCalibration()
print(f"JointSensitivityCalibration rtn is {rtn}")
rtn = robot.JointSensitivityEnable(0)
print(f"JointSensitivityEnable rtn is {rtn}")
print(f"jointSensor Calib result is {calibResult[0]},{calibResult[1]},{calibResult[2]},{calibResult[3]},{calibResult[4]},{calibResult[5]}")
print( f"jointSensor linearity is {linearity[0]},{linearity[1]},{linearity[2]},{linearity[3]},{linearity[4]},{linearity[5]}")
hysteresisError = [0.0] * 6
rtn,hysteresisError = robot.JointHysteresisError()
print(f"JointHysteresisError result is {hysteresisError[0]},{hysteresisError[1]},{hysteresisError[2]},{hysteresisError[3]},{hysteresisError[4]},{hysteresisError[5]}")
repeatability = [0.0] * 6
rtn,repeatability = robot.JointRepeatability()
print(f"JointRepeatability result is {repeatability[0]},{repeatability[1]},{repeatability[2]},{repeatability[3]},{repeatability[4]},{repeatability[5]}")
M = [1.0] * 6
B = [1.0] * 6
K = [0.0] * 6
threshold = [1.0] * 6
setZeroFlag = 1
rtn = robot.SetAdmittanceParams(M, B, K, threshold, calibResult, setZeroFlag)
print(f"SetAdmittanceParams rtn is {rtn}")
robot.CloseRPC()
6.60. The number of error frames at eight slave ports of the robot is obtained
New in version python: SDK-v2.1.7
Prototype | GetSlavePortErrCounter() |
Description | The number of error frames at eight slave ports of the robot is obtained |
Mandatory parameters | NULL |
Default parameters | NULL |
Return Value |
|
6.61. Slave port error frame reset
New in version python: SDK-v2.1.7
Prototype | JointSensitivityEnable(slaveID) |
Description | Slave port error frame reset |
Mandatory parameters |
|
Default parameters | NULL |
Return Value | Error Code Success-0 Failure- errcode |
6.62. Get sample slave port error frame code
from fairino import Robot
import time
import threading
# Establish a connection with the robot controller and return a robot object if the connection is successful
robot = Robot.RPC('192.168.58.2')
inRecvErr = [0] * 8
inCRCErr = [0] * 8
inTransmitErr = [0] * 8
inLinkErr = [0] * 8
outRecvErr = [0] * 8
outCRCErr = [0] * 8
outTransmitErr = [0] * 8
outLinkErr = [0] * 8
rtn,inRecvErr, inCRCErr, inTransmitErr, inLinkErr, outRecvErr, outCRCErr, outTransmitErr, outLinkErr = robot.GetSlavePortErrCounter()
for i in range(8):
if inRecvErr[i] != 0:
print(f"inRecvErr {i} is {inRecvErr[i]}")
if inCRCErr[i] != 0:
print(f"inCRCErr {i} is {inCRCErr[i]}")
if inTransmitErr[i] != 0:
print(f"inTransmitErr {i} is {inTransmitErr[i]}")
if inLinkErr[i] != 0:
print(f"inLinkErr {i} is {inLinkErr[i]}")
if outRecvErr[i] != 0:
print(f"outRecvErr {i} is {outRecvErr[i]}")
if outCRCErr[i] != 0:
print(f"outCRCErr {i} is {outCRCErr[i]}")
if outTransmitErr[i] != 0:
print(f"outTransmitErr {i} is {outTransmitErr[i]}")
if outLinkErr[i] != 0:
print(f"outLinkErr {i} is {outLinkErr[i]}")
print("others has no err!")
for i in range(8):
robot.SlavePortErrCounterClear(i)
robot.CloseRPC()
6.63. Set the feed-forward coefficient of each axis speed
New in version python: SDK-v2.1.7
Prototype | SetVelFeedForwardRatio(radio) |
Description | Set the feed-forward coefficient of each axis speed |
Mandatory parameters |
|
Default parameters | NULL |
Return Value | Error Code Success-0 Failure- errcode |
6.64. The velocity feedforward coefficients of each axis are obtained
New in version python: SDK-v2.1.7
Prototype | GetVelFeedForwardRatio() |
Description | The velocity feedforward coefficients of each axis are obtained |
Mandatory parameters | NULL |
Default parameters | NULL |
Return Value |
|
6.65. Robot velocity feedforward coefficient code example
from fairino import Robot
import time
import threading
# Establish a connection with the robot controller and return a robot object if the connection is successful
robot = Robot.RPC('192.168.58.2')
setRadio = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
robot.SetVelFeedForwardRatio(setRadio)
getRadio = [0.0] * 6
rtn,getRadio = robot.GetVelFeedForwardRatio()
print(f"{getRadio[0]},{getRadio[1]},{getRadio[2]},{getRadio[3]},{getRadio[4]},{getRadio[5]}")
robot.CloseRPC()