7. Security 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 [], percentage range [0~1]
5* @param  [in]  config 0-Don't update config file, 1-Update config file
6* @return  Error code
7*/
8errno_t  SetAnticollision(int mode, float level[6], int config);

7.2. Set Post-Collision Strategy

Changed in version C++SDK-v2.1.5.0.

1/**
2     * @brief  Set post-collision strategy
3     * @param  [in] strategy  0-Error pause; 1-Continue running; 2-Error stop; 3-Gravity torque mode; 4-Oscillation response mode; 5-Collision rebound mode
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 factor [1-10]
7     * @return  Error code
8     */
9    errno_t SetCollisionStrategy(int strategy, int safeTime, int safeDistance, int safetyMargin[]);

7.3. Custom Collision Detection Threshold Start

New in version C++SDK-v2.2.0-3.8.0.

1     /**
2     * @brief  Start custom collision detection threshold, set joint and TCP collision detection thresholds
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 threshold j1-j6
5     * @param  [in] tcpDetectionThreshould TCP collision detection threshold, xyzabc
6     * @param  [in] block 0-Non-blocking; 1-Blocking
7     * @return  Error code
8     */
9    errno_t CustomCollisionDetectionStart(int flag, double jointDetectionThreshould[6], double tcpDetectionThreshould[6], int block);

7.4. Custom Collision Detection Threshold End

New in version C++SDK-v2.2.0-3.8.0.

1    /**
2     * @brief  Close custom collision detection threshold function
3     * @return  Error code
4     */
5    errno_t CustomCollisionDetectionEnd();

7.5. Robot Collision Level Setting Code Example

 1int TestCollision(void)
 2 {
 3     ROBOT_STATE_PKG pkg = {};
 4     FRRobot robot;
 5     robot.LoggerInit();
 6     robot.SetLoggerLevel(1);
 7     int rtn = robot.RPC("192.168.58.2");
 8     if (rtn != 0)
 9     {
10         return -1;
11     }
12     robot.SetReConnectParam(true, 30000, 500);
13     int mode = 0;
14     int config = 1;
15     float level1[6] = { 1.0,2.0,3.0,4.0,5.0,6.0 };
16     float level2[6] = { 50.0,20.0,30.0,40.0,50.0,60.0 };
17     rtn = robot.SetAnticollision(mode, level1, config);
18     printf("SetAnticollision mode 0 rtn is %d\n", rtn);
19     mode = 1;
20     rtn = robot.SetAnticollision(mode, level2, config);
21     printf("SetAnticollision mode 1 rtn is %d\n", rtn);
22     JointPos p1Joint(-11.904, -99.669, 117.473, -108.616, -91.726, 74.256);
23     JointPos p2Joint(-45.615, -106.172, 124.296, -107.151, -91.282, 74.255);
24     DescPose p1Desc(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
25     DescPose p2Desc(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
26     ExaxisPos exaxisPos(0.0, 0.0, 0.0, 0.0);
27     DescPose offdese(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
28     robot.MoveL(&p2Joint, &p2Desc, 0, 0, 100, 100, 100, 2, &exaxisPos, 0, 0, &offdese);
29     robot.ResetAllError();
30     int safety[6] = { 5,5,5,5,5,5 };
31     rtn = robot.SetCollisionStrategy(3, 1000, 150, 250, safety);
32     printf("SetCollisionStrategy rtn is %d\n", rtn);
33     double jointDetectionThreshould[6] = { 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 };
34     double tcpDetectionThreshould[6] = { 60,60,60,60,60,60 };
35     rtn = robot.CustomCollisionDetectionStart(3, jointDetectionThreshould, tcpDetectionThreshould, 0);
36     cout << "CustomCollisionDetectionStart rtn is " << rtn << endl;
37     robot.MoveL(&p1Joint, &p1Desc, 0, 0, 100, 100, 100, -1, &exaxisPos, 0, 0, &offdese);
38     robot.MoveL(&p2Joint, &p2Desc, 0, 0, 100, 100, 100, -1, &exaxisPos, 0, 0, &offdese);
39     rtn = robot.CustomCollisionDetectionEnd();
40     cout << "CustomCollisionDetectionEnd rtn is " << rtn << endl;
41     robot.CloseRPC();
42     return 0;
43 }

7.6. Set Positive Limit

1/**
2* @brief  Set positive limit
3* @param  [in] limit Six joint positions, unit deg
4* @return  Error code
5*/
6errno_t  SetLimitPositive(float limit[6]);

7.7. Set Negative Limit

1/**
2* @brief  Set negative limit
3* @param  [in] limit Six joint positions, unit deg
4* @return  Error code
5*/
6errno_t  SetLimitNegative(float limit[6]);

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 angle, unit deg
5* @param  [out] positive  Positive limit angle, unit deg
6* @return  Error code
7*/
8errno_t  GetJointSoftLimitDeg(uint8_t flag, float negative[6], float positive[6]);

7.9. Robot Limit Setting Code Example

 1int TestLimit(void)
 2{
 3  ROBOT_STATE_PKG pkg = {};
 4  FRRobot robot;
 5  robot.LoggerInit();
 6  robot.SetLoggerLevel(1);
 7  int rtn = robot.RPC("192.168.58.2");
 8  if (rtn != 0)
 9  {
10    return -1;
11  }
12  robot.SetReConnectParam(true, 30000, 500);
13  float plimit[6] = { 170.0,80.0,150.0,80.0,170.0,160.0 };
14  robot.SetLimitPositive(plimit);
15  float nlimit[6] = { -170.0,-260.0,-150.0,-260.0,-170.0,-160.0 };
16  robot.SetLimitNegative(nlimit);
17  float neg_deg[6] = { 0.0 }, pos_deg[6] = { 0.0 };
18  robot.GetJointSoftLimitDeg(0, neg_deg, pos_deg);
19  printf("neg limit deg:%f,%f,%f,%f,%f,%f\n", neg_deg[0], neg_deg[1], neg_deg[2], neg_deg[3], neg_deg[4], neg_deg[5]);
20  printf("pos limit deg:%f,%f,%f,%f,%f,%f\n", pos_deg[0], pos_deg[1], pos_deg[2], pos_deg[3], pos_deg[4], pos_deg[5]);
21  robot.CloseRPC();
22  return 0;
23}

7.10. Set Robot Collision Detection Method

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 collision level threshold; 1-Custom collision detection threshold
5* @return  Error code
6*/
7errno_t SetCollisionDetectionMethod(int method, int thresholdMode = 0);

7.11. Set Static Collision Detection On/Off

New in version C++SDK-v2.1.5.0.

1/**
2 * @brief Set static collision detection on/off
3 * @param [in] status 0-Off; 1-On
4 * @return Error code
5 */
6errno_t SetStaticCollisionOnOff(int status);

7.12. Robot Collision Detection Method Code Example

New in version C++SDK-v2.1.5.0.

 1int TestCollisionMethod(void)
 2{
 3  ROBOT_STATE_PKG pkg = {};
 4  FRRobot robot;
 5  robot.LoggerInit();
 6  robot.SetLoggerLevel(1);
 7  int rtn = robot.RPC("192.168.58.2");
 8  if (rtn != 0)
 9  {
10    return -1;
11  }
12  robot.SetReConnectParam(true, 30000, 500);
13  rtn = robot.SetCollisionDetectionMethod(0, 0);
14  printf("SetCollisionDetectionMethod rtn is %d\n", rtn);
15  rtn = robot.SetStaticCollisionOnOff(1);
16  printf("SetStaticCollisionOnOff On rtn is %d\n", rtn);
17  rtn = robot.Sleep(5000);
18  rtn = robot.SetStaticCollisionOnOff(0);
19  printf("SetStaticCollisionOnOff Off rtn is %d\n", rtn);
20  robot.CloseRPC();
21  return 0;
22}

7.13. Joint Torque Power Detection

New in version C++SDK-v2.1.5.0.

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 */
7errno_t SetPowerLimit(int status, double power);

7.14. Joint Torque Power Detection Code Example

 1int TestPowerLimit(void)
 2{
 3   ROBOT_STATE_PKG pkg = {};
 4   FRRobot robot;
 5   robot.LoggerInit();
 6   robot.SetLoggerLevel(1);
 7   int rtn = robot.RPC("192.168.58.2");
 8   if (rtn != 0)
 9   {
10      return -1;
11   }
12   robot.SetReConnectParam(true, 30000, 500);
13   robot.DragTeachSwitch(1);
14   robot.SetPowerLimit(1, 200);
15   float torques[] = { 0, 0, 0, 0, 0, 0 };
16   robot.GetJointTorques(1, torques);
17   int count = 100;
18   robot.ServoJTStart();
19   int error = 0;
20   while (count > 0)
21   {
22      error = robot.ServoJT(torques, 0.001);
23      count = count - 1;
24      robot.Sleep(1);
25   }
26   error = robot.ServoJTEnd();
27   robot.DragTeachSwitch(0);
28   robot.CloseRPC();
29   return 0;
30}

7.15. Set Safety Speed Parameters

1/**
2* @brief Set safety speed parameters
3* @param [in] enable 0-off; 1-enabled in manual mode; 2-enabled in all modes
4* @param [in] maxTCPVel Maximum TCP speed limit; [0-1000] mm/s
5* @param [in] strategy Strategy after overspeed; 0-stop with alarm; 1-automatic speed limiting; 2-stop with alarm and disable
6* @return Error code
7*/
8errno_t SetVelReducePara(int enable, double maxTCPVel, int strategy);

7.16. SDK Code Example for Setting Safety Speed Parameters

 1int TestSetVelReducePara()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot;
 5    robot.LoggerInit();
 6    robot.SetLoggerLevel(1);
 7    int rtn = robot.RPC("192.168.58.2");
 8    if (rtn != 0)
 9    {
10        return -1;
11    }
12    robot.SetReConnectParam(true, 30000, 500);
13    JointPos j1(0, -90, 90, 0, 0, 0);
14    JointPos j2(90, -90, 90, 0, 0, 0);
15    ExaxisPos epos(0, 0, 0, 0);
16    DescPose offset_pos(0, 0, 0, 0, 0, 0);
17    robot.SetSpeed(80);
18    rtn = robot.SetVelReducePara(2, 30, 1);
19    printf("SetVelReducePara param error rtn is %d\n", rtn);
20    rtn = robot.SetVelReducePara(0, 30, 1);
21    printf("SetVelReducePara disable reduce vel rtn is %d\n", rtn);
22    robot.MoveJ(&j1, 0, 0, 100, 100, 100, &epos, -1, 0, &offset_pos);
23    robot.MoveJ(&j2, 0, 0, 100, 100, 100, &epos, -1, 0, &offset_pos);
24    rtn = robot.SetVelReducePara(1, 30, 1);
25    printf("SetVelReducePara reduce vel rtn is %d\n", rtn);
26    robot.MoveJ(&j1, 0, 0, 100, 100, 100, &epos, -1, 0, &offset_pos);
27    robot.MoveJ(&j2, 0, 0, 100, 100, 100, &epos, -1, 0, &offset_pos);
28    rtn = robot.SetVelReducePara(2, 30, 2);
29    printf("SetVelReducePara disable robot rtn is %d\n", rtn);
30    robot.MoveJ(&j1, 0, 0, 100, 100, 100, &epos, -1, 0, &offset_pos);
31    robot.MoveJ(&j2, 0, 0, 100, 100, 100, &epos, -1, 0, &offset_pos);
32    robot.Sleep(2000);
33    robot.ResetAllError();
34    robot.RobotEnable(1);
35    robot.Sleep(1000);
36    rtn = robot.SetVelReducePara(2, 30, 0);
37    printf("SetVelReducePara report error rtn is %d\n", rtn);
38    robot.MoveJ(&j1, 0, 0, 100, 100, 100, &epos, -1, 0, &offset_pos);
39    robot.MoveJ(&j2, 0, 0, 100, 100, 100, &epos, -1, 0, &offset_pos);
40    robot.CloseRPC();
41    robot.Sleep(1000);
42    return 0;
43}