12. Force Control

12.1. Force Sensor Configuration

Prototype

FT_SetConfig(company,device,softversion=0,bus=0)

Description

Force Sensor Configuration

Required Parameters

  • company: Sensor Manufacturer, 17 - Kunwei Technology, 19 - Aerospace 11th Academy, 20 - ATI Sensors, 21 - Zhongke MiDot, 22 - Weihang Minxin,23-NBIT,24-XJC,26-NSR;

  • device: device number, Kunwei (0-KWR75B), Aisino Eleventh Academy (0-MCS6A-200-4), ATI (0-AXIA80-M8), Zhongke MiDot (0-MST2010), Weihang Minxin (0-WHC6L-YB-10A),NBIT(0-XLH93003ACS),XJC(0-XJC-6F-D82),NSR(0-NSR-FTSensorA);

Default parameters

  • softversion: software version number, not used for now, default is 0;

  • bus: device mount end bus location, not used yet, default is 0;

Return Value

Error Code Success-0 Failure- errcode

12.2. Get Force Sensor Configuration

Prototype

FT_GetConfig()

Description

Get Force Sensor Configuration

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • [number,company,device,softversion,bus]:number 传感器编号;company 力传感器厂商,17-坤维科技,19-航天十一院,20-ATI 传感器,21-中科米点,22-伟航敏芯;device 设备号,坤维 (0- KWR75B), Aisino Eleven (0-MCS6A-200-4), ATI (0-AXIA80-M8), Zhongke MiDot (0-MST2010), Weihang Minxin (0-WHC6L-YB10A); softvesion software version number, not used for the time being, the default is 0.

12.3. Force sensor activation

Prototype

FT_Activate(state)

Description

Force sensor activation

Mandatory parameters

  • state: 0-reset, 1-activate

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.4. Force Sensor Zeroing

Prototype

FT_SetZero(state)

Description

Force Transducer Zeroing

Mandatory parameters

  • state: 0-removal of zeros, 1-zero correction

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.5. Setting the force transducer reference coordinate system

Changed in version python: SDK-v2.0.5

prototype

FT_SetRCS(ref,coord=[0,0,0,0,0,0,0])

Description

Setting the force transducer reference coordinate system

Mandatory parameters

  • ref: 0 - tool coordinate system, 1 - base coordinate system

Default parameters

  • coord: [x,y,z,rx,ry,rz] customized coordinate system values, default [0,0,0,0,0,0,0]

Return Value

Error Code Success-0 Failure- errcode

12.6. Setting the load weight under the force transducer

New in version python: SDK-v2.0.5

Prototype

SetForceSensorPayload(weight)

Description

Set the load weight under the force transducer

Mandatory parameters

  • weight: load weight kg

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.7. Setting the load center of mass under the force transducer

New in version python: SDK-v2.0.5

Prototype

SetForceSensorPayloadCog(x,y,z)

Description

Setting the center of mass of the load under the force transducer

Mandatory parameters

  • x: load center of mass x mm

  • y: load center of mass y mm

  • z: load center of mass z mm

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.8. Getting the load weight under the force transducer

New in version python: SDK-v2.0.5

Prototype

GetForceSensorPayload()

Description

Get the weight of the load under the force transducer.

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • weight: loaded weight kg

12.9. Obtaining the center of mass of the load under the force transducer

New in version python: SDK-v2.0.5

Prototype

GetForceSensorPayloadCog()

Description

Getting the center of mass of the load under the force transducer

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • x: load center of mass x mm

  • y: load center of mass y mm

  • z: load center of mass z mm

12.10. Automatic zeroing of force sensors

New in version python: SDK-v2.0.5

Prototype

ForceSensorAutoComputeLoad()

Description

Automatic zeroing of force sensors

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • weight: sensor mass kg

  • pos=[x,y,z]: sensor center of mass mm

12.11. Obtaining force/torque data in the reference coordinate system

Prototype

FT_GetForceTorqueRCS()

Description

Get force/torque data in reference coordinate system

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • data=[fx,fy,fz,tx,ty,tz]: force/torque data in the reference coordinate system.

12.12. Obtaining Force Sensor Raw Force/Torque Data

Prototype

FT_GetForceTorqueOrigin()

Description

Get force sensor raw force/torque data

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • data=[fx,fy,fz,tx,ty,tz]: Force sensor raw force/torque data

12.13. Force sensor configuration and automatic zero correction code example

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4company = 24
 5device = 0
 6softversion = 0
 7bus = 1
 8index = 1
 9robot.FT_SetConfig(company, device, softversion, bus)
10time.sleep(1)
11error,[company, device, softversion, bus] = robot.FT_GetConfig()
12print(f"FT config:{company},{device},{softversion},{bus}")
13time.sleep(1)
14robot.FT_Activate(0)
15time.sleep(1)
16robot.FT_Activate(1)
17time.sleep(1)
18time.sleep(1)
19robot.FT_SetZero(0)
20time.sleep(1)
21error,ft = robot.FT_GetForceTorqueOrigin()
22print(f"ft origin:{ft[0]},{ft[1]},{ft[2]},{ft[3]},{ft[4]},{ft[5]}")
23robot.FT_SetZero(1)
24time.sleep(1)
25ftCoord = [0, 0, 0, 0, 0, 0]
26robot.FT_SetRCS(0, ftCoord)
27robot.SetForceSensorPayload(0.824)
28robot.SetForceSensorPayloadCog(0.778, 2.554, 48.765)
29error,weight = robot.GetForceSensorPayload()
30error,x, y, z = robot.GetForceSensorPayloadCog()
31print(f"the FT load is  {weight}, {x} {y} {z}")
32robot.SetForceSensorPayload(0)
33robot.SetForceSensorPayloadCog(0, 0, 0)
34error,computeWeight, tran = robot.ForceSensorAutoComputeLoad()
35print(f"the result is weight {computeWeight} pos is {tran[0]} {tran[1]} {tran[2]}")
36robot.CloseRPC()

12.14. Load weight identification records

Prototype

FT_PdIdenRecord(tool_id)

Description

Load weight identification record

Mandatory parameters

  • tool_id: sensor coordinate system number, range [0~14]

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.15. Load weight identification calculation

Prototype

FT_PdIdenCompute()

Description

Load weight identification calculation

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • weight: weight of the load in kg

12.16. Load center of mass identification records

prototype

FT_PdCogIdenRecord(tool_id,index)

Description

Load center of mass identification record

Mandatory parameter

  • tool_id: sensor coordinate system number, range [0~14].

  • index: point number [1 to 3]

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.17. Load center of mass identification calculation

Prototype

FT_PdCogIdenCompute()

Description

Load center of mass identification calculation

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • cog=[cogx,cogy,cogz]: center of mass of load in mm

12.18. Force sensor load identification code example

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4company = 24
 5device = 0
 6softversion = 0
 7bus = 1
 8index = 1
 9robot.FT_SetConfig(company, device, softversion, bus)
10time.sleep(1)
11error,[company, device, softversion, bus] = robot.FT_GetConfig()
12print(f"FT config:{company},{device},{softversion},{bus}")
13time.sleep(1)
14robot.FT_Activate(0)
15time.sleep(1)
16robot.FT_Activate(1)
17time.sleep(1)
18robot.FT_SetZero(0)
19time.sleep(1)
20error,ft = robot.FT_GetForceTorqueOrigin()
21print(f"ft origin:{ft[0]},{ft[1]},{ft[2]},{ft[3]},{ft[4]},{ft[5]}")
22robot.FT_SetZero(1)
23time.sleep(1)
24tcoord = [0, 0, 35.0, 0, 0, 0]
25robot.SetToolCoord(10, tcoord, 1, 0, 0, 0)
26robot.FT_PdIdenRecord(10)
27time.sleep(1)
28error,weight = robot.FT_PdIdenCompute()
29print(f"payload weight:{weight}")
30desc_p1 = [-419.524, -13.000, 351.569, -178.118, 0.314, 3.833]
31desc_p2 = [-321.222, 185.189, 335.520, -179.030, -1.284, -29.869]
32desc_p3 = [-327.622, 402.230, 320.402, -178.067, 2.127, -46.207]
33robot.MoveCart(desc_p1, 0, 0, 100.0)
34time.sleep(1)
35robot.FT_PdCogIdenRecord(10, 1)
36robot.MoveCart(desc_p2, 0, 0, 100.0)
37time.sleep(1)
38robot.FT_PdCogIdenRecord(10, 2)
39robot.MoveCart(desc_p3, 0, 0, 100.0)
40time.sleep(1)
41robot.FT_PdCogIdenRecord(10, 3)
42time.sleep(1)
43error,cog = robot.FT_PdCogIdenCompute()
44print(f"FT_PdCogIdenCompute return {error}")
45print(f"cog:{cog[0]},{cog[1]},{cog[2]}")
46robot.CloseRPC()

12.19. Collision Guard

Prototype

FT_Guard(flag,sensor_num,select,force_torque,max_threshold,min_threshold)

description

collision guarding

Required Parameters

  • flag: 0 - turn off collision guarding, 1 - turn on collision guarding;

  • sensor_num: force sensor number;

  • select: whether or not the six degrees of freedom detect collisions [fx,fy,fz,mx,my,mz], 0 - not valid, 1 - valid;

  • force_torque: collision detection force/torque in N or Nm;

  • max_threshold: maximum threshold;

  • min_threshold: minimum threshold;

  • Force/torque detection range: (force_torque-min_threshold,force_torque+max_threshold)

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

12.20. Collision guard code example

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4company = 24
 5device = 0
 6softversion = 0
 7bus = 1
 8index = 1
 9robot.FT_SetConfig(company, device, softversion, bus)
10time.sleep(1)
11error,[company, device, softversion, bus] = robot.FT_GetConfig()
12print(f"FT config:{company},{device},{softversion},{bus}")
13time.sleep(1)
14robot.FT_Activate(0)
15time.sleep(1)
16robot.FT_Activate(1)
17time.sleep(1)
18robot.FT_SetZero(0)
19time.sleep(1)
20sensor_id = 1
21select = [1, 1, 1, 1, 1, 1]
22max_threshold = [10.0, 10.0, 10.0, 10.0, 10.0, 10.0]
23min_threshold = [5.0, 5.0, 5.0, 5.0, 5.0, 5.0]
24ft = None
25desc_p1 = [-419.524, -13.000, 351.569, -178.118, 0.314, 3.833]
26desc_p2 = [-321.222, 185.189, 335.520, -179.030, -1.284, -29.869]
27desc_p3 = [-327.622, 402.230, 320.402, -178.067, 2.127, -46.207]
28error = robot.FT_Guard(1, sensor_id, select,[0.0,0.0,0.0,0.0,0.0,0.0], max_threshold, min_threshold)
29robot.MoveCart(desc_p1, 0, 0, 100.0)
30robot.MoveCart(desc_p2, 0, 0, 100.0)
31robot.MoveCart(desc_p3, 0, 0, 100.0)
32robot.FT_Guard(0, sensor_id, select,[0.0,0.0,0.0,0.0,0.0,0.0], max_threshold, min_threshold)
33robot.CloseRPC()

12.21. constant force control

prototype

FT_Control(flag, sensor_id, select, ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, M=None, B=None, threshold=[0.2,0.2], adjustCoeff=[1.0,1.0], polishRadio=0, filter_Sign=0, posAdapt_sign=0, isNoBlock=0)

Description

Constant force control

Mandatory parameter

  • flag: constant force control on flag, 0-off, 1-on;

  • sensor_id: force sensor number;

  • select: whether the six degrees of freedom are detected [fx,fy,fz,mx,my,mz], 0 - not valid, 1 - valid;

  • ft: detection of force/torque in N or Nm;

  • ft_pid: [f_p,f_i,f_d,m_p,m_i,m_d], force PID parameter, moment PID parameter;

  • adj_sign: adaptive start/stop state, 0-off, 1-on;

  • ILC_sign: ILC control start/stop status, 0-stop, 1-training, 2-practical;

  • max_dis: maximum adjustment distance;

  • max_ang: maximum angle of adjustment;

Default parameters

  • M:Quality parameters;

  • B:Damping parameter;

  • threshold:Activation threshold for rx, ry [0-10], default 0.2;

  • adjustCoeff:Torque adjustment coefficient for rx, ry [0-1], default 1;

  • polishRadio:Grinding disc radius, unit: mm;

  • filter_Sign:Filter on indicator 0- off; 1- On, default 0- off;

  • posAdapt_sign:The posture conforms to the opening mark 0-off. 1- On, default 0- off;

  • isNoBlock:Block flag, 0- block; 1- Non-blocking default 0- blocking;

Return Value

Error Code Success-0 Failure- errcode

12.22. A code example of constant force control with damping

 1from fairino import Robot
 2import time
 3robot = Robot.RPC('192.168.58.2')
 4sensor_id = 10
 5select = [0, 0, 1, 0, 0, 0]
 6ft_pid = [0.0008, 0.0, 0.0, 0.0, 0.0, 0.0]
 7adj_sign = 0
 8ILC_sign = 0
 9max_dis = 1000.0
10max_ang = 20.0
11ft = [0.0] * 6
12epos = [0.0] * 4
13j1 = [80.765, -98.795, 106.548, -97.734, -89.999, 94.842]
14j2 = [43.067, -84.429, 92.620, -98.175, -90.011, 57.144]
15desc_p1 = [5.009, -547.463, 262.053, -179.999, -0.019, 75.923]
16desc_p2 = [-347.966, -547.463, 262.048, -180.000, -0.019, 75.923]
17offset_pos = [0.0] * 6
18M = [2.0, 2.0]
19B = [15.0, 15.0]
20threshold = [1.0, 1.0]
21adjustCoeff = [1.0, 0.8]
22polishRadio = 0.0
23filter_Sign = 0
24posAdapt_sign = 1
25isNoBlock = 0
26ft[2] = -10.0
27while True:
28    rtn = robot.FT_Control(1, sensor_id, select, ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, M, B, threshold,adjustCoeff, 0, 0, 1, 0)
29    print(f"FT_Control start rtn is {rtn}")
30    rtn = robot.MoveL(desc_pos=desc_p1, tool=1, user=0, vel=100, acc=100, ovl=100, blendR=-1, blendMode = 0, exaxis_pos=epos, search=0, offset_flag=0, offset_pos=offset_pos)
31    rtn = robot.MoveL(desc_pos=desc_p2, tool=1, user=0, vel=100, acc=100, ovl=100, blendR=-1, blendMode = 0, exaxis_pos=epos, search=0, offset_flag=0, offset_pos=offset_pos)
32    rtn = robot.FT_Control(0, sensor_id, select, ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, M, B, threshold,adjustCoeff, 0, 0, 1, 0)
33    print(f"FT_Control end rtn is {rtn}")
34robot.CloseRPC()
35return 0

12.23. Helix Exploration

Prototype

FT_SpiralSearch(rcs, ft, dr=0.7, max_t_ms=60000, max_vel=5)

Description

Helix Explorations

Mandatory parameters

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

  • ft: force or moment threshold (0 to 100) in N or Nm;

Default parameters

  • dr: radius feed per revolution in mm Default 0.7.

  • max_t_ms: maximum time to explore, in ms default 60000.

  • max_vel: maximum value of linear velocity in mm/s Default 5

Return Value

Error Code Success-0 Failure- errcode

12.24. Rotational Insertion

Prototype

FT_RotInsertion(rcs, ft, orn, angVelRot=3, angleMax=45, angAccmax=0, rotorn=1, strategy=0)

Description

Rotational Insertion

Required Parameters

  • rcs: Reference coordinate system, 0 - Tool coordinate system, 1 - Base coordinate system;

  • ft: Force or torque threshold (0~100), unit N or Nm;

  • orn: Force/torque direction, 1 - Along Z-axis direction, 2 - Around Z-axis direction;

Default Parameters

  • angVelRot: Rotational angular velocity, unit °/s, default 3;

  • angleMax: Maximum rotation angle, unit °, default 45;

  • angAccmax: Maximum rotational acceleration, unit °/s^2, currently unused, default 0;

  • rotorn: Rotation direction, 1 - Clockwise, 2 - Counterclockwise, default 1;

  • strategy: Processing strategy for undetected force/torque, 0 - Error; 1 - Warning, continue motion

Return Value

Error code. Success - 0, Failure - errcode

12.25. Code Example for Spiral Search, Linear Insertion, and Other Commands

 1from fairino import Robot
 2import time
 3robot = Robot.RPC('192.168.58.2')
 4j1=[-11.904,-99.669,117.473,-108.616,-91.726,74.256]
 5j2=[-45.615,-106.172,124.296,-107.151,-91.282,74.255]
 6j3=[-29.777,-84.536,109.275,-114.075,-86.655,74.257]
 7j4=[-31.154,-95.317,94.276,-88.079,-89.740,74.256]
 8desc_pos1=[-419.524,-13.000,351.569,-178.118,0.314,3.833]
 9desc_pos2=[-321.222,185.189,335.520,-179.030,-1.284,-29.869]
10desc_pos3=[-487.434,154.362,308.576,176.600,0.268,-14.061]
11desc_pos4=[-443.165,147.881,480.951,179.511,-0.775,-15.409]
12offset_pos=[0.0]*6
13epos=[0.0]*4
14tool=0
15user=0
16vel=100.0
17acc=100.0
18ovl=100.0
19oacc=100.0
20blendT=0.0
21blendR=0.0
22flag=0
23search=0
24blendMode=0
25velAccMode=0
26robot.SetSpeed(20)
27rtn=robot.MoveJ(joint_pos=j1,tool=tool,user=user,vel=vel,acc=acc,ovl=ovl,exaxis_pos=epos,blendT=blendT,offset_flag=flag,offset_pos=offset_pos)
28print(f"movejerrcode:{rtn}")
29rtn=robot.MoveL(desc_pos=desc_pos2,tool=tool,user=user,vel=vel,acc=acc,ovl=ovl,blendR=blendR,blendMode=blendMode,exaxis_pos=epos,search=search,offset_flag=flag,offset_pos=offset_pos,oacc=oacc,velAccParamMode=velAccMode)
30print(f"movelerrcode:{rtn}")
31rtn=robot.MoveC(desc_pos_p=desc_pos3,tool_p=tool,user_p=user,vel_p=vel,acc_p=acc,exaxis_pos_p=epos,offset_flag_p=flag,offset_pos_p=offset_pos,desc_pos_t=desc_pos4,tool_t=tool,user_t=user,vel_t=vel,acc_t=acc,exaxis_pos_t=epos,offset_flag_t=flag,offset_pos_t=offset_pos,ovl=ovl,blendR=blendR,oacc=oacc,velAccParamMode=velAccMode)
32print(f"movecerrcode:{rtn}")
33rtn=robot.MoveJ(joint_pos=j2,tool=tool,user=user,vel=vel,acc=acc,ovl=ovl,exaxis_pos=epos,blendT=blendT,offset_flag=flag,offset_pos=offset_pos)
34print(f"movejerrcode:{rtn}")
35rtn=robot.Circle(desc_pos_p=desc_pos3,tool_p=tool,user_p=user,vel_p=vel,acc_p=acc,exaxis_pos_p=epos,desc_pos_t=desc_pos1,tool_t=tool,user_t=user,vel_t=vel,acc_t=acc,exaxis_pos_t=epos,ovl=ovl,offset_flag=flag,offset_pos=offset_pos,oacc=oacc,blendR=-1,velAccParamMode=velAccMode)
36print(f"circleerrcode:{rtn}")
37rtn=robot.MoveCart(desc_pos=desc_pos4,tool=tool,user=user,vel=vel,acc=acc,ovl=ovl,blendT=blendT,config=-1)
38print(f"MoveCarterrcode:{rtn}")
39rtn=robot.MoveJ(joint_pos=j1,tool=tool,user=user,vel=vel,acc=acc,ovl=ovl,exaxis_pos=epos,blendT=blendT,offset_flag=flag,offset_pos=offset_pos)
40print(f"movejerrcode:{rtn}")
41rtn=robot.MoveL(desc_pos=desc_pos2,tool=tool,user=user,vel=vel,acc=acc,ovl=ovl,blendR=blendR,blendMode=blendMode,exaxis_pos=epos,search=search,offset_flag=flag,offset_pos=offset_pos,config=-1,velAccParamMode=velAccMode)
42print(f"movelerrcode:{rtn}")
43rtn=robot.MoveC(desc_pos_p=desc_pos3,tool_p=tool,user_p=user,vel_p=vel,acc_p=acc,exaxis_pos_p=epos,offset_flag_p=flag,offset_pos_p=offset_pos,desc_pos_t=desc_pos4,tool_t=tool,user_t=user,vel_t=vel,acc_t=acc,exaxis_pos_t=epos,offset_flag_t=flag,offset_pos_t=offset_pos,ovl=ovl,blendR=blendR,config=-1,velAccParamMode=velAccMode)
44print(f"movecerrcode:{rtn}")
45rtn=robot.MoveJ(joint_pos=j2,tool=tool,user=user,vel=vel,acc=acc,ovl=ovl,exaxis_pos=epos,blendT=blendT,offset_flag=flag,offset_pos=offset_pos)
46print(f"movejerrcode:{rtn}")
47rtn=robot.Circle(desc_pos_p=desc_pos3,tool_p=tool,user_p=user,vel_p=vel,acc_p=acc,exaxis_pos_p=epos,desc_pos_t=desc_pos1,tool_t=tool,user_t=user,vel_t=vel,acc_t=acc,exaxis_pos_t=epos,ovl=ovl,offset_flag=flag,offset_pos=offset_pos,oacc=oacc,blendR=-1,velAccParamMode=velAccMode)
48print(f"circleerrcode:{rtn}")
49robot.CloseRPC()
50return 0

12.26. Linear insertion

prototype

FT_LinInsertion(rcs, ft, disMax, linorn, lin_v=1.0, lin_a=1.0)

Description

Linear Insertion

Mandatory parameters

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

  • ft: force or moment threshold (0 to 100) in N or Nm.

  • disMax: maximum insertion distance in mm.

  • linorn: insertion direction: 0-negative direction, 1-positive direction

Default parameters

  • lin_v: linear velocity in mm/s Default 1.

  • lin_a: linear acceleration in mm/s^2, not used yet Default 1

Return Value

Error Code Success-0 Failure- errcode

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

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4company = 24
 5device = 0
 6softversion = 0
 7bus = 1
 8index = 1
 9robot.FT_SetConfig(company, device, softversion, bus)
10time.sleep(1)
11error,[company, device, softversion, bus] = robot.FT_GetConfig()
12print(f"FT config:{company},{device},{softversion},{bus}")
13time.sleep(1)
14robot.FT_Activate(0)
15time.sleep(1)
16robot.FT_Activate(1)
17time.sleep(1)
18robot.FT_SetZero(0)
19time.sleep(1)
20status = 1
21sensor_num = 1
22gain = [0.0001, 0.0, 0.0, 0.0, 0.0, 0.0]
23adj_sign = 0
24ILC_sign = 0
25max_dis = 100.0
26max_ang = 5.0
27ft = [0.0,0.0,-10.0,0.0,0.0,0.0]
28rcs = 0
29dr = 0.7
30fFinish = 1.0
31t = 60000.0
32vmax = 3.0
33force_goal = 20.0
34lin_v = 0.0
35lin_a = 0.0
36disMax = 100.0
37linorn = 1
38angVelRot = 2.0
39forceInsertion = 1.0
40angleMax = 45
41orn = 1
42angAccmax = 0.0
43rotorn = 1
44select1 = [0, 0, 1, 1, 1, 0]
45robot.FT_Control(status, sensor_num, select1, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0)
46rtn = robot.FT_SpiralSearch(rcs, dr, fFinish, t, vmax)
47print(f"FT_SpiralSearch rtn is {rtn}")
48robot.FT_Control(0, sensor_num, select1, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0)
49select2 = [1, 1, 1, 0, 0, 0]
50gain[0] = 0.00005
51ft[2] = -30.0
52robot.FT_Control(1, sensor_num, select2, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0)
53rtn = robot.FT_LinInsertion(rcs, force_goal, lin_v, lin_a, disMax, linorn)
54print(f"FT_LinInsertion rtn is {rtn}")
55robot.FT_Control(0, sensor_num, select2, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0)
56select3 = [0, 0, 1, 1, 1, 0]
57ft[2] = -10.0
58gain[0] = 0.0001
59robot.FT_Control(1, sensor_num, select3, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0)
60rtn = robot.FT_RotInsertion(rcs, angVelRot, forceInsertion, angleMax, orn, angAccmax, rotorn)
61print(f"FT_RotInsertion rtn is {rtn}")
62robot.FT_Control(0, sensor_num, select3, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0)
63select4 = [1, 1, 1, 0, 0, 0]
64ft[2] = -30.0
65robot.FT_Control(1, sensor_num, select4, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0)
66rtn = robot.FT_LinInsertion(rcs, force_goal, lin_v, lin_a, disMax, linorn)
67print(f"FT_LinInsertion rtn is {rtn}")
68robot.FT_Control(0, sensor_num, select4, ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0)
69robot.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

 1from fairino import Robot
 2import time
 3# Establish a connection with the robot controller and return a robot object if the connection is successful
 4robot = Robot.RPC('192.168.58.2')
 5company = 24
 6device = 0
 7softversion = 0
 8bus = 1
 9index = 1
10robot.FT_SetConfig(company, device, softversion, bus)
11time.sleep(1)
12error,[company, device, softversion, bus] = robot.FT_GetConfig()
13print(f"FT config:{company},{device},{softversion},{bus}")
14time.sleep(1)
15robot.FT_Activate(0)
16time.sleep(1)
17robot.FT_Activate(1)
18time.sleep(1)
19robot.FT_SetZero(0)
20time.sleep(1)
21rcs = 0
22dir = 1
23axis = 1
24lin_v = 3.0
25lin_a = 0.0
26maxdis = 50.0
27ft_goal = 2.0
28desc_pos = [-419.524, -13.000, 351.569, -178.118, 0.314, 3.833]
29xcenter = [0, 0, 0, 0, 0, 0]
30ycenter = [0, 0, 0, 0, 0, 0]
31ft = [-2.0, 0.0, 0.0, 0.0, 0.0, 0.0]
32robot.MoveCart(desc_pos, 9, 0, 100.0)
33robot.FT_CalCenterStart()
34robot.FT_FindSurface(rcs, dir, axis, lin_v, lin_a, maxdis, ft_goal)
35robot.MoveCart(desc_pos, 9, 0)
36robot.WaitMs(1000)
37dir = 2
38robot.FT_FindSurface(rcs, dir, axis, lin_v, lin_a, maxdis, ft_goal)
39error,xcenter = robot.FT_CalCenterEnd()
40print(f"xcenter:{xcenter[0]},{xcenter[1]},{xcenter[2]},{xcenter[3]},{xcenter[4]},{xcenter[5]}")
41robot.MoveCart(xcenter, 9, 0, 60.0)
42robot.FT_CalCenterStart()
43dir = 1
44axis = 2
45lin_v = 6.0
46maxdis = 150.0
47robot.FT_FindSurface(rcs, dir, axis, lin_v, lin_a, maxdis, ft_goal)
48robot.MoveCart(desc_pos, 9, 0, 100.0)
49robot.WaitMs(1000)
50dir = 2
51robot.FT_FindSurface(rcs, dir, axis, lin_v, lin_a, maxdis, ft_goal)
52error,ycenter = robot.FT_CalCenterEnd()
53print(f"ycenter:{ycenter[0]},{ycenter[1]},{ycenter[2]},{ycenter[3]},{ycenter[4]},{ycenter[5]}")
54robot.MoveCart(ycenter, 9, 0, 60.0)
55robot.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

 1from fairino import Robot
 2import time
 3# Establish a connection with the robot controller and return a robot object if the connection is successful
 4robot = Robot.RPC('192.168.58.2')
 5company = 24
 6device = 0
 7softversion = 0
 8bus = 1
 9index = 1
10robot.FT_SetConfig(company, device, softversion, bus)
11time.sleep(1)
12error,[company, device, softversion, bus] = robot.FT_GetConfig()
13print(f"FT config:{company},{device},{softversion},{bus}")
14time.sleep(1)
15robot.FT_Activate(0)
16time.sleep(1)
17robot.FT_Activate(1)
18time.sleep(1)
19robot.FT_SetZero(0)
20time.sleep(1)
21flag = 1
22sensor_id = 1
23select = [1, 1, 1, 0, 0, 0]
24ft_pid = [0.0005, 0.0, 0.0, 0.0, 0.0, 0.0]
25adj_sign = 0
26ILC_sign = 0
27max_dis = 100.0
28max_ang = 0.0
29ft = [-10.0, -10.0, -10.0, 0.0, 0.0, 0.0]
30offset_pos = [0.0,0.0,0.0,0.0,0.0,0.0]  # 替代 DescPose(0, 0, 0, 0, 0, 0)
31epos = [0.0,0.0,0.0,0.0]  # 替代 ExaxisPos(0, 0, 0, 0)
32j1 = [-11.904, -99.669, 117.473, -108.616, -91.726, 74.256]  # JointPos
33j2 = [-45.615, -106.172, 124.296, -107.151, -91.282, 74.255]
34desc_p1 = [-419.524, -13.000, 351.569, -178.118, 0.314, 3.833]  # DescPose
35desc_p2 = [-321.222, 185.189, 335.520, -179.030, -1.284, -29.869]
36robot.FT_Control(flag, sensor_id, select, ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0)
37p = 0.00005
38force = 30.0
39rtn = robot.FT_ComplianceStart(p, force)
40print(f"FT_ComplianceStart rtn is {rtn}")
41count = 3
42while count > 0:
43    robot.MoveL(desc_pos=desc_p1,tool= 0,user= 0,vel= 100.0)
44    robot.MoveL(desc_pos=desc_p2,tool= 0,user= 0,vel= 100.0)
45    count -= 1
46robot.FT_ComplianceStop()
47print(f"FT_ComplianceStop rtn is {rtn}")
48flag = 0
49robot.FT_Control(flag, sensor_id, select, ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0)
50robot.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

 1from fairino import Robot
 2import time
 3# Establish a connection with the robot controller and return a robot object if the connection is successful
 4robot = Robot.RPC('192.168.58.2')
 5retval = robot.LoadIdentifyDynFilterInit()
 6print(f"LoadIdentifyDynFilterInit retval is: {retval}")
 7retval = robot.LoadIdentifyDynVarInit()
 8print(f"LoadIdentifyDynVarInit retval is: {retval}")
 9error, posJ = robot.GetActualJointPosDegree(0)
10posJ[1] += 10  # Modify joint 2
11error, joint_toq = robot.GetJointTorques(0)
12joint_toq[1] += 2  # Modify torque on joint 2
13tmpTorque = joint_toq.copy()
14retval = robot.LoadIdentifyMain(tmpTorque, posJ, 1)
15print(f"LoadIdentifyMain retval is: {retval}")
16gain = [0, 0.05, 0, 0, 0, 0, 0, 0.02, 0, 0, 0, 0]
17weight = [0.0]
18load_pos = [0.0, 0.0, 0.0]
19retval, weight, load_pos = robot.LoadIdentifyGetResult(gain)
20print(f"LoadIdentifyGetResult retval is: {retval} ; weight is {weight}  cog is {load_pos[0]} {load_pos[1]} {load_pos[2]}")
21robot.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

 1from fairino import Robot
 2import time
 3# Establish a connection with the robot controller and return a robot object if the connection is successful
 4robot = Robot.RPC('192.168.58.2')
 5robot.SetForceSensorDragAutoFlag(1)
 6M = [15.0, 15.0, 15.0, 0.5, 0.5, 0.1]
 7B = [150.0, 150.0, 150.0, 5.0, 5.0, 1.0]
 8K = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
 9F = [10.0, 10.0, 10.0, 1.0, 1.0, 1.0]
10robot.EndForceDragControl(1, 0, 0, 0, M, B, K, F, 50, 100)
11time.sleep(5)
12drag_state = 0
13six_dimensional_drag_state = 0
14error,drag_state, six_dimensional_drag_state = robot.GetForceAndTorqueDragState()
15print(f"the drag state is {drag_state} {six_dimensional_drag_state}")
16robot.EndForceDragControl(0, 0, 0, 0, M, B, K, F, 50, 100)
17robot.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

 1from fairino import Robot
 2import time
 3# Establish a connection with the robot controller and return a robot object if the connection is successful
 4robot = Robot.RPC('192.168.58.2')
 5robot.DragTeachSwitch(1)
 6lamde_dain = [3.0, 2.0, 2.0, 2.0, 2.0, 3.0]
 7k_gain = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
 8b_gain = [150.0, 150.0, 150.0, 5.0, 5.0, 1.0]
 9rtn = robot.ForceAndJointImpedanceStartStop(1, 0, lamde_dain, k_gain, b_gain, 1000, 180)
10print(f"ForceAndJointImpedanceStartStop rtn is {rtn}")
11time.sleep(5)
12robot.DragTeachSwitch(0)
13rtn = robot.ForceAndJointImpedanceStartStop(0, 0, lamde_dain, k_gain, b_gain, 1000, 180)
14print(f"ForceAndJointImpedanceStartStop rtn is {rtn}")
15robot.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

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4j1 = [102.622, -135.990, 120.769, -73.950, -90.848, 35.507]
 5j2 = [93.674, -80.062, 82.947, -92.199, -90.967, 26.559]
 6desc_pos1 = [136.552, -149.799, 449.532, 179.817, -1.172, 157.123]
 7desc_pos2 = [136.540, -561.048, 449.542, 179.819, -1.172, 157.122]
 8offset_pos = [0.0] * 6
 9epos = [0.0] * 4
10tool = 0
11user = 0
12vel = 100.0
13acc = 200.0
14ovl = 100.0
15blendT = -1.0
16blendR = -1.0
17flag = 0
18search = 0
19robot.SetSpeed(20)
20company = 17
21device = 0
22softversion = 0
23bus = 1
24robot.FT_SetConfig(company, device, softversion, bus)
25time.sleep(1)
26rnt,[company, device, softversion, bus] = robot.FT_GetConfig()
27print(f"FT config:{company},{device},{softversion},{bus}")
28time.sleep(1)
29robot.FT_Activate(0)
30time.sleep(1)
31robot.FT_Activate(1)
32time.sleep(1)
33time.sleep(1)
34robot.FT_SetZero(0)
35time.sleep(1)
36robot.FT_SetZero(1)
37time.sleep(1)
38forceThreshold = [30.0, 30.0, 30.0, 5.0, 5.0, 5.0]
39m = [0.1, 0.1, 0.1, 0.02, 0.02, 0.02]
40b = [1.0, 1.0, 1.0, 0.08, 0.08, 0.08]
41k = [0.0] * 6
42rtn = robot.ImpedanceControlStartStop(1, 1, forceThreshold, m, b, k, 1000, 500, 100, 100)
43print(f"ImpedanceControlStartStop errcode:{rtn}")
44rtn = robot.MoveL(desc_pos=desc_pos1,tool= tool,user= user,vel= vel,speedPercent=1)
45rtn = robot.MoveL(desc_pos=desc_pos2,tool= tool,user= user,vel= vel,speedPercent=1)
46rtn = robot.MoveL(desc_pos=desc_pos1,tool= tool,user= user,vel= vel,speedPercent=1)
47rtn = robot.MoveL(desc_pos=desc_pos2,tool= tool,user= user,vel= vel,speedPercent=1)
48rtn = robot.MoveL(desc_pos=desc_pos1,tool= tool,user= user,vel= vel,speedPercent=1)
49rtn = robot.MoveL(desc_pos=desc_pos2,tool= tool,user= user,vel= vel,speedPercent=1)
50print(f"movel errcode:{rtn}")
51robot.ImpedanceControlStartStop(0, 1, forceThreshold, m, b, k, 1000, 500, 100, 100)
52robot.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