7. Impostazioni Sicurezza Robot

7.1. Impostare Livello Collisione

1/**
2* @brief Impostare Livello Collisione
3* @param  [in]  mode  0-livello, 1-percentuale
4* @param  [in]  level Soglia collisione, livello corrisponde range[], percentuale corrisponde range[0~1]
5* @param  [in]  config 0-non aggiornare file configurazione, 1-aggiornare file configurazione
6* @return   Codice errore
7*/
8int SetAnticollision(int mode, double[] level, int config);

7.2. Impostare Strategia Post-Collisione

 1/**
 2* @brief  Impostare Strategia Post-Collisione
 3* @param  [in] strategy  0-segnala errore e pausa; 1-continua esecuzione; 2-segnala errore e arresto; 3-modalità coppia gravità; 4-modalità risposta oscillazione; 5-modalità rimbalzo collisione
 4* @param  [in] safeTime  Tempo arresto sicuro [1000 - 2000]ms
 5* @param  [in] safeDistance  Distanza arresto sicuro [1-150]mm
 6* @param  [in] safeVel  Velocità arresto sicuro TCP [50-250]mm/s
 7* @param  [in] safetyMargin  Coefficiente sicurezza j1-j6 [1-10]
 8* @return   Codice errore
 9*/
10int SetCollisionStrategy(int strategy, int safeTime, int safeDistance, int safeVel,int[] safetyMargin);

7.3. Inizio Funzione Soglia Rilevamento Collisione Personalizzata

1/**
2* @brief  Inizio Funzione Soglia Rilevamento Collisione Personalizzata, impostare soglia rilevamento collisione lato articolare e TCP
3* @param  [in] flag 1-solo rilevamento articolare attivo; 2-solo rilevamento TCP attivo; 3-rilevamento articolare e TCP simultaneamente attivo
4* @param  [in] jointDetectionThreshould Soglia rilevamento collisione articolare j1-j6
5* @param  [in] tcpDetectionThreshould Soglia rilevamento collisione TCP, xyzabc
6* @param  [in] block 0-non bloccante; 1-bloccante
7* @return   Codice errore
8*/
9int CustomCollisionDetectionStart(int flag, double[] jointDetectionThreshould, double[] tcpDetectionThreshould, int block);

7.4. Fine Funzione Soglia Rilevamento Collisione Personalizzata

1/**
2* @brief  Fine Funzione Soglia Rilevamento Collisione Personalizzata
3* @return   Codice errore
4*/
5int CustomCollisionDetectionEnd()

7.5. Esempio Codice Impostazione Livello Collisione Robot

 1private void button24_Click(object sender, EventArgs e)
 2{
 3    int mode = 0;
 4    int config = 1;
 5    double[] level1 = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f };
 6    double[] level2 = { 50.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f };
 7
 8    int rtn = robot.SetAnticollision(mode, level1, config);
 9    Console.WriteLine($"SetAnticollision mode 0 rtn is {rtn}");
10    mode = 1;
11    rtn = robot.SetAnticollision(mode, level2, config);
12    Console.WriteLine($"SetAnticollision mode 1 rtn is {rtn}");
13
14    JointPos p1Joint = new JointPos(-11.904f, -99.669f, 117.473f, -108.616f, -91.726f, 74.256f);
15    JointPos p2Joint = new JointPos(-45.615f, -106.172f, 124.296f, -107.151f, -91.282f, 74.255f);
16
17    DescPose p1Desc = new DescPose(-419.524f, -13.000f, 351.569f, -178.118f, 0.314f, 3.833f);
18    DescPose p2Desc = new DescPose(-321.222f, 185.189f, 335.520f, -179.030f, -1.284f, -29.869f);
19
20    ExaxisPos exaxisPos = new ExaxisPos(0.0f, 0.0f, 0.0f, 0.0f);
21    DescPose offdese = new DescPose(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
22    robot.MoveL( p2Joint,  p2Desc, 0, 0, 100, 100, 100, 2,  exaxisPos, 0, 0,  offdese);
23    robot.ResetAllError();
24    int[] safety = { 5, 5, 5, 5, 5, 5 };
25    rtn = robot.SetCollisionStrategy(3, 1000, 150, 250, safety);
26    Console.WriteLine($"SetCollisionStrategy rtn is {rtn}");
27
28    double[] jointDetectionThreshould = { 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 };
29    double[] tcpDetectionThreshould = { 60, 60, 60, 60, 60, 60 };
30    rtn = robot.CustomCollisionDetectionStart(3, jointDetectionThreshould, tcpDetectionThreshould, 0);
31    Console.WriteLine($"CustomCollisionDetectionStart rtn is {rtn}");
32
33    robot.MoveL( p1Joint,  p1Desc, 0, 0, 100, 100, 100, -1,  exaxisPos, 0, 0,  offdese);
34    robot.MoveL( p2Joint,  p2Desc, 0, 0, 100, 100, 100, -1,  exaxisPos, 0, 0,  offdese);
35    rtn = robot.CustomCollisionDetectionEnd();
36    Console.WriteLine($"CustomCollisionDetectionEnd rtn is {rtn}");
37}

7.6. Impostare Limite Positivo

1/**
2* @brief  Impostare Limite Positivo
3* @param  [in] limit Sei posizioni articolari, unità deg
4* @return   Codice errore
5*/
6int SetLimitPositive(double[] limit);

7.7. Impostare Limite Negativo

1/**
2* @brief  Impostare Limite Negativo
3* @param  [in] limit Sei posizioni articolari, unità deg
4* @return   Codice errore
5*/
6int SetLimitNegative(double[] limit);

7.8. Ottenere Angoli Limiti Software Articolari

1/**
2* @brief  Ottenere Angoli Limiti Software Articolari
3* @param  [in] flag 0-bloccante, 1-non bloccante
4* @param  [out] negative  Angoli limite negativo, unità deg
5* @param  [out] positive  Angoli limite positivo, unità deg
6* @return   Codice errore
7*/
8int GetJointSoftLimitDeg(byte flag, ref double[] negative, ref double[] positive);

7.9. Esempio Codice Impostazione Limiti Robot

 1private void btnRobotSafetySet_Click(object sender, EventArgs e)
 2{
 3    double[] plimit = { 170.0f, 80.0f, 150.0f, 80.0f, 170.0f, 160.0f };
 4    robot.SetLimitPositive(plimit);
 5    double[] nlimit = { -170.0f, -260.0f, -150.0f, -260.0f, -170.0f, -160.0f };
 6    robot.SetLimitNegative(nlimit);
 7
 8    double[] neg_deg = new double[6] {0,0,0,0,0,0 };
 9    double[] pos_deg = new double[6] { 0, 0, 0, 0, 0, 0 };
10    robot.GetJointSoftLimitDeg(0, ref neg_deg,ref pos_deg);
11    Console.WriteLine($"neg limit deg:{neg_deg[0]},{neg_deg[1]},{neg_deg[2]},{neg_deg[3]},{neg_deg[4]},{neg_deg[5]}");
12    Console.WriteLine($"pos limit deg:{pos_deg[0]},{pos_deg[1]},{pos_deg[2]},{pos_deg[3]},{pos_deg[4]},{pos_deg[5]}");
13}

7.10. Impostare Metodo Rilevamento Collisione Robot

1/**
2* @brief Impostare Metodo Rilevamento Collisione Robot
3* @param  [in] method Metodo rilevamento collisione: 0-modalità corrente; 1-doppio encoder; 2-corrente e doppio encoder simultaneamente attivi
4* @param [in] thresholdMode Modalità soglia livello collisione; 0-modalità soglia fissa livello collisione; 1-soglia rilevamento collisione personalizzata
5* @return   Codice errore
6*/
7int SetCollisionDetectionMethod(int method,int thresholdMode=0);

7.11. Impostare Inizio/Arresto Rilevamento Collisione Statica

1/**
2* @brief Impostare Inizio/Arresto Rilevamento Collisione Statica
3* @param  [in] status 0-arresto; 1-inizio
4* @return   Codice errore
5*/
6int SetStaticCollisionOnOff(int status);

7.12. Esempio Codice Impostazione Metodo Rilevamento Collisione Robot

 1private void button26_Click(object sender, EventArgs e)
 2{
 3    int rtn = robot.SetCollisionDetectionMethod(0, 0);
 4
 5    rtn = robot.SetStaticCollisionOnOff(1);
 6    Console.WriteLine($"SetStaticCollisionOnOff On rtn is {rtn}");
 7    Thread.Sleep(5000);
 8    rtn = robot.SetStaticCollisionOnOff(0);
 9    Console.WriteLine($"SetStaticCollisionOnOff Off rtn is {rtn}");
10}

7.13. Rilevamento Potenza Coppia Articolare

1/**
2* @brief Rilevamento Potenza Coppia Articolare
3* @param  [in] status 0-arresto; 1-inizio
4* @param  [in] power Impostare potenza massima(W)
5* @return   Codice errore
6*/
7int SetPowerLimit(int status, double power);

7.14. Esempio Codice Rilevamento Potenza Coppia Articolare

 1private void button26_Click(object sender, EventArgs e)
 2{
 3    robot.DragTeachSwitch(1);
 4    robot.SetPowerLimit(1, 200);
 5    double[] torques = { 0, 0, 0, 0, 0, 0 };
 6    robot.GetJointTorques(1, torques);
 7
 8    int count = 100;
 9    robot.ServoJTStart();
10    int error = 0;
11    while (count > 0)
12    {
13        error = robot.ServoJT(torques, 0.001f);
14        count--;
15        Thread.Sleep(1);
16    }
17    error = robot.ServoJTEnd();
18    robot.DragTeachSwitch(0);
19}

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à (limitazione automatica della velocità non supportata)
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*/
8public int SetVelReducePara(int enable, double maxTCPVel, int strategy)

7.16. Esempio di Codice SDK per Impostare i Parametri di Velocità di Sicurezza

 1public int TestSetVelReducePara()
 2{
 3    int rtn = 0;
 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
11    // Test errore parametro
12    rtn = robot.SetVelReducePara(2, 30, 1);
13    Console.WriteLine($"SetVelReducePara param error rtn is {rtn}");
14
15    // Disabilita riduzione velocità
16    rtn = robot.SetVelReducePara(0, 30, 1);
17    Console.WriteLine($"SetVelReducePara disable reduce vel rtn is {rtn}");
18    robot.MoveJ(j1, 0, 0, 100, 100, 100, epos, -1, 0, offset_pos);
19    robot.MoveJ(j2, 0, 0, 100, 100, 100, epos, -1, 0, offset_pos);
20
21    // Abilita riduzione velocità (modalità manuale)
22    rtn = robot.SetVelReducePara(1, 30, 1);
23    Console.WriteLine($"SetVelReducePara reduce vel rtn is {rtn}");
24    robot.MoveJ(j1, 0, 0, 100, 100, 100, epos, -1, 0, offset_pos);
25    robot.MoveJ(j2, 0, 0, 100, 100, 100, epos, -1, 0, offset_pos);
26
27    // Abilitato in tutte le modalità, strategia: ferma con allarme e disabilita
28    rtn = robot.SetVelReducePara(2, 30, 2);
29    Console.WriteLine($"SetVelReducePara disable robot rtn is {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
33    Thread.Sleep(2000);
34    robot.ResetAllError();
35    robot.RobotEnable(1);
36    Thread.Sleep(1000);
37
38    // Abilitato in tutte le modalità, strategia: ferma con allarme (parametri normali)
39    rtn = robot.SetVelReducePara(2, 30, 0);
40    Console.WriteLine($"SetVelReducePara report error rtn is {rtn}");
41    robot.MoveJ(j1, 0, 0, 100, 100, 100, epos, -1, 0, offset_pos);
42    robot.MoveJ(j2, 0, 0, 100, 100, 100, epos, -1, 0, offset_pos);
43
44    Thread.Sleep(1000);
45    return 0;
46}