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

Added 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

Added 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

Added 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

Added 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

Added 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-manual mode enable; 2-all modes enable
4* @param [in] maxTCPVel Maximum TCP speed limit; [0-1000] mm/s
5* @param [in] strategy Post-overspeed strategy; 0-stop and alarm; 1-auto speed limit; 2-stop and alarm with disable
6* @param [in] maxJointVel Maximum speed for 6 joints (°/s), default 45°/s
7* @return Error code
8*/
9errno_t SetVelReducePara(int enable, double maxTCPVel, int strategy, std::vector<double> maxJointVel = {45.0, 45.0, 45.0, 45.0, 45.0, 45.0});

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}

7.17. Code Example for Setting Robot Joint Safety Speed

 1int TestSetJointVelReducePara()
 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(10.220, -11.121, -118.086, -46.739, 82.036, 131.503);
14    JointPos j2(89.782, -11.122, -118.086, -46.740, 82.036, 131.504);
15    ExaxisPos epos(0, 0, 0, 0);
16    DescPose offset_pos(0, 0, 0, 0, 0, 0);
17    robot.SetSpeed(20);
18
19    std::vector<double> maxJointVelA = {100.0, 100.0, 100.0, 100.0, 100.0, 100.0 };
20    rtn = robot.SetVelReducePara(2, 200, 0, maxJointVelA);
21    printf("SetVelReducePara param error rtn is %d\n", rtn);
22    robot.MoveJ(&j1, 1, 2, 100, 100, 100, &epos, -1, 0, &offset_pos);
23    robot.MoveJ(&j2, 1, 2, 100, 100, 100, &epos, -1, 0, &offset_pos);
24    std::vector<double> maxJointVelB = { 20.0, 20.0, 20.0, 20.0, 20.0, 20.0 };
25    rtn = robot.SetVelReducePara(2, 200, 0, maxJointVelB);
26    printf("SetVelReducePara reduce vel rtn is %d\n", rtn);
27    robot.MoveJ(&j1, 1, 2, 100, 100, 100, &epos, -1, 0, &offset_pos);
28    robot.MoveJ(&j2, 1, 2, 100, 100, 100, &epos, -1, 0, &offset_pos);
29    robot.Sleep(2000);
30    robot.CloseRPC();
31    return 0;
32}

7.18. Get Safety Configuration Parameter Checksum

1/**
2* @brief Get safety configuration parameter checksum
3* @param [out] status Verification status, 0-valid, 1-verifying, 2-verification failed
4* @param [out] checksum Checksum, 8-digit hexadecimal
5* @return  Error code
6*/
7errno_t GetSafetyParamsCheckSum(int& status, uint32_t& checksum);

7.19. Safety Operation Password Verification

1/**
2* @brief Safety operation password verification
3* @param [in] status Verification, 0-enable, 1-disable
4* @param [in] password Password
5* @return Error code
6*/
7errno_t SafetyOPPasswordCheck(int status, std::string password);

7.20. Safety Configuration Parameter Password Verification Code Example

 1int TestSafetyParamsCheckSum()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot;
 5    robot.LoggerInit();
 6    robot.SetLoggerLevel(1);
 7    robot.SetReConnectParam(true, 30000, 500);
 8    int rtn = robot.RPC("192.168.58.2");
 9    if (rtn != 0)
10    {
11        return -1;
12    }
13    int status = 0;
14    uint32_t checksum = 0;
15    rtn = robot.GetSafetyParamsCheckSum(status, checksum);
16    printf("GetSafetyParamsCheckSum: error=%d, status=%d, hex_code=  0x%x  \n", rtn, status, checksum);
17    robot.Sleep(3000);
18    rtn = robot.SafetyOPPasswordCheck(0, "123");
19    printf("SafetyOPPasswordCheck: error= %d\n", rtn);
20    float level1[6] = { 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 };
21    rtn = robot.SetAnticollision(0, level1, 1);
22    printf("SetAnticollision: error=%d\n", rtn);
23    int safety[6] = { 10, 10, 10, 10, 10, 10 };
24    rtn = robot.SetCollisionStrategy(0, 1000, 150, 0, safety);
25    printf("SetCollisionStrategy rtn is %d\n", rtn);
26    robot.Sleep(1000);
27    rtn = robot.GetSafetyParamsCheckSum(status, checksum);
28    printf("GetSafetyParamsCheckSum(again): error=%d, status=%d, hex_code=  0x%x  \n", rtn, status, checksum);
29    robot.Sleep(2000);
30    robot.CloseRPC();
31    return 0;
32}

7.21. Set TLS Encryption Certificate Path

1/**
2* @brief Set the TLS encryption certificate path
3* @param [in] certPath  Certificate path; if empty, the default is the certificate in the directory where the executable file is located; certificate names: ca.crt; client.crt; client.key
4* @return Error code
5*/
6errno_t MtlsLink(std::string certPath = "");

7.22. Code Example for Setting the TLS Encryption Certificate Path

 1int TestSendModeTcp()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot(true);
 5    int rtn = 0;
 6    robot.LoggerInit();
 7    robot.SetLoggerLevel(1);
 8    rtn = robot.SetCmdRpyCallback(UDPFrameCallBack);
 9    robot.MtlsLink("D://TLSCERTS/");
10    robot.SetReConnectParam(true, 300000, 50);
11    rtn = robot.RPC("192.168.58.2");
12    if (rtn != 0)
13    {
14        return -1;
15    }
16
17    std::string mode0 = "/f/bIII52III236III7IIIMode(0)III/b/f";
18    std::string mode1 = "/f/bIII52III236III7IIIMode(1)III/b/f";
19    printf("[SEND] %s\n", mode0.c_str());
20    robot.SendTCPFrame(mode0);
21    robot.Sleep(1000);
22    printf("[SEND] %s\n", mode1.c_str());
23    robot.SendTCPFrame(mode1);
24    robot.Sleep(1000);
25    printf("[SEND] %s\n", mode0.c_str());
26    robot.SendTCPFrame(mode0);
27    robot.CloseRPC();
28    robot.Sleep(1000);
29    return 0;
30}