7. Robot safety settings
7.1. Set collision level
1/**
2* @brief Set collision level
3* @param [in] mode 0-level, 1-percentage
4* @param [in] level Collision threshold. Level range: [1-10 corresponds to levels 1-10, 100-disabled]. Percentage range: [0~10 corresponds to 0% - 100%]
5* @param [in] config 0-Do not update config file, 1-Update config file
6* @return Error code
7*/
8int SetAnticollision(int mode, Object[] level, int config);
7.2. Set post-collision strategy
1/**
2* @brief Set post-collision strategy
3* @param [in] strategy 0-Report error and stop, 1-Continue running
4* @param [in] safeTime Safe stop time [1000 - 2000]ms
5* @param [in] safeDistance Safe stop distance [1-150]mm
6* @param [in] safetyMargin J1-J6 safety coefficients [1-10]
7* @return Error code
8*/
9int SetCollisionStrategy(int strategy, int safeTime, int safeDistance, int safetyMargin[]);
7.3. Custom collision detection threshold function start
New in version Java: SDK-v1.0.3-3.8.0
1/**
2* @brief Start custom collision detection threshold function. Set collision detection thresholds for joints and TCP
3* @param [in] flag 1-Joint detection only; 2-TCP detection only; 3-Both joint and TCP detection
4* @param [in] jointDetectionThreshould Joint collision detection thresholds for J1-J6
5* @param [in] tcpDetectionThreshould TCP collision detection thresholds for xyzabc
6* @param [in] block 0-Non-blocking; 1-Blocking
7* @return Error code
8*/
9public int CustomCollisionDetectionStart(int flag, double[] jointDetectionThreshould, double[] tcpDetectionThreshould, int block);
7.4. Custom collision detection threshold function end
New in version Java: SDK-v1.0.3-3.8.0
1/**
2* @brief End custom collision detection threshold function
3* @return Error code
4*/
5public int CustomCollisionDetectionEnd();
7.5. Robot collision level setting code example
1public static int TestCollision(Robot robot)
2{
3 int mode = 0;
4 int config = 1;
5 Object[] level1 = new Object[]{ 1.0,2.0,3.0,4.0,5.0,6.0 };
6 Object[] level2 = new Object[]{ 50.0,20.0,30.0,40.0,50.0,60.0 };
7
8 int rtn = robot.SetAnticollision(mode, level1, config);
9 System.out.println("SetAnticollision mode 0 rtn is: "+ rtn);
10 mode = 1;
11 rtn = robot.SetAnticollision(mode, level2, config);
12 System.out.println("SetAnticollision mode 1 rtn is :"+ rtn);
13
14 JointPos p1Joint=new JointPos(-11.904, -99.669, 117.473, -108.616, -91.726, 74.256);
15 JointPos p2Joint=new JointPos(-45.615, -106.172, 124.296, -107.151, -91.282, 74.255);
16
17 DescPose p1Desc=new DescPose(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
18 DescPose p2Desc=new DescPose(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
19
20 ExaxisPos exaxisPos=new ExaxisPos(0.0, 0.0, 0.0, 0.0);
21 DescPose offdese=new DescPose(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
22 robot.MoveL(p2Joint, p2Desc, 0, 0, 100, 100, 100, 2,0, exaxisPos, 0, 0, offdese,0,10);
23 robot.ResetAllError();
24 int[] safety = new int[]{ 5,5,5,5,5,5 };
25 rtn = robot.SetCollisionStrategy(3, 1000, 150, 250, safety);
26 System.out.println("SetCollisionStrategy rtn is:"+ rtn);
27
28 double[] jointDetectionThreshould = new double[]{ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 };
29 double[] tcpDetectionThreshould =new double[] { 60,60,60,60,60,60 };
30 rtn = robot.CustomCollisionDetectionStart(3, jointDetectionThreshould, tcpDetectionThreshould, 0);
31 System.out.println("CustomCollisionDetectionStart rtn is :"+ rtn);
32
33 robot.MoveL(p1Joint, p1Desc, 0, 0, 100, 100, 100, -1,0, exaxisPos, 0, 0, offdese,0,10);
34 robot.MoveL(p2Joint, p2Desc, 0, 0, 100, 100, 100, -1,0, exaxisPos, 0, 0, offdese,0,10);
35 rtn = robot.CustomCollisionDetectionEnd();
36 System.out.println("CustomCollisionDetectionEnd rtn is: "+ rtn);
37 return 0;
38}
7.6. Set positive limit
1/**
2* @brief Set positive limit
3* @param [in] limit Six joint positions in deg
4* @return Error code
5*/
6int SetLimitPositive(Object[] limit);
7.7. Set negative limit
1/**
2* @brief Set negative limit
3* @param [in] limit Six joint positions in deg
4* @return Error code
5*/
6int SetLimitNegative(Object[] limit);
7.8. Get joint soft limit angles
1/**
2* @brief Get joint soft limit angles
3* @param [in] flag 0-Blocking, 1-Non-blocking
4* @param [out] negative Negative limit angles in deg
5* @param [out] positive Positive limit angles in deg
6* @return Error code
7*/
8int GetJointSoftLimitDeg(int flag, Object[] negative, Object[] positive);
7.9. Robot limit setting code example
1public static int TestLimit(Robot robot)
2{
3 Object[] plimit =new Object[] { 170.0,80.0,150.0,80.0,170.0,160.0 };
4 robot.SetLimitPositive(plimit);
5 Object[] nlimit =new Object[] { -170.0,-260.0,-150.0,-260.0,-170.0,-160.0 };
6 robot.SetLimitNegative(nlimit);
7
8 Object[] neg_deg =new Object[] {0, 0 , 0, 0, 0, 0}, pos_deg = new Object[]{0, 0 , 0, 0, 0, 0};
9 robot.GetJointSoftLimitDeg(1, neg_deg, pos_deg);
10 System.out.println("neg limit deg:"+ neg_deg[0]+","+ neg_deg[1]+","+ neg_deg[2]+","+ neg_deg[3]+","+ neg_deg[4]+","+ neg_deg[5]);
11 System.out.println("pos limit deg:"+pos_deg[0]+","+ pos_deg[1]+","+ pos_deg[2]+","+ pos_deg[3]+","+ pos_deg[4]+","+pos_deg[5]);
12 return 0;
13}
7.10. Set robot collision detection method
Changed in version Java: SDK-v1.0.5-3.8.2
1/**
2* @brief Set robot collision detection method
3* @param [in] method Collision detection method: 0-Current mode; 1-Dual encoder; 2-Both current and dual encoder
4* @param [in] thresholdMode Collision level threshold method: 0-Fixed threshold; 1-Custom collision detection threshold
5* @return Error code
6*/
7int SetCollisionDetectionMethod(int method,int thresholdMode)
7.11. Set static collision detection on/off
1/**
2* @brief Set static collision detection on/off
3* @param [in] status 0-Off; 1-On
4* @return Error code
5*/
6public int SetStaticCollisionOnOff(int status)
7.12. Robot collision detection method code example
1public static int TestCollisionMethod(Robot robot)
2{
3 int rtn = robot.SetCollisionDetectionMethod(0);
4
5 rtn = robot.SetStaticCollisionOnOff(1);
6 System.out.println("SetStaticCollisionOnOff On rtn is:"+ rtn);
7 robot.Sleep(5000);
8 rtn = robot.SetStaticCollisionOnOff(0);
9 System.out.println("SetStaticCollisionOnOff Off rtn is:"+ rtn);
10
11 robot.CloseRPC();
12 return 0;
13}
7.13. Joint torque power detection
1/**
2* @brief Joint torque power detection
3* @param [in] status 0-Off; 1-On
4* @param [in] power Set maximum power (W)
5* @return Error code
6*/
7public int SetPowerLimit(int status, double power)
7.14. Joint torque power detection code example
1public static int TestPowerLimit(Robot robot)
2{
3 robot.DragTeachSwitch(1);
4 robot.SetPowerLimit(1, 200);
5 List<Number> joint_toq=new ArrayList<>();
6 joint_toq=robot.GetJointTorques(1);
7
8 int count = 100;
9 robot.ServoJTStart(); // #servoJT start
10 int error = 0;
11 while (count > 0)
12 {
13 count = count - 1;
14 robot.Sleep(1);
15 }
16 error = robot.ServoJTEnd();
17 robot.DragTeachSwitch(0);
18
19 robot.CloseRPC();
20 return 0;
21}
7.15. Set Safety Speed Parameters
1/**
2* @brief Set safety speed parameters
3* @param enable 0-off; 1-enabled in manual mode; 2-enabled in all modes (automatic speed limiting not supported)
4* @param maxTCPVel Maximum TCP speed limit; [0-1000] mm/s
5* @param strategy Strategy after overspeed; 0-stop with alarm; 1-automatic speed limiting; 2-stop with alarm and disable
6* @return Error code
7*/
8public int SetVelReducePara(int enable, double maxTCPVel, int strategy)
7.16. SDK Code Example for Setting Safety Speed Parameters
1public static int TestSetVelReducePara(Robot robot) {
2 int rtn = 0;
3
4 JointPos j1 = new JointPos(0, -90, 90, 0, 0, 0);
5 JointPos j2 = new JointPos(90, -90, 90, 0, 0, 0);
6 ExaxisPos epos = new ExaxisPos(0, 0, 0, 0);
7 DescPose offset_pos = new DescPose(0, 0, 0, 0, 0, 0);
8
9 robot.SetSpeed(80);
10 rtn = robot.SetVelReducePara(2, 30, 1);
11 System.out.printf("SetVelReducePara param error rtn is %d\n", rtn);
12
13 rtn = robot.SetVelReducePara(0, 30, 1);
14 System.out.printf("SetVelReducePara disable reduce vel rtn is %d\n", rtn);
15 robot.MoveJ(j1, 0, 0, 100, 100, 100.0, epos, -1.0, 0, offset_pos);
16 robot.MoveJ(j2, 0, 0, 100, 100, 100.0, epos, -1.0, 0, offset_pos);
17
18 rtn = robot.SetVelReducePara(1, 30, 1);
19 System.out.printf("SetVelReducePara reduce vel rtn is %d\n", rtn);
20 robot.MoveJ(j1, 0, 0, 100, 100, 100.0, epos, -1.0, 0, offset_pos);
21 robot.MoveJ(j2, 0, 0, 100, 100, 100.0, epos, -1.0, 0, offset_pos);
22
23 rtn = robot.SetVelReducePara(2, 30, 2);
24 System.out.printf("SetVelReducePara disable robot rtn is %d\n", rtn);
25 robot.MoveJ(j1, 0, 0, 100, 100, 100.0, epos, -1.0, 0, offset_pos);
26 robot.MoveJ(j2, 0, 0, 100, 100, 100.0, epos, -1.0, 0, offset_pos);
27
28 robot.Sleep(2000);
29 robot.ResetAllError();
30 robot.RobotEnable(1);
31 robot.Sleep(1000);
32
33 rtn = robot.SetVelReducePara(2, 30, 0);
34 System.out.printf("SetVelReducePara report error rtn is %d\n", rtn);
35 robot.MoveJ(j1, 0, 0, 100, 100, 100.0, epos, -1.0, 0, offset_pos);
36 robot.MoveJ(j2, 0, 0, 100, 100, 100.0, epos, -1.0, 0, offset_pos);
37
38 robot.Sleep(1000);
39 return 0;
40}