7. Configurazione Sicurezza Robot
7.1. Impostare Livello Rilevamento Collisioni
1/**
2* @brief Imposta il livello di rilevamento collisioni
3* @param [in] mode 0-livello, 1-percentuale
4* @param [in] level Soglia di collisione, intervallo per livello [], intervallo per percentuale [0~1]
5* @param [in] config 0-non aggiornare file di configurazione, 1-aggiorna file di configurazione
6* @return Codice errore
7*/
8errno_t SetAnticollision(int mode, float level[6], int config);
7.2. Impostare Strategia dopo Collisione
Cambiato nella versione C++SDK-v2.1.5.0.
1/**
2 * @brief Imposta la strategia dopo una collisione
3 * @param [in] strategy 0-segnala errore e pausa; 1-continua esecuzione; 2-segnala errore e ferma; 3-modalità coppia gravità; 4-modalità risposta oscillazioni; 5-modalità rimbalzo da collisione
4 * @param [in] safeTime Tempo di arresto sicuro [1000 - 2000] ms
5 * @param [in] safeDistance Distanza di arresto sicuro [1-150] mm
6 * @param [in] safetyMargin Fattori di sicurezza j1-j6 [1-10]
7 * @return Codice errore
8 */
9 errno_t SetCollisionStrategy(int strategy, int safeTime, int safeDistance, int safetyMargin[]);
7.3. Inizio Funzione Soglia Rilevamento Collisioni Personalizzata
Nuovo nella versione C++SDK-v2.2.0-3.8.0.
1 /**
2 * @brief Inizia funzione soglia rilevamento collisioni personalizzata, imposta le soglie di rilevamento collisioni per lato articolare e TCP
3 * @param [in] flag 1-attiva solo rilevamento articolare; 2-attiva solo rilevamento TCP; 3-attiva sia rilevamento articolare che TCP
4 * @param [in] jointDetectionThreshould Soglia rilevamento collisioni articolari j1-j6
5 * @param [in] tcpDetectionThreshould Soglia rilevamento collisioni TCP, xyzabc
6 * @param [in] block 0-non bloccante; 1-bloccante
7 * @return Codice errore
8 */
9 errno_t CustomCollisionDetectionStart(int flag, double jointDetectionThreshould[6], double tcpDetectionThreshould[6], int block);
7.4. Fine Funzione Soglia Rilevamento Collisioni Personalizzata
Nuovo nella versione C++SDK-v2.2.0-3.8.0.
1 /**
2 * @brief Disattiva funzione soglia rilevamento collisioni personalizzata
3 * @return Codice errore
4 */
5 errno_t CustomCollisionDetectionEnd();
7.5. Esempio di Codice Impostazione Livello Collisioni Robot
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. Impostare Limiti Positivi (Soft Limit)
1/**
2* @brief Imposta i limiti positivi (soft limit)
3* @param [in] limit Posizioni delle sei articolazioni, unità deg
4* @return Codice errore
5*/
6errno_t SetLimitPositive(float limit[6]);
7.7. Impostare Limiti Negativi (Soft Limit)
1/**
2* @brief Imposta i limiti negativi (soft limit)
3* @param [in] limit Posizioni delle sei articolazioni, unità deg
4* @return Codice errore
5*/
6errno_t SetLimitNegative(float limit[6]);
7.8. Ottenere Angoli Limiti Articolari Soft
1/**
2* @brief Ottiene gli angoli dei limiti articolari soft
3* @param [in] flag 0-bloccante, 1-non bloccante
4* @param [out] negative Angoli limite negativi, unità deg
5* @param [out] positive Angoli limite positivi, unità deg
6* @return Codice errore
7*/
8errno_t GetJointSoftLimitDeg(uint8_t flag, float negative[6], float positive[6]);
7.9. Esempio di Codice Impostazione Limiti Robot
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. Impostare Metodo Rilevamento Collisioni Robot
1/**
2* @brief Imposta il metodo di rilevamento collisioni del robot
3* @param [in] method Metodo di rilevamento collisioni: 0-modalità corrente; 1-doppio encoder; 2-attiva sia corrente che doppio encoder
4* @param [in] thresholdMode Modalità soglia livello collisioni; 0-modalità soglia fissa per livello collisioni; 1-soglia di rilevamento collisioni personalizzata
5* @return Codice errore
6*/
7errno_t SetCollisionDetectionMethod(int method, int thresholdMode = 0);
7.11. Impostare Attivazione/Disattivazione Rilevamento Collisioni in Stato Statico
Nuovo nella versione C++SDK-v2.1.5.0.
1/**
2 * @brief Imposta attivazione/disattivazione rilevamento collisioni in stato statico
3 * @param [in] status 0-disattiva; 1-attiva
4 * @return Codice errore
5 */
6errno_t SetStaticCollisionOnOff(int status);
7.12. Esempio di Codice Impostazione Metodo Rilevamento Collisioni Robot
Nuovo nella versione 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. Rilevamento Potenza Coppia Articolare
Nuovo nella versione C++SDK-v2.1.5.0.
1/**
2 * @brief Rilevamento potenza coppia articolare
3 * @param [in] status 0-disattiva; 1-attiva
4 * @param [in] power Imposta potenza massima (W);
5 * @return Codice errore
6 */
7errno_t SetPowerLimit(int status, double power);
7.14. Esempio di Codice Rilevamento Potenza Coppia Articolare
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. Imposta i Parametri di Velocità di Sicurezza
1/**
2* @brief Imposta i parametri di velocità di sicurezza
3* @param [in] enable 0-disabilitato; 1-abilitato in modalità manuale; 2-abilitato in tutte le modalità
4* @param [in] maxTCPVel Limite massimo velocità TCP; [0-1000] mm/s
5* @param [in] strategy Strategia dopo superamento velocità; 0-ferma con allarme; 1-limitazione automatica della velocità; 2-ferma con allarme e disabilita
6* @return Codice di errore
7*/
8errno_t SetVelReducePara(int enable, double maxTCPVel, int strategy);
7.16. Esempio di Codice SDK per Impostare i Parametri di Velocità di Sicurezza
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}