top of page

Python 12.27. Examples of instruction code for spiral exploration, straight line insertion, etc

from fairino import Robot
# Establish a connection with the robot controller and return a robot object if the connection is successful
robot = Robot.RPC('192.168.58.2')
company = 24
device = 0
softversion = 0
bus = 1
index = 1
robot.FT_SetConfig(company, device, softversion, bus)
time.sleep(1)
error,[company, device, softversion, bus] = robot.FT_GetConfig()
print(f"FT config:{company},{device},{softversion},{bus}")
time.sleep(1)
robot.FT_Activate(0)
time.sleep(1)
robot.FT_Activate(1)
time.sleep(1)
robot.FT_SetZero(0)
time.sleep(1)
status = 1
sensor_num = 1
gain = [0.00010.00.00.00.00.0]
adj_sign = 0
ILC_sign = 0
max_dis = 100.0
max_ang = 5.0
ft = [0.0,0.0,-10.0,0.0,0.0,0.0]
rcs = 0
dr = 0.7
fFinish = 1.0= 60000.0
vmax = 3.0
force_goal = 20.0
lin_v = 0.0
lin_a = 0.0
disMax = 100.0
linorn = 1
angVelRot = 2.0
forceInsertion = 1.0
angleMax = 45
orn = 1
angAccmax = 0.0
rotorn = 1
select1 = [001110]
robot.FT_Control(status, sensor_num, select1, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 000)
rtn = robot.FT_SpiralSearch(rcs, dr, fFinish, t, vmax)
print(f"FT_SpiralSearch rtn is {rtn}")
robot.FT_Control(0, sensor_num, select1, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 000)
select2 = [111000]
gain[0= 0.00005
ft[2= -30.0
robot.FT_Control(1, sensor_num, select2, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 000)
rtn = robot.FT_LinInsertion(rcs, force_goal, lin_v, lin_a, disMax, linorn)
print(f"FT_LinInsertion rtn is {rtn}")
robot.FT_Control(0, sensor_num, select2, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 000)
select3 = [001110]
ft[2= -10.0
gain[0= 0.0001
robot.FT_Control(1, sensor_num, select3, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 000)
rtn = robot.FT_RotInsertion(rcs, angVelRot, forceInsertion, angleMax, orn, angAccmax, rotorn)
print(f"FT_RotInsertion rtn is {rtn}")
robot.FT_Control(0, sensor_num, select3, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 000)
select4 = [111000]
ft[2= -30.0
robot.FT_Control(1, sensor_num, select4, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 000)
rtn = robot.FT_LinInsertion(rcs, force_goal, lin_v, lin_a, disMax, linorn)
print(f"FT_LinInsertion rtn is {rtn}")
robot.FT_Control(0, sensor_num, select4, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 000)
robot.CloseRPC()

12.28. Surface positioning

prototype

FT_FindSurface (rcs, dir, axis, disMax, ft, lin_v=3.0, lin_a=0.0)

Description

Surface Positioning

Mandatory parameters

  • rcs: reference coordinate system, 0 - tool coordinate system, 1 - base coordinate system;

  • dir: direction of movement, 1-positive, 2-negative;

  • axis: moving axes, 1-x, 2-y, 3-z;

  • disMax: large exploration distance in mm.

  • ft: action termination force threshold in N;

Default Parameters

  • lin_v: explore linear velocity in mm/s default 3.

  • lin_a: explore linear acceleration in mm/s^2 default 0;

Return Value

Error Code Success-0 Failure- errcode

12.29. Calculation of the center plane position begins

Prototype

FT_CalCenterStart()

Description

Calculation of mid-plane position begins

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.30. Calculate end of mid-plane position

Prototype

FT_CalCenterEnd()

Description

End of calculation of mid-plane position

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode - pos=[x,y,z,rx,ry,rz]: mid-plane position

12.31. Sample code for surface localization

from fairino import Robot
import time
# Establish a connection with the robot controller and return a robot object if the connection is successful
robot = Robot.RPC('192.168.58.2')
company = 24
device = 0
softversion = 0
bus = 1
index = 1
robot.FT_SetConfig(company, device, softversion, bus)
time.sleep(1)
error,[company, device, softversion, bus] = robot.FT_GetConfig()
print(f"FT config:{company},{device},{softversion},{bus}")
time.sleep(1)
robot.FT_Activate(0)
time.sleep(1)
robot.FT_Activate(1)
time.sleep(1)
robot.FT_SetZero(0)
time.sleep(1)
rcs = 0
dir = 1
axis = 1
lin_v = 3.0
lin_a = 0.0
maxdis = 50.0
ft_goal = 2.0
desc_pos = [-419.524-13.000351.569-178.1180.3143.833]
xcenter = [000000]
ycenter = [000000]
ft = [-2.00.00.00.00.00.0]
robot.MoveCart(desc_pos, 90100.0)
robot.FT_CalCenterStart()
robot.FT_FindSurface(rcs, dir, axis, lin_v, lin_a, maxdis, ft_goal)
robot.MoveCart(desc_pos, 90)
robot.WaitMs(1000)
dir = 2
robot.FT_FindSurface(rcs, dir, axis, lin_v, lin_a, maxdis, ft_goal)
error,xcenter = robot.FT_CalCenterEnd()
print(f"xcenter:{xcenter[0]},{xcenter[1]},{xcenter[2]},{xcenter[3]},{xcenter[4]},{xcenter[5]}")
robot.MoveCart(xcenter, 9060.0)
robot.FT_CalCenterStart()
dir = 1
axis = 2
lin_v = 6.0
maxdis = 150.0
robot.FT_FindSurface(rcs, dir, axis, lin_v, lin_a, maxdis, ft_goal)
robot.MoveCart(desc_pos, 90100.0)
robot.WaitMs(1000)
dir = 2
robot.FT_FindSurface(rcs, dir, axis, lin_v, lin_a, maxdis, ft_goal)
error,ycenter = robot.FT_CalCenterEnd()
print(f"ycenter:{ycenter[0]},{ycenter[1]},{ycenter[2]},{ycenter[3]},{ycenter[4]},{ycenter[5]}")
robot.MoveCart(ycenter, 9060.0)
robot.CloseRPC()

12.32. Soft control on

Prototype

FT_ComplianceStart(p, force)

Description

Softening control on

Mandatory parameters

  • p: Position adjustment factor or softness factor

  • force: soft opening force threshold in N

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.33. Soft control off

Prototype

FT_ComplianceStop()

Description

Softening control off

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.34. Soft control code example

from fairino import Robot
import time
# Establish a connection with the robot controller and return a robot object if the connection is successful
robot = Robot.RPC('192.168.58.2')
company = 24
device = 0
softversion = 0
bus = 1
index = 1
robot.FT_SetConfig(company, device, softversion, bus)
time.sleep(1)
error,[company, device, softversion, bus] = robot.FT_GetConfig()
print(f"FT config:{company},{device},{softversion},{bus}")
time.sleep(1)
robot.FT_Activate(0)
time.sleep(1)
robot.FT_Activate(1)
time.sleep(1)
robot.FT_SetZero(0)
time.sleep(1)
flag = 1
sensor_id = 1
select = [111000]
ft_pid = [0.00050.00.00.00.00.0]
adj_sign = 0
ILC_sign = 0
max_dis = 100.0
max_ang = 0.0
ft = [-10.0-10.0-10.00.00.00.0]
offset_pos = [0.0,0.0,0.0,0.0,0.0,0.0]  # 替代 DescPose(0, 0, 0, 0, 0, 0)
epos = [0.0,0.0,0.0,0.0]  # 替代 ExaxisPos(0, 0, 0, 0)
j1 = [-11.904-99.669117.473-108.616-91.72674.256]  # JointPos
j2 = [-45.615-106.172124.296-107.151-91.28274.255]
desc_p1 = [-419.524-13.000351.569-178.1180.3143.833]  # DescPose
desc_p2 = [-321.222185.189335.520-179.030-1.284-29.869]
robot.FT_Control(flag, sensor_id, select, ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, 000)
p = 0.00005
force = 30.0
rtn = robot.FT_ComplianceStart(p, force)
print(f"FT_ComplianceStart rtn is {rtn}")
count = 3
while count > 0:
    robot.MoveL(desc_pos=desc_p1,tool= 0,user= 0,vel= 100.0)
    robot.MoveL(desc_pos=desc_p2,tool= 0,user= 0,vel= 100.0)
    count -= 1
robot.FT_ComplianceStop()
print(f"FT_ComplianceStop rtn is {rtn}")
flag = 0
robot.FT_Control(flag, sensor_id, select, ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, 000)
robot.CloseRPC()

12.35. Load recognition filter initialization

New in version python: SDK-v2.0.1

Prototype

LoadIdentifyDynFilterInit()

Description

Load Recognition Filter Initialization

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.36. Initialization of load recognition variables

New in version python: SDK-v2.0.1

Prototype

LoadIdentifyDynVarInit()

Description

Load Identification Variable Initialization

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.37. Load Recognition Main Program

New in version python: SDK-v2.0.1

Prototype

LoadIdentifyMain(joint_torque, joint_pos, t)

Description

Load Recognition Master Program

Mandatory parameters

  • joint_torque: Joint torque j1-j6;

  • joint_pos: joint position j1-j6

  • t: sampling period

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.38. Getting Load Recognition Results

New in version python: SDK-v2.0.1

Prototype

LoadIdentifyGetResult(gain)

Description

Get load identification results

Mandatory parameters

  • gain: gravity term coefficient double[6], centrifugal term coefficient double[6]

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • weight: weight of the load

  • cog=[x,y,z]: load center of mass coordinates

12.39. Robot load identification code example

from fairino import Robot
import time
# Establish a connection with the robot controller and return a robot object if the connection is successful
robot = Robot.RPC('192.168.58.2')
retval = robot.LoadIdentifyDynFilterInit()
print(f"LoadIdentifyDynFilterInit retval is: {retval}")
retval = robot.LoadIdentifyDynVarInit()
print(f"LoadIdentifyDynVarInit retval is: {retval}")
error, posJ = robot.GetActualJointPosDegree(0)
posJ[1+= 10  # Modify joint 2
error, joint_toq = robot.GetJointTorques(0)
joint_toq[1+= 2  # Modify torque on joint 2
tmpTorque = joint_toq.copy()
retval = robot.LoadIdentifyMain(tmpTorque, posJ, 1)
print(f"LoadIdentifyMain retval is: {retval}")
gain = [00.05000000.020000]
weight = [0.0]
load_pos = [0.00.00.0]
retval, weight, load_pos = robot.LoadIdentifyGetResult(gain)
print(f"LoadIdentifyGetResult retval is: {retval} ; weight is {weight}  cog is {load_pos[0]} {load_pos[1]} {load_pos[2]}")
robot.CloseRPC()

12.40. Force Sensor Assisted Drag

New in version python: SDK-v2.1.3

Prototype

EndForceDragControl(status, asaptiveFlag, interfereDragFlag, ingularityConstraintsFlag, M, B, K, F, Fmax, Vmax, forceCollisionFlag=0)

Description

Force Sensor Assisted Drag

Mandatory parameters

  • status: control status, 0 - off; 1 - on

  • asaptiveFlag: adaptive on flag, 0 - off; 1 - on

  • interfereDragFlag: interference area drag flag, 0 - off; 1 - on

  • ingularityConstraintsFlag: singularity strategy, 0- evade; 1- Crossing

  • forceCollisionFlag: Robot collision detection mark during assisted dragging 0- Close 1- Enable

  • M=[m1,m2,m3,m4,m5,m6]: inertia factor

  • B=[b1,b2,b3,b4,b5,b6]: damping factor

  • K=[k1,k2,k3,k4,k5,k6]: stiffness factor

  • F=[f1,f2,f3,f4,f5,f6]: drag six-dimensional force thresholds

  • Fmax: Maximum towing force limitation

  • Vmax: maximum joint speed limit

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.41. Get force sensor drag switch status

New in version python: SDK-v2.0.5

Prototype

GetForceAndTorqueDragState()

Description

Get force sensor drag switch status

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • dragState: force sensor assisted drag control state, 0 - off; 1 - on

  • sixDimensionalDragState: six-dimensional force-assisted drag control state, 0-off; 1-on

12.42. The force sensor turns on automatically after the error is cleared.

New in version python: SDK-v2.0.5

Prototype

SetForceSensorDragAutoFlag(status)

Description

The force sensor turns on automatically after an error is cleared.

Mandatory parameters

  • status: control status, 0 - off; 1 - on

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.43. Force sensor assisted drag code example

from fairino import Robot
import time
# Establish a connection with the robot controller and return a robot object if the connection is successful
robot = Robot.RPC('192.168.58.2')
robot.SetForceSensorDragAutoFlag(1)
M = [15.015.015.00.50.50.1]
B = [150.0150.0150.05.05.01.0]
K = [0.00.00.00.00.00.0]
F = [10.010.010.01.01.01.0]
robot.EndForceDragControl(1000, M, B, K, F, 50100)
time.sleep(5)
drag_state = 0
six_dimensional_drag_state = 0
error,drag_state, six_dimensional_drag_state = robot.GetForceAndTorqueDragState()
print(f"the drag state is {drag_state} {six_dimensional_drag_state}")
robot.EndForceDragControl(0000, M, B, K, F, 50100)
robot.CloseRPC()

12.44. Setting up hybrid drag switches and parameters for six-dimensional force and joint impedance

New in version python: SDK-v2.0.5

Prototype

ForceAndJointImpedanceStartStop(status, impedanceFlag, lamdeDain, KGain, BGain, dragMaxTcpVel, dragMaxTcpOriVel)

Description

Setting up the six-dimensional force and joint impedance hybrid drag switch and parameters

Mandatory parameters

  • status: control status, 0 - off; 1 - on

  • impedanceFlag: impedance on flag, 0 - off; 1 - on

  • lamdeDain: [D1, D2, D3, D4, D5, D6] drag gain

  • KGain: [K1,K2,K3,K4,K5,K6] Stiffness Gain

  • BGain: [B1,B2,B3,B4,B5,B] damping gain

  • dragMaxTcpVel: maximum line speed limit at the end of a drag

  • dragMaxTcpOriVel: drag end maximum angular velocity limit

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.45. Six dimensional force and joint impedance mixed drag code example

from fairino import Robot
import time
# Establish a connection with the robot controller and return a robot object if the connection is successful
robot = Robot.RPC('192.168.58.2')
robot.DragTeachSwitch(1)
lamde_dain = [3.02.02.02.02.03.0]
k_gain = [0.00.00.00.00.00.0]
b_gain = [150.0150.0150.05.05.01.0]
rtn = robot.ForceAndJointImpedanceStartStop(10, lamde_dain, k_gain, b_gain, 1000180)
print(f"ForceAndJointImpedanceStartStop rtn is {rtn}")
time.sleep(5)
robot.DragTeachSwitch(0)
rtn = robot.ForceAndJointImpedanceStartStop(00, lamde_dain, k_gain, b_gain, 1000180)
print(f"ForceAndJointImpedanceStartStop rtn is {rtn}")
robot.CloseRPC()

12.46. Impedance start and stop control

New in version python: SDK-v2.1.6

Prototype

ImpedanceControlStartStop(status, workSpace, forceThreshold, m, b, k, maxV, maxVA, maxW, maxWA)

Description

Impedance start and stop control

Mandatory parameters

  • status:0- closed; 1- On

  • workSpace:0-joint space; 1-Dekal space

  • forceThreshold:Trigger force threshold (N)

  • m:Quality parameter

  • b:Parameter of damping

  • k:Parameter of stiffness

  • maxV:Maximum linear velocity (mm/s)

  • maxVA:Maximum linear acceleration (mm/s2)

  • maxW:Maximum angular velocity (°/s)

  • maxWA:Maximum angular acceleration (°/s2)

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.47. Example code for impedance start and stop control

from fairino import Robot
# Establish a connection with the robot controller and return a robot object if the connection is successful
robot = Robot.RPC('192.168.58.2')
j1 = [102.622-135.990120.769-73.950-90.84835.507]
j2 = [93.674-80.06282.947-92.199-90.96726.559]
desc_pos1 = [136.552-149.799449.532179.817-1.172157.123]
desc_pos2 = [136.540-561.048449.542179.819-1.172157.122]
offset_pos = [0.0* 6
epos = [0.0* 4
tool = 0
user = 0
vel = 100.0
acc = 200.0
ovl = 100.0
blendT = -1.0
blendR = -1.0
flag = 0
search = 0
robot.SetSpeed(20)
company = 17
device = 0
softversion = 0
bus = 1
robot.FT_SetConfig(company, device, softversion, bus)
time.sleep(1)
rnt,[company, device, softversion, bus] = robot.FT_GetConfig()
print(f"FT config:{company},{device},{softversion},{bus}")
time.sleep(1)
robot.FT_Activate(0)
time.sleep(1)
robot.FT_Activate(1)
time.sleep(1)
time.sleep(1)
robot.FT_SetZero(0)
time.sleep(1)
robot.FT_SetZero(1)
time.sleep(1)
forceThreshold = [30.030.030.05.05.05.0]
m = [0.10.10.10.020.020.02]
b = [1.01.01.00.080.080.08]
k = [0.0* 6
rtn = robot.ImpedanceControlStartStop(11, forceThreshold, m, b, k, 1000500100100)
print(f"ImpedanceControlStartStop errcode:{rtn}")
rtn = robot.MoveL(desc_pos=desc_pos1,tool= tool,user= user,vel= vel,speedPercent=1)
rtn = robot.MoveL(desc_pos=desc_pos2,tool= tool,user= user,vel= vel,speedPercent=1)
rtn = robot.MoveL(desc_pos=desc_pos1,tool= tool,user= user,vel= vel,speedPercent=1)
rtn = robot.MoveL(desc_pos=desc_pos2,tool= tool,user= user,vel= vel,speedPercent=1)
rtn = robot.MoveL(desc_pos=desc_pos1,tool= tool,user= user,vel= vel,speedPercent=1)
rtn = robot.MoveL(desc_pos=desc_pos2,tool= tool,user= user,vel= vel,speedPercent=1)
print(f"movel errcode:{rtn}")
robot.ImpedanceControlStartStop(01, forceThreshold, m, b, k, 1000500100100)
robot.CloseRPC()

12.48. Enable Torque Compensation Function and Compensation Coefficients

Prototype

SerCoderCompenParams(status, torqueCoeff)

Description

Enable Torque Compensation Function and Compensation Coefficients

Required Parameters

  • status:Switch, 0-Disable; 1-Enable

  • torqueCoeff:J1-J6 Torque compensation coefficients [0-1]

Default Parameters

None

Return Value

Error code 0-Success Error- errcode


robotic arm
FAIRINO ROBOTIC ARMS

Contact

Location: 10637 Scripps Summit Court,

San Diego, CA. 92131
Phone: (619) 333-FAIR
Email: hello@fairino.us

© 2023 Fairino US official site Proudly created By G2T

bottom of page