7. Security Settings

7.1. Setting the collision level

Prototype

SetAnticollision (mode,level,config)

Description

Setting the collision level

Mandatory parameters

  • mode: 0 - level, 1 - percentage;

  • level=[j1,j2,j3,j4,j5,j6]: collision threshold;

  • config: 0 - do not update configuration file, 1 - update configuration file

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

7.2. Setting the post-collision strategy

Prototype

SetCollisionStrategy(strategy,safeTime,safeDistance,safeVel,safetyMargin)

Description

Set post-crash strategy

Mandatory parameters

  • strategy: 0 - report error and pause, 1 - keep running, 2 - error stop, 3 - heavy moment mode, 4 - shock response mode, 5 - impact rebound mode

Default parameters

  • safeTime: safe stop time [1000-2000] ms, default: 1000

  • safeDistance: safe stopping distance [1-150] mm, default: 100

  • safeVel: safe stopping speed[50-250]mm/s, default: 250

  • safetyMargin[6]: safety margin [1-10], default: [10,10,10,10,10,10,10]

Return Value

Error Code Success-0 Failure- errcode

7.3. The Custom collision detection threshold function starts to set the collision detection thresholds of the joint end and TCP end

New in version python: SDK-v2.1.0

Prototype

CustomCollisionDetectionStart(flag, jointDetectionThreshould, tcpDetectionThreshould, block)

Description

The Custom collision detection threshold function starts to set the collision detection thresholds of the joint end and TCP end

Mandatory parameters

  • flag: 1- Only joint detection is turned on; 2- Only TCP detection is enabled. 3- Joint and TCP detection are enabled simultaneously

  • jointDetectionThreshould: Joint collision detection threshold j1-j6

  • tcpDetectionThreshould: indicates TCP collision detection threshold, xyzabc

  • block: 0- non-blocking; 1- block

Default parameters

NULL

Return Value

  • errcode Success-0 Failure- errcode

7.4. The custom collision detection threshold function is disabled

New in version python: SDK-v2.1.0

Prototype

CustomCollisionDetectionEnd()

Description

The custom collision detection threshold function is disabled

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errcode Success-0 Failure- errcode

7.5. Robot collision level setting 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')
 5mode = 0
 6config = 1
 7level1 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
 8level2 = [50.0, 20.0, 30.0, 40.0, 50.0, 60.0]
 9rtn = robot.SetAnticollision(mode, level1, config)
10print(f"SetAnticollision mode 0 rtn is {rtn}")
11mode = 1
12rtn = robot.SetAnticollision(mode, level2, config)
13print(f"SetAnticollision mode 1 rtn is {rtn}")
14p1Joint = [-11.904, -99.669, 117.473, -108.616, -91.726, 74.256]
15p2Joint = [-45.615, -106.172, 124.296, -107.151, -91.282, 74.255]
16p1Desc = [-419.524, -13.000, 351.569, -178.118, 0.314, 3.833]
17p2Desc = [-321.222, 185.189, 335.520, -179.030, -1.284, -29.869]
18exaxisPos = [0.0, 0.0, 0.0, 0.0]
19offdese = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
20robot.MoveL(desc_pos=p2Desc, tool=0, user=0, vel=100, blendR=2)
21robot.ResetAllError()
22safety = [5, 5, 5, 5, 5, 5]
23rtn = robot.SetCollisionStrategy(3, 1000, 150, 250, safety)
24print(f"SetCollisionStrategy rtn is {rtn}")
25jointDetectionThreshould = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1]
26tcpDetectionThreshould = [60, 60, 60, 60, 60, 60]
27rtn = robot.CustomCollisionDetectionStart(3, jointDetectionThreshould, tcpDetectionThreshould, 0)
28print(f"CustomCollisionDetectionStart rtn is {rtn}")
29robot.MoveL(desc_pos=p1Desc, tool=0, user=0, vel=100)
30robot.MoveL(desc_pos=p2Desc, tool=0, user=0, vel=100)
31rtn = robot.CustomCollisionDetectionEnd()
32print(f"CustomCollisionDetectionEnd rtn is {rtn}")
33robot.CloseRPC()

7.6. Setting the positive limit

Prototype

SetLimitPositive(p_limit)

Description

Setting positive limits

Mandatory parameters

  • p_limit=[j1,j2,j3,j4,j5,j6]: six joint positions

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

7.7. Setting the negative limit

Prototype

SetLimitNegative(n_limit)

Description

Setting negative limits

Mandatory parameters

  • n_limit=[j1,j2,j3,j4,j5,j6]: six joint positions

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

7.8. Obtaining the soft limiting angle of a joint

Prototype

GetJointSoftLimitDeg(flag=1)

Description

Acquisition of joint soft limiting angle

Mandatory parameters

NULL

Default parameters

flag: 0-blocking, 1-non-blocking Default 1

Return Value

  • errorcode Success-0 Failure- errcode

  • [j1min,j1max,j2min,j2max,j3min,j3max, j4min,j4max,j5min, j5max, j6min,j6max]: Axis 1 to Axis 6, joints with negative and positive limits, in [mm]

7.9. Robot limit setting 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')
 5plimit = [170.0, 80.0, 150.0, 80.0, 170.0, 160.0]
 6robot.SetLimitPositive(plimit)
 7nlimit = [-170.0, -260.0, -150.0, -260.0, -170.0, -160.0]
 8robot.SetLimitNegative(nlimit)
 9error,neg_deg = robot.GetJointSoftLimitDeg(0)
10print(f"pos limit deg: {neg_deg[1]}, {neg_deg[3]}, {neg_deg[5]}, {neg_deg[7]}, {neg_deg[9]}, {neg_deg[11]}")
11print(f"neg limit deg: {neg_deg[0]}, {neg_deg[2]}, {neg_deg[4]}, {neg_deg[6]}, {neg_deg[8]}, {neg_deg[10]}")
12robot.CloseRPC()

7.10. Setting up a robot collision detection method

New in version python: SDK-v2.1.2

prototype

SetCollisionDetectionMethod(method, thresholdMode)

Description

Sets the robot collision detection method.

Mandatory parameters

  • method: collision detection method: 0 - current mode; 1 - dual encoder; 2 - current and dual encoder on at the same time

  • thresholdMode: Collision level threshold method 0-Collision level fixed threshold mode 1- Customize collision detection thresholds

Default parameters

NULL

Return Value

  • errcode Success-0 Failure- errcode

7.11. Set static undercollision detection to start off

New in version python: SDK-v2.0.5

Prototype

SetStaticCollisionOnOff(status)

Description

Set static undercollision detection to start off

Mandatory parameters

  • status: 0 - off; 1 - on

Default parameters

NULL

Return Value

  • errcode Success-0 Failure- errcode

7.12. Set up the robot collision detection method 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')
 5rtn = robot.SetCollisionDetectionMethod(0,0)
 6rtn = robot.SetStaticCollisionOnOff(1)
 7print(f"SetStaticCollisionOnOff On rtn is {rtn}")
 8time.sleep(5)
 9rtn = robot.SetStaticCollisionOnOff(0)
10print(f"SetStaticCollisionOnOff Off rtn is {rtn}")
11robot.CloseRPC()

7.13. Joint torque and power detection

New in version python: SDK-v2.0.5

Prototype

SetPowerLimit(status, power)

Description

Joint torque and power detection

Mandatory parameters

  • status: 0 - off; 1 - on

  • power:Set the maximum power (W)

Default parameters

NULL

Return Value

  • errcode Success-0 Failure- errcode

7.14. Sample code for joint torque power detection

 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)
 6robot.SetPowerLimit(1, 200)
 7error,torques = robot.GetJointTorques(1)
 8count = 100
 9robot.ServoJTStart()
10while count > 0:
11    error = robot.ServoJT(torques, 0.001)
12    count -= 1
13    time.sleep(0.001)  # 1ms delay
14error = robot.ServoJTEnd()
15robot.DragTeachSwitch(0)
16robot.CloseRPC()

7.15. Set Safety Speed Parameters

Prototype

SetVelReducePara(enable, maxTCPVel, strategy)

Description

Set safety speed parameters

Required Parameters

  • enable: 0-off; 1-enabled in manual mode; 2-enabled in all modes (automatic speed limiting not supported)

  • maxTCPVel: Maximum TCP speed limit; [0-1000] mm/s

  • strategy: Strategy after overspeed; 0-stop with alarm; 1-automatic speed limiting; 2-stop with alarm and disable

Default Parameters

None

Return Value

  • Error code Success-0 Failure-errcode

7.16. SDK Code Example for Setting Safety Speed Parameters

 1from time import sleep
 2import time
 3from fairino import Robot
 4
 5# Establish connection with robot controller
 6robot = Robot.RPC('192.168.58.2')
 7
 8def TestSetVelReducePara(self):
 9    # Initialize joint position, external axis and offset
10    j1 = [0, -90, 90, 0, 0, 0]
11    j2 = [90, -90, 90, 0, 0, 0]
12    epos = [0, 0, 0, 0]
13    offset_pos = [0, 0, 0, 0, 0, 0]
14
15    # Set base speed
16    robot.SetSpeed(80)
17
18    # Test parameter error case (mode=2 invalid?)
19    rtn = robot.SetVelReducePara(2, 30, 1)
20    print(f"SetVelReducePara param error rtn is {rtn}")
21
22    # Disable speed reduction function (mode=0, action=1 indicates disable)
23    rtn = robot.SetVelReducePara(0, 30, 1)
24    print(f"SetVelReducePara disable reduce vel rtn is {rtn}")
25    robot.MoveJ(joint_pos=j1, tool=0, user=0, vel=100, acc=100, ovl=100,
26                exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
27    robot.MoveJ(joint_pos=j2, tool=0, user=0, vel=100, acc=100, ovl=100,
28                exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
29
30    # Enable speed reduction function (mode=1, action=1)
31    rtn = robot.SetVelReducePara(1, 30, 1)
32    print(f"SetVelReducePara reduce vel rtn is {rtn}")
33    robot.MoveJ(joint_pos=j1, tool=0, user=0, vel=100, acc=100, ovl=100,
34                exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
35    robot.MoveJ(joint_pos=j2, tool=0, user=0, vel=100, acc=100, ovl=100,
36                exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
37
38    # Test action=2 (may indicate emergency stop or disable robot)
39    rtn = robot.SetVelReducePara(2, 30, 2)
40    print(f"SetVelReducePara disable robot rtn is {rtn}")
41    robot.MoveJ(joint_pos=j1, tool=0, user=0, vel=100, acc=100, ovl=100,
42                exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
43    robot.MoveJ(joint_pos=j2, tool=0, user=0, vel=100, acc=100, ovl=100,
44                exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
45
46    # Wait, reset errors and re-enable robot
47    time.sleep(2)
48    robot.ResetAllError()
49    robot.RobotEnable(1)
50    time.sleep(1)
51
52    # Test action=0 (may indicate only report error, no action)
53    rtn = robot.SetVelReducePara(2, 30, 0)
54    print(f"SetVelReducePara report error rtn is {rtn}")
55    robot.MoveJ(joint_pos=j1, tool=0, user=0, vel=100, acc=100, ovl=100,
56                exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
57    robot.MoveJ(joint_pos=j2, tool=0, user=0, vel=100, acc=100, ovl=100,
58                exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
59
60    # Close connection
61    robot.CloseRPC()
62
63TestSetVelReducePara(robot)