11. Periferiche del Robot

11.1. Configurare la pinza

1/**
2* @brief  Configura la pinza
3* @param  [in] company  Produttore pinza, da definire
4* @param  [in] device  Numero dispositivo, attualmente non utilizzato, predefinito 0
5* @param  [in] softvesion  Numero versione software, attualmente non utilizzato, predefinito 0
6* @param  [in] bus  Posizione bus terminale su cui è montato il dispositivo, attualmente non utilizzato, predefinito 0
7* @return  Codice di errore
8*/
9errno_t  SetGripperConfig(int company, int device, int softvesion, int bus);

11.2. Ottenere la configurazione della pinza

1/**
2* @brief  Ottiene la configurazione della pinza
3* @param  [in] company  Produttore pinza, da definire
4* @param  [in] device  Numero dispositivo, attualmente non utilizzato, predefinito 0
5* @param  [in] softvesion  Numero versione software, attualmente non utilizzato, predefinito 0
6* @param  [in] bus  Posizione bus terminale su cui è montato il dispositivo, attualmente non utilizzato, predefinito 0
7* @return  Codice di errore
8*/
9errno_t  GetGripperConfig(int *company, int *device, int *softvesion, int *bus);

11.3. Attivare la pinza

1/**
2* @brief  Attiva la pinza
3* @param  [in] index  Numero pinza
4* @param  [in] act  0-Ripristina, 1-Attiva
5* @return  Codice di errore
6*/
7errno_t  ActGripper(int index, uint8_t act);

11.4. Controllare la pinza

Cambiato nella versione C++SDK-v2.1.5.0.

 1/**
 2 * @brief  Controlla la pinza
 3 * @param  [in] index  Numero pinza
 4 * @param  [in] pos  Percentuale posizione, intervallo [0~100]
 5 * @param  [in] vel  Percentuale velocità, intervallo [0~100]
 6 * @param  [in] force  Percentuale coppia, intervallo [0~100]
 7 * @param  [in] max_time  Tempo massimo attesa, intervallo [0~30000], unità ms
 8 * @param  [in] block  0-Blocco, 1-Non bloccante
 9 * @param  [in] type Tipo pinza, 0-Pinza parallela; 1-Pinza rotante
10 * @param  [in] rotNum Numero rotazioni
11 * @param  [in] rotVel Percentuale velocità rotazione [0-100]
12 * @param  [in] rotTorque Percentuale coppia rotazione [0-100]
13 * @return  Codice di errore
14 */
15errno_t MoveGripper(int index, int pos, int vel, int force, int max_time, uint8_t block, int type, double rotNum, int rotVel, int rotTorque);

11.5. Ottenere lo stato di movimento della pinza

1/**
2 * @brief  Ottiene lo stato di movimento della pinza
3 * @param  [out] fault  0-Nessun errore, 1-Errore presente
4 * @param  [out] staus  0-Movimento non completato, 1-Movimento completato
5 * @return  Codice di errore
6 */
7errno_t  GetGripperMotionDone(uint16_t *fault, uint8_t *status);

11.6. Ottenere lo stato di attivazione della pinza

1/**
2 * @brief  Ottiene lo stato di attivazione della pinza
3 * @param  [out] fault  0-Nessun errore, 1-Errore presente
4 * @param  [out] status  bit0~bit15 corrisponde ai numeri pinza 0~15, bit=0 non attivata, bit=1 attivata
5 * @return  Codice di errore
6 */
7errno_t  GetGripperActivateStatus(uint16_t *fault, uint16_t *status);

11.7. Ottenere la posizione della pinza

1/**
2 * @brief  Ottiene la posizione della pinza
3 * @param  [out] fault  0-Nessun errore, 1-Errore presente
4 * @param  [out] position  Percentuale posizione, intervallo 0~100%
5 * @return  Codice di errore
6 */
7errno_t  GetGripperCurPosition(uint16_t *fault, uint8_t *position);

11.8. Ottenere la velocità della pinza

1/**
2 * @brief  Ottiene la velocità della pinza
3 * @param  [out] fault  0-Nessun errore, 1-Errore presente
4 * @param  [out] speed  Percentuale velocità, intervallo 0~100%
5 * @return  Codice di errore
6 */
7errno_t  GetGripperCurSpeed(uint16_t *fault, int8_t *speed);

11.9. Ottenere la corrente della pinza

1/**
2 * @brief  Ottiene la corrente della pinza
3 * @param  [out] fault  0-Nessun errore, 1-Errore presente
4 * @param  [out] current  Percentuale corrente, intervallo 0~100%
5 * @return  Codice di errore
6 */
7errno_t  GetGripperCurCurrent(uint16_t *fault, int8_t *current);

11.10. Ottenere la tensione della pinza

1/**
2 * @brief  Ottiene la tensione della pinza
3 * @param  [out] fault  0-Nessun errore, 1-Errore presente
4 * @param  [out] voltage  Tensione, unità 0.1V
5 * @return  Codice di errore
6 */
7errno_t  GetGripperVoltage(uint16_t *fault, int *voltage);

11.11. Ottenere la temperatura della pinza

1/**
2 * @brief  Ottiene la temperatura della pinza
3 * @param  [out] fault  0-Nessun errore, 1-Errore presente
4 * @param  [out] temp  Temperatura, unità ℃
5 * @return  Codice di errore
6 */
7errno_t  GetGripperTemp(uint16_t *fault, int *temp);

11.12. Calcolare punto pre-presa - visione

1/**
2 * @brief  Calcola punto pre-presa - visione
3 * @param  [in] desc_pos  Posa cartesiana punto presa
4 * @param  [in] zlength   Spostamento asse z
5 * @param  [in] zangle    Spostamento rotazione asse z
6 * @return  Codice di errore
7 */
8errno_t  ComputePrePick(DescPose *desc_pos, double zlength, double zangle, DescPose *pre_pos);

11.13. Calcolare punto ritiro - visione

1/**
2 * @brief  Calcola punto ritiro - visione
3 * @param  [in] desc_pos  Posa cartesiana punto presa
4 * @param  [in] zlength   Spostamento asse z
5 * @param  [in] zangle    Spostamento rotazione asse z
6 * @return  Codice di errore
7 */
8errno_t  ComputePostPick(DescPose *desc_pos, double zlength, double zangle, DescPose *post_pos);

11.14. Esempio di codice per operazioni pinza robot

 1int TestGripper(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 company = 4;
14  int device = 0;
15  int softversion = 0;
16  int bus = 2;
17  int index = 2;
18  int act = 0;
19  int max_time = 30000;
20  uint8_t block = 0;
21  uint8_t status;
22  uint16_t fault;
23  uint16_t active_status = 0;
24  uint8_t current_pos = 0;
25  int8_t current = 0;
26  int voltage = 0;
27  int temp = 0;
28  int8_t speed = 0;
29  robot.SetGripperConfig(company, device, softversion, bus);
30  std::this_thread::sleep_for(std::chrono::milliseconds(1000));
31  robot.GetGripperConfig(&company, &device, &softversion, &bus);
32  printf("gripper config:%d,%d,%d,%d\n", company, device, softversion, bus);
33  robot.ActGripper(index, act);
34  std::this_thread::sleep_for(std::chrono::milliseconds(1000));
35  act = 1;
36  robot.ActGripper(index, act);
37  std::this_thread::sleep_for(std::chrono::milliseconds(1000));
38  robot.MoveGripper(index, 100, 50, 50, max_time, block, 0, 0, 0, 0);
39  std::this_thread::sleep_for(std::chrono::milliseconds(1000));
40  robot.MoveGripper(index, 0, 50, 0, max_time, block, 0, 0, 0, 0);
41  robot.GetGripperMotionDone(&fault, &status);
42  printf("motion status:%u,%u\n", fault, status);
43  robot.GetGripperActivateStatus(&fault, &active_status);
44  printf("gripper active fault is: %u, status is: %u\n", fault, active_status);
45  robot.GetGripperCurPosition(&fault, &current_pos);
46  printf("fault is:%u, current position is: %u\n", fault, current_pos);
47  robot.GetGripperCurCurrent(&fault, &current);
48  printf("fault is:%u, current current is: %d\n", fault, current);
49  robot.GetGripperVoltage(&fault, &voltage);
50  printf("fault is:%u, current voltage is: %d \n", fault, voltage);
51  robot.GetGripperTemp(&fault, &temp);
52  printf("fault is:%u, current temperature is: %d\n", fault, temp);
53  robot.GetGripperCurSpeed(&fault, &speed);
54  printf("fault is:%u, current speed is: %d\n", fault, speed);
55  int retval = 0;
56  DescPose prepick_pose = {};
57  DescPose postpick_pose = {};
58  DescPose p1Desc(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
59  DescPose p2Desc(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
60  retval = robot.ComputePrePick(&p1Desc, 10, 0, &prepick_pose);
61  printf("ComputePrePick retval is: %d\n", retval);
62  printf("xyz is: %f, %f, %f; rpy is: %f, %f, %f\n", prepick_pose.tran.x, prepick_pose.tran.y, prepick_pose.tran.z, prepick_pose.rpy.rx, prepick_pose.rpy.ry, prepick_pose.rpy.rz);
63  retval = robot.ComputePostPick(&p2Desc, -10, 0, &postpick_pose);
64  printf("ComputePostPick retval is: %d\n", retval);
65  printf("xyz is: %f, %f, %f; rpy is: %f, %f, %f\n", postpick_pose.tran.x, postpick_pose.tran.y, postpick_pose.tran.z, postpick_pose.rpy.rx, postpick_pose.rpy.ry, postpick_pose.rpy.rz);
66  robot.CloseRPC();
67  return 0;
68}

11.15. Ottenere il numero di rotazioni della pinza rotante

Nuovo nella versione 3.7.6版本加入.

1/**
2 * @brief  Ottiene il numero di rotazioni della pinza rotante
3 * @param  [out] fault  0-Nessun errore, 1-Errore presente
4 * @param  [out] num  Numero rotazioni
5 * @return  Codice di errore
6 */
7errno_t GetGripperRotNum(uint16_t* fault, double* num);

11.16. Ottenere la velocità di rotazione della pinza rotante

Nuovo nella versione V3.7.6.

1/**
2 * @brief  Ottiene la velocità di rotazione della pinza rotante
3 * @param  [out] fault  0-Nessun errore, 1-Errore presente
4 * @param  [out] speed  Percentuale velocità rotazione
5 * @return  Codice di errore
6 */
7errno_t GetGripperRotSpeed(uint16_t* fault, int* speed);

11.17. Ottenere la coppia di rotazione della pinza rotante

Nuovo nella versione V3.7.6.

1/**
2 * @brief  Ottiene la coppia di rotazione della pinza rotante
3 * @param  [out] fault  0-Nessun errore, 1-Errore presente
4 * @param  [out] torque  Percentuale coppia rotazione
5 * @return  Codice di errore
6 */
7errno_t GetGripperRotTorque(uint16_t* fault, int* torque);

11.18. Esempio di codice per ottenere lo stato della pinza rotante

 1int TestRotGripperState(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  uint16_t fault = 0;
14  double rotNum = 0.0;
15  int rotSpeed = 0;
16  int rotTorque = 0;
17  robot.GetGripperRotNum(&fault, &rotNum);
18  robot.GetGripperRotSpeed(&fault, &rotSpeed);
19  robot.GetGripperRotTorque(&fault, &rotTorque);
20  printf("gripper rot num : %lf, gripper rotSpeed : %d, gripper rotTorque : %d\n", rotNum, rotSpeed, rotTorque);
21  robot.CloseRPC();
22  return 0;
23}

11.19. Avvio/arresto nastro trasportatore

1/**
2* @brief Avvio/arresto nastro trasportatore
3* @param [in] status Stato, 1-Avvia, 0-Arresta
4* @return Codice di errore
5*/
6errno_t ConveyorStartEnd(uint8_t status);

11.20. Registrare punto rilevamento IO

1/**
2* @brief Registra punto rilevamento IO
3* @return Codice di errore
4*/
5errno_t ConveyorPointIORecord();

11.21. Registrare punto A

1/**
2* @brief Registra punto A
3* @return Codice di errore
4*/
5errno_t ConveyorPointARecord();

11.22. Registrare punto di riferimento

1/**
2* @brief Registra punto di riferimento
3* @return Codice di errore
4*/
5errno_t ConveyorRefPointRecord();

11.23. Registrare punto B

1/**
2* @brief Registra punto B
3* @return Codice di errore
4*/
5errno_t ConveyorPointBRecord();

11.24. Rilevamento IO pezzo nastro trasportatore

1/**
2* @brief Rilevamento IO pezzo nastro trasportatore
3* @param [in] max_t Tempo massimo rilevamento, unità ms
4* @return Codice di errore
5*/
6errno_t ConveyorIODetect(int max_t);

11.25. Ottenere posizione corrente oggetto

1/**
2* @brief Ottiene posizione corrente oggetto
3* @param [in] mode
4* @return Codice di errore
5*/
6errno_t ConveyorGetTrackData(int mode);

11.26. Inizio tracciamento nastro trasportatore

1/**
2* @brief Inizio tracciamento nastro trasportatore
3* @param [in] status Stato, 1-Avvia, 0-Arresta
4* @return Codice di errore
5*/
6errno_t ConveyorTrackStart(uint8_t status);

11.27. Fine tracciamento nastro trasportatore

1/**
2* @brief Fine tracciamento nastro trasportatore
3* @return Codice di errore
4*/
5errno_t ConveyorTrackEnd();

11.28. Configurazione parametri nastro trasportatore

Cambiato nella versione C++SDK-v2.2.1-3.8.1.

 1/**
 2* @brief Configurazione parametri nastro trasportatore
 3* @param [in] para[0] Canale encoder 1~2
 4* @param [in] para[1] Impulsi per giro encoder
 5* @param [in] para[2] Distanza percorrenza nastro per giro encoder
 6* @param [in] para[3] Numero sistema coordinate pezzo Per funzione tracciamento movimento seleziona numero sistema coordinate pezzo, per tracciamento presa, tracciamento TPD imposta 0
 7* @param [in] para[4] Configura visione 0 non configurato 1 configurato
 8* @param [in] para[5] Rapporto velocità Per opzione tracciamento presa nastro trasportatore (1-100) Altre opzioni predefinite 1
 9* @param [in] followType Tipo movimento tracciamento, 0-Movimento tracciamento; 1-Movimento inseguimento verifica
10* @param [in] startDis Necessario per presa inseguimento verifica, distanza inizio tracciamento, -1: calcolo automatico (avvio automatico inseguimento verifica quando pezzo raggiunge sotto robot), unità mm, valore predefinito 0
11* @param [in] endDis Necessario per presa inseguimento verifica, distanza fine tracciamento, unità mm, valore predefinito 100
12* @return Codice di errore
13*/
14errno_t ConveyorSetParam(float para[6], int followType = 0, int startDis = 0, int endDis = 100);

11.29. Compensazione punto presa nastro trasportatore

Cambiato nella versione C++SDK-v2.1.2.0.

1/**
2 * @brief Compensazione punto presa nastro trasportatore
3 * @param [in] cmp Posizione compensazione double[3]{x, y, z}
4 * @return Codice di errore
5 */
6errno_t ConveyorCatchPointComp(double cmp[3]);

11.30. Movimento lineare nastro trasportatore

1/**
2* @brief Movimento lineare nastro trasportatore
3* @param [in] status Stato, 1-Avvia, 0-Arresta
4* @return Codice di errore
5*/
6errno_t TrackMoveL(char name[32], int tool, int wobj, float vel, float acc, float ovl, float blendR, uint8_t flag, uint8_t type);

11.31. Rilevamento input comunicazione nastro trasportatore

Nuovo nella versione C++SDK-v2.2.1-3.8.1.

1/**
2* @brief Rilevamento input comunicazione nastro trasportatore
3* @param [in] timeout Tempo attesa timeout ms
4* @return Codice di errore
5*/
6errno_t ConveyorComDetect(int timeout);

11.32. Trigger rilevamento input comunicazione nastro trasportatore

Nuovo nella versione C++SDK-v2.2.1-3.8.1.

1/**
2* @brief Trigger rilevamento input comunicazione nastro trasportatore
3* @return Codice di errore
4*/
5errno_t ConveyorComDetectTrigger();

11.33. Esempio programma operazioni nastro trasportatore robot

 1int TestConveyor(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 retval = 0;
14  retval = robot.ConveyorStartEnd(1);
15  printf("ConveyorStartEnd retval is: %d\n", retval);
16  retval = robot.ConveyorPointIORecord();
17  printf("ConveyorPointIORecord retval is: %d\n", retval);
18  retval = robot.ConveyorPointARecord();
19  printf("ConveyorPointARecord retval is: %d\n", retval);
20  retval = robot.ConveyorRefPointRecord();
21  printf("ConveyorRefPointRecord retval is: %d\n", retval);
22  retval = robot.ConveyorPointBRecord();
23  printf("ConveyorPointBRecord retval is: %d\n", retval);
24  retval = robot.ConveyorStartEnd(0);
25  printf("ConveyorStartEnd retval is: %d\n", retval);
26  retval = 0;
27  float param[6] = { 1,10000,200,0,0,20 };
28  retval = robot.ConveyorSetParam(param);
29  printf("ConveyorSetParam retval is: %d\n", retval);
30  double cmp[3] = { 0.0, 0.0, 0.0 };
31  retval = robot.ConveyorCatchPointComp(cmp);
32  printf("ConveyorCatchPointComp retval is: %d\n", retval);
33  int index = 1;
34  int max_time = 30000;
35  uint8_t block = 0;
36  retval = 0;
37  DescPose p1Desc(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
38  DescPose p2Desc(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
39  retval = robot.MoveCart(&p1Desc, 1, 0, 100.0, 100.0, 100.0, -1.0, -1);
40  printf("MoveCart retval is: %d\n", retval);
41  retval = robot.WaitMs(1);
42  printf("WaitMs retval is: %d\n", retval);
43  retval = robot.ConveyorIODetect(10000);
44  printf("ConveyorIODetect retval is: %d\n", retval);
45  retval = robot.ConveyorGetTrackData(1);
46  printf("ConveyorGetTrackData retval is: %d\n", retval);
47  retval = robot.ConveyorTrackStart(1);
48  printf("ConveyorTrackStart retval is: %d\n", retval);
49  retval = robot.TrackMoveL("cvrCatchPoint", 1, 0, 100, 100, 100, -1.0, 0, 0);
50  printf("TrackMoveL retval is: %d\n", retval);
51  retval = robot.MoveGripper(index, 51, 40, 30, max_time, block, 0, 0, 0, 0);
52  printf("MoveGripper retval is: %d\n", retval);
53  retval = robot.TrackMoveL("cvrRaisePoint", 1, 0, 100, 100, 100, -1.0, 0, 0);
54  printf("TrackMoveL retval is: %d\n", retval);
55  retval = robot.ConveyorTrackEnd();
56  printf("ConveyorTrackEnd retval is: %d\n", retval);
57  robot.MoveCart(&p2Desc, 1, 0, 100.0, 100.0, 100.0, -1.0, -1);
58  retval = robot.MoveGripper(index, 100, 40, 10, max_time, block, 0, 0, 0, 0);
59  printf("MoveGripper retval is: %d\n", retval);
60  rtn = robot->ConveyorComDetect(1000 * 10);
61  printf("ConveyorComDetect rtn is: %d\n", rtn);
62  robot.Sleep(2000);
63  rtn = robot->ConveyorComDetectTrigger();
64  printf("ConveyorComDetectTrigger rtn is: %d\n", rtn);
65  robot.CloseRPC();
66  return 0;
67}

11.34. Configurazione sensore terminale

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Configurazione sensore terminale
3* @param [in] idCompany Produttore, 18-JUNKONG; 25-HUIDE
4* @param [in] idDevice Tipo, 0-JUNKONG/RYR6T.V1.0
5* @param [in] idSoftware Versione software, 0-J1.0/HuiDe1.0 (non ancora disponibile)
6* @param [in] idBus Posizione montaggio, 1-Porta terminale 1; 2-Porta terminale 2...8-Porta terminale 8 (non ancora disponibile)
7* @return Codice di errore
8*/
9errno_t AxleSensorConfig(int idCompany, int idDevice, int idSoftware, int idBus);

11.35. Ottenere configurazione sensore terminale

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2 * @brief Ottiene configurazione sensore terminale
3 * @param [out] idCompany Produttore, 18-JUNKONG; 25-HUIDE
4 * @param [out] idDevice Tipo, 0-JUNKONG/RYR6T.V1.0
5 * @return Codice di errore
6 */
7errno_t AxleSensorConfigGet(int& idCompany, int& idDevice);

11.36. Attivazione sensore terminale

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2 * @brief Attivazione sensore terminale
3 * @param [in] actFlag 0-Ripristino; 1-Attivazione
4 * @return Codice di errore
5 */
6errno_t AxleSensorActivate(int actFlag);

11.37. Scrittura registro sensore terminale

Nuovo nella versione C++SDK-v2.1.5.0.

 1/**
 2 * @brief Scrittura registro sensore terminale
 3 * @param [in] devAddr Numero indirizzo dispositivo 0-255
 4 * @param [in] regHAddr Indirizzo registro alto 8 bit
 5 * @param [in] regLAddr Indirizzo registro basso 8 bit
 6 * @param [in] regNum Numero registri 0-255
 7 * @param [in] data1 Valore registro scritto 1
 8 * @param [in] data2 Valore registro scritto 2
 9 * @param [in] isNoBlock 0-Blocco; 1-Non bloccante
10 * @return Codice di errore
11 */
12errno_t AxleSensorRegWrite(int devAddr, int regHAddr, int regLAddr, int regNum, int data1, int data2, int isNoBlock);

11.38. Esempio di codice sensore terminale

 1int TestAxleSensor(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.AxleSensorConfig(18, 0, 0, 1);
14  int company = -1;
15  int type = -1;
16  robot.AxleSensorConfigGet(company, type);
17  printf("company is %d, type is %d\n", company, type);
18  rtn = robot.AxleSensorActivate(1);
19  printf("AxleSensorActivate rtn is %d\n", rtn);
20  robot.Sleep(1000);
21  rtn = robot.AxleSensorRegWrite(1, 4, 6, 1, 0, 0, 0);
22  printf("AxleSensorRegWrite rtn is %d\n", rtn);
23  robot.CloseRPC();
24  return 0;
25}

11.39. Ottenere protocollo periferiche robot

Nuovo nella versione C++SDK-v2.1.3.0.

1/**
2* @brief Ottiene protocollo periferiche robot
3* @param [out] protocol Numero protocollo periferiche robot 4096-Scheda controllo assi estesi; 4097-ModbusSlave; 4098-ModbusMaster
4* @return Codice di errore
5*/
6errno_t GetExDevProtocol(int *protocol);

11.40. Impostare protocollo periferiche robot

Nuovo nella versione C++SDK-v2.1.3.0.

1/**
2* @brief Imposta protocollo periferiche robot
3* @param [in] protocol Numero protocollo periferiche robot 4096-Scheda controllo assi estesi; 4097-ModbusSlave; 4098-ModbusMaster
4* @return Codice di errore
5*/
6errno_t SetExDevProtocol(int protocol);

11.41. Esempio programma impostazione protocollo periferiche robot

Nuovo nella versione C++SDK-v2.1.3.0.

 1int TestExDevProtocol(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 protocol = 4096;
14  rtn = robot.SetExDevProtocol(protocol);
15  std::cout << "SetExDevProtocol rtn " << rtn << std::endl;
16  rtn = robot.GetExDevProtocol(&protocol);
17  std::cout << "GetExDevProtocol rtn " << rtn << " protocol is: " << protocol << std::endl;
18  robot.CloseRPC();
19  return 0;
20}

11.42. Ottenere parametri comunicazione terminale

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Ottiene parametri comunicazione terminale
3* @param param Parametri comunicazione terminale
4* @return  Codice di errore
5*/
6errno_t GetAxleCommunicationParam(AxleComParam* param);

11.43. Impostare parametri comunicazione terminale

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Imposta parametri comunicazione terminale
3* @param param  Parametri comunicazione terminale
4* @return  Codice di errore
5*/
6errno_t SetAxleCommunicationParam(AxleComParam param);

11.44. Impostare tipo trasferimento file terminale

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Imposta tipo trasferimento file terminale
3* @param type 1-File aggiornamento MCU; 2-File LUA
4* @return  Codice di errore
5*/
6errno_t SetAxleFileType(int type);

11.45. Impostare abilitazione esecuzione LUA terminale

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Imposta abilitazione esecuzione LUA terminale
3* @param enable 0-Non abilitare; 1-Abilitare
4* @return  Codice di errore
5*/
6errno_t SetAxleLuaEnable(int enable);

11.46. Ripristino errori anomali file LUA terminale

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Ripristino errori anomali file LUA terminale
3* @param status 0-Non ripristinare; 1-Ripristinare
4* @return  Codice di errore
5*/
6errno_t SetRecoverAxleLuaErr(int status);

11.47. Ripristino errori anomali file LUA terminale

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Ottiene stato abilitazione esecuzione LUA terminale
3* @param status status[0]: 0-Non abilitato; 1-Abilitato
4* @return  Codice di errore
5*/
6errno_t GetAxleLuaEnableStatus(int status[]);

11.48. Impostare tipo dispositivo terminale abilitato per LUA terminale

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Imposta tipo dispositivo terminale abilitato per LUA terminale
3* @param forceSensorEnable Stato abilitazione sensore forza, 0-Non abilitato; 1-Abilitato
4* @param gripperEnable Stato abilitazione pinza, 0-Non abilitato; 1-Abilitato
5* @param IOEnable Stato abilitazione dispositivo IO, 0-Non abilitato; 1-Abilitato
6* @return  Codice di errore
7*/
8errno_t SetAxleLuaEnableDeviceType(int forceSensorEnable, int gripperEnable, int IOEnable);

11.49. Impostare tipo dispositivo terminale abilitato per LUA terminale

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Ottiene tipo dispositivo terminale abilitato per LUA terminale
3* @param enable enable[0]:forceSensorEnable Stato abilitazione sensore forza, 0-Non abilitato; 1-Abilitato
4* @param enable enable[1]:gripperEnable Stato abilitazione pinza, 0-Non abilitato; 1-Abilitato
5* @param enable enable[2]:IOEnable Stato abilitazione dispositivo IO, 0-Non abilitato; 1-Abilitato
6* @return  Codice di errore
7*/
8errno_t GetAxleLuaEnableDeviceType(int* forceSensorEnable, int* gripperEnable, int* IOEnable);

11.50. Ottenere dispositivi terminali attualmente configurati

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Ottiene dispositivi terminali attualmente configurati
3* @param forceSensorEnable Numero dispositivo sensore forza abilitato 0-Non abilitato; 1-Abilitato
4* @param gripperEnable Numero dispositivo pinza abilitato, 0-Non abilitato; 1-Abilitato
5* @param IODeviceEnable Numero dispositivo IO abilitato, 0-Non abilitato; 1-Abilitato
6* @return  Codice di errore
7*/
8errno_t GetAxleLuaEnableDevice(int forceSensorEnable[], int gripperEnable[], int IODeviceEnable[]);

11.51. Impostare abilitazione funzione controllo azioni pinza

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Imposta abilitazione funzione controllo azioni pinza
3* @param id Numero dispositivo pinza
4* @param func func[0]-Abilitazione pinza; func[1]-Inizializzazione pinza; 2-Impostazione posizione; 3-Impostazione velocità; 4-Impostazione coppia; 6-Lettura stato pinza; 7-Lettura stato inizializzazione; 8-Lettura codice errore; 9-Lettura posizione; 10-Lettura velocità; 11-Lettura coppia
5* @return  Codice di errore
6*/
7errno_t SetAxleLuaGripperFunc(int id, int func[]);

11.52. Ottenere abilitazione funzione controllo azioni pinza

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Ottiene abilitazione funzione controllo azioni pinza
3* @param id Numero dispositivo pinza
4* @param func func[0]-Abilitazione pinza; func[1]-Inizializzazione pinza; 2-Impostazione posizione; 3-Impostazione velocità; 4-Impostazione coppia; 6-Lettura stato pinza; 7-Lettura stato inizializzazione; 8-Lettura codice errore; 9-Lettura posizione; 10-Lettura velocità; 11-Lettura coppia
5* @return  Codice di errore
6*/
7errno_t GetAxleLuaGripperFunc(int id, int func[]);

11.53. Scrittura file slave Ethercat robot

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Scrittura file slave Ethercat robot
3* @param type Tipo file slave, 1-Aggiornamento file slave; 2-Aggiornamento file configurazione slave
4* @param slaveID Numero slave
5* @param fileName Nome file upload
6* @return  Codice di errore
7*/
8errno_t SlaveFileWrite(int type, int slaveID, std::string fileName);

11.54. Upload file protocollo aperto Lua terminale

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Upload file protocollo aperto Lua terminale
3* @param filePath Percorso nome file lua locale ".../AXLE_LUA_End_DaHuan.lua"
4* @return Codice di errore
5*/
6errno_t AxleLuaUpload(std::string filePath);

11.55. Modalità boot slave Ethercat robot

Nuovo nella versione C++SDK-v2.1.5.0.

1/**
2* @brief Modalità boot slave Ethercat robot
3* @return  Codice di errore
4*/
5errno_t SetSysServoBootMode();

11.56. Esempio codice operazioni file LUA terminale robot

 1int TestAxleLua(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.AxleLuaUpload("D://zUP/AXLE_LUA_End_DaHuan.lua");
14  AxleComParam param(7, 8, 1, 0, 5, 3, 1);
15  robot.SetAxleCommunicationParam(param);
16  AxleComParam getParam;
17  robot.GetAxleCommunicationParam(&getParam);
18  printf("GetAxleCommunicationParam param is %d %d %d %d %d %d %d\n", getParam.baudRate, getParam.dataBit, getParam.stopBit, getParam.verify, getParam.timeout, getParam.timeoutTimes, getParam.period);
19  robot.SetAxleLuaEnable(1);
20  int luaEnableStatus = 0;
21  robot.GetAxleLuaEnableStatus(&luaEnableStatus);
22  robot.SetAxleLuaEnableDeviceType(0, 1, 0);
23  int forceEnable = 0;
24  int gripperEnable = 0;
25  int ioEnable = 0;
26  robot.GetAxleLuaEnableDeviceType(&forceEnable, &gripperEnable, &ioEnable);
27  printf("GetAxleLuaEnableDeviceType param is %d %d %d\n", forceEnable, gripperEnable, ioEnable);
28  int func[16] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
29  robot.SetAxleLuaGripperFunc(1, func);
30  int getFunc[16] = { 0 };
31  robot.GetAxleLuaGripperFunc(1, getFunc);
32  int getforceEnable[16] = { 0 };
33  int getgripperEnable[16] = { 0 };
34  int getioEnable[16] = { 0 };
35  robot.GetAxleLuaEnableDevice(getforceEnable, getgripperEnable, getioEnable);
36  printf("\ngetforceEnable status : ");
37  for (int i = 0; i < 16; i++)
38  {
39    printf("%d,", getforceEnable[i]);
40  }
41  printf("\ngetgripperEnable status : ");
42  for (int i = 0; i < 16; i++)
43  {
44    printf("%d,", getgripperEnable[i]);
45  }
46  printf("\ngetioEnable status : ");
47  for (int i = 0; i < 16; i++)
48  {
49    printf("%d,", getioEnable[i]);
50  }
51  printf("\n");
52  robot.ActGripper(1, 0);
53  robot.Sleep(2000);
54  robot.ActGripper(1, 1);
55  robot.Sleep(2000);
56  robot.MoveGripper(1, 90, 10, 100, 50000, 0, 0, 0, 0, 0);
57  int pos = 0;
58  while (true)
59  {
60    robot.GetRobotRealTimeState(&pkg);
61    printf("gripper pos is %u\n", pkg.gripper_position);
62    robot.Sleep(100);
63  }
64  robot.CloseRPC();
65  return 0;
66}

11.57. Ottenere stato pulsanti SmartTool

1/**
2* @brief Ottiene stato pulsanti SmartTool
3* @param [out] state Stato pulsanti manopola SmartTool; (bit0:0-Comunicazione normale; 1-Comunicazione interrotta; bit1-Annulla operazione; bit2-Svuota programma;
4bit3-Pulsante A; bit4-Pulsante B; bit5-Pulsante C; bit6-Pulsante D; bit7-Pulsante E; bit8-Pulsante IO; bit9-Manuale/automatico; bit10-Avvio)
5* @return Codice di errore
6*/
7errno_t GetSmarttoolBtnState(int& state);

11.58. Esempio codice pulsanti SmartTool

 1int main(void)
 2{
 3  ROBOT_STATE_PKG pkg = {};
 4  FRRobot robot;
 5
 6  robot.LoggerInit();
 7  robot.SetLoggerLevel(1);
 8  int rtn = robot.RPC("192.168.58.2");
 9  robot.SetReConnectParam(true, 30000, 500);
10
11  while (true)
12  {
13    int btn = 0;
14    robot.GetSmarttoolBtnState(btn);
15    cout << "smarttool " << std::bitset<sizeof(btn) * 8>(btn) << endl;
16
17    Sleep(100);
18  }
19}

11.59. Controllare ventose a matrice

1/**
2* @brief Controlla ventose a matrice
3* @param [in] slaveID Numero slave
4* @param [in] len Lunghezza
5* @param [in] ctrlValue Valore controllo
6* @return Codice di errore
7*/
8errno_t FRRobot::SetSuckerCtrl(uint8_t slaveID, uint8_t len, uint8_t ctrlValue[20]);

11.60. Ottenere stato ventose a matrice

1/**
2* @brief Ottiene stato ventose a matrice
3* @param [in] slaveID Numero slave
4* @param [out] state Stato aspirazione 0-Rilascio oggetto 1-Rilevato pezzo aspirazione riuscita 2-Nessun oggetto aspirato 3-Oggetto distaccato
5* @param [out] pressValue Vuoto corrente unità kpa
6* @param [out] error Codice errore corrente ventosa
7* @return Codice di errore
8*/
9errno_t FRRobot::GetSuckerState(uint8_t slaveID, uint8_t* state, int* pressValue, int* error);

11.61. Attendere stato ventosa

1/**
2* @brief Attende stato ventosa
3* @param [in] slaveID Numero slave
4* @param [in] state Stato aspirazione 0-Rilascio oggetto 1-Rilevato pezzo aspirazione riuscita 2-Nessun oggetto aspirato 3-Oggetto distaccato
5* @param [in] ms Tempo massimo attesa
6* @return Codice di errore
7*/
8errno_t FRRobot::WaitSuckerState(uint8_t slaveID, uint8_t state, int ms);

11.62. Esempio codice comandi controllo ventose a matrice

 1void testSucker()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot;
 5    uint8_t ctrl[20];
 6    uint8_t state;
 7    int pressVlaue;
 8    int error;
 9
10    robot.LoggerInit();
11    robot.SetLoggerLevel(1);
12    int rtn = robot.RPC("192.168.58.2");
13    if (rtn != 0)
14    {
15        return;
16    }
17    robot.SetReConnectParam(true, 30000, 500);
18    //Upload e caricamento file protocollo aperto
19    robot.OpenLuaUpload("E://项目/外设SDK/CtrlDev_sucker.lua");
20    robot.Sleep(2000);
21    robot.SetCtrlOpenLUAName(1, "CtrlDev_sucker.lua");
22    robot.UnloadCtrlOpenLUA(1);
23    robot.LoadCtrlOpenLUA(1);
24    robot.Sleep(1000);
25
26    //Controllo ventosa modalità broadcast, aspirazione massima capacità
27    ctrl[0] = 1;
28    robot.SetSuckerCtrl(0, 1, ctrl);
29
30    //Monitoraggio ciclo stato ventosa 1 e ventosa 12
31    for (int i = 0; i < 100; i++)
32    {
33        robot.GetSuckerState(1, &state, &pressVlaue, &error);
34        printf("sucker1 state is %d, pressVlaue is %d, error num is %d\n", state, pressVlaue, error);
35        robot.GetSuckerState(12, &state, &pressVlaue, &error);
36        printf("sucker12 state is %d, pressVlaue is %d, error num is %d\n", state, pressVlaue, error);
37        robot.Sleep(100);
38    }
39
40    //Attesa ventosa 1 se in stato oggetto aspirato, tempo attesa 100ms
41    int ret = robot.WaitSuckerState(1, 1, 100);
42    printf("WaitSuckerState result is  %d\n", ret);
43
44    //Modalità unicast spegnimento ventosa 1 e 12
45    ctrl[0] = 3;
46    robot.SetSuckerCtrl(1, 1, ctrl);
47    robot.SetSuckerCtrl(12, 1, ctrl);
48
49    robot.CloseRPC();
50}

11.63. Upload file LUA protocollo aperto periferiche

1/**
2 * @brief Upload file Lua
3 * @param [in] filePath Percorso nome file lua locale
4 * @return Codice di errore
5 */
6errno_t OpenLuaUpload(std::string filePath);

11.64. Ottenere parametri scheda slave

1/**
2* @brief  Ottiene parametri scheda slave
3* @param  [out] type  0-Ethercat,1-CClink, 3-Ethercat, 4-EIP
4* @param  [out] version  Versione protocollo
5* @param  [out] connState  0-Non connesso 1-Connesso
6* @return  Codice di errore
7*/
8errno_t GetFieldBusConfig(uint8_t* type, uint8_t* version, uint8_t* connState);

11.65. Scrivere DO slave

1/**
2* @brief  Scrive DO slave
3* @param  [in] DOIndex  Numero DO
4* @param  [in] wirteNum  Quantità scritta
5* @param  [in] status[8] Valori scritti, massimo 8
6* @return  Codice di errore
7*/
8errno_t FieldBusSlaveWriteDO(uint8_t DOIndex, uint8_t wirteNum, uint8_t status[8]);

11.66. Scrivere AO slave

1/**
2* @brief  Scrive AO slave
3* @param  [in] AOIndex  Numero AO
4* @param  [in] wirteNum  Quantità scritta
5* @param  [in] status[8] Valori scritti, massimo 8
6* @return  Codice di errore
7*/
8errno_t FieldBusSlaveWriteAO(uint8_t AOIndex, uint8_t wirteNum, double status[8]);

11.67. Leggere DI slave

1/**
2* @brief  Legge DI slave
3* @param  [in] DOIndex  Numero DI
4* @param  [in] readeNum  Quantità letta
5* @param  [out] status[8] Valori letti, massimo 8
6* @return  Codice di errore
7*/
8errno_t FieldBusSlaveReadDI(uint8_t DOIndex, uint8_t readNum, uint8_t status[8]);

11.68. Leggere AI slave

1/**
2* @brief  Legge AI slave
3* @param  [in] AOIndex  Numero AI
4* @param  [in] readeNum  Quantità letta
5* @param  [out] status[8] Valori letti, massimo 8
6* @return  Codice di errore
7*/
8errno_t FieldBusSlaveReadAI(uint8_t AIIndex, uint8_t readNum, double status[8]);

11.69. Attendere input DI esteso

1/**
2* @brief Attende input DI esteso
3* @param [in] DIIndex Numero DI
4* @param [in] status 0-Livello basso; 1-Livello alto
5* @param [in] waitMs Tempo massimo attesa (ms)
6* @return Codice di errore
7*/
8errno_t FRRobot::FieldBusSlaveWaitDI(uint8_t DIIndex, bool status, int waitMs);

11.70. Attendere input AI esteso

1/**
2* @brief Attende input AI esteso
3* @param [in] AIIndex Numero AI
4* @param [in] waitType 0-Maggiore di; 1-Minore di
5* @param [in] value Valore AI
6* @param [in] waitMs Tempo massimo attesa (ms)
7* @return Codice di errore
8*/
9errno_t FRRobot::FieldBusSlaveWaitAI(uint8_t AIIndex, uint8_t waitType, double value, int waitMs);

11.71. Esempio codice interfacce modalità slave

 1void testFieldBusBoard()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot;
 5    uint8_t type = 0, version = 0, connState = 0;
 6    uint8_t ctrl[8];
 7    double ctrlAO[8];
 8    static uint8_t DI[8];
 9    static double AI[8];
10
11    robot.LoggerInit();
12    robot.SetLoggerLevel(1);
13    int rtn = robot.RPC("192.168.58.2");
14    if (rtn != 0)
15    {
16        return;
17    }
18    robot.SetReConnectParam(true, 30000, 500);
19    //Upload e caricamento file protocollo aperto
20    robot.OpenLuaUpload("E://项目/外设SDK/CtrlDev_field.lua");
21    robot.Sleep(2000);
22    robot.SetCtrlOpenLUAName(3, "CtrlDev_field.lua");
23    robot.UnloadCtrlOpenLUA(3);
24    robot.LoadCtrlOpenLUA(3);
25    robot.Sleep(8000);
26
27    //Ottenere tipo protocollo, versione software, stato connessione PLC scheda slave
28    robot.GetFieldBusConfig(&type, &version, &connState);
29    printf("type is %d, version is %d,connState is %d\n", type, version, connState);
30
31    //Scrittura DO0 = 1, DO1 = 0, DO2 = 1
32    ctrl[0] = 0;
33    ctrl[1] = 1;
34    ctrl[2] = 1;
35    robot.FieldBusSlaveWriteDO(0, 3, ctrl);
36
37    //Scrittura AO2 = 0x1000
38    ctrlAO[0] = 0x1005;
39    robot.FieldBusSlaveWriteAO(2, 1, ctrlAO);
40
41    //Monitoraggio ciclo DI0~DI3 AI0~AI2
42    for (int i = 0; i < 100; i++)
43    {
44        robot.FieldBusSlaveReadDI(0, 4, DI);
45        printf("DI0 is %d, DI1 is %d,DI2 is %d,DI3 is %d\n", DI[0], DI[1], DI[2], DI[3]);
46        robot.FieldBusSlaveReadAI(0, 3, AI);
47        printf("AI0 is %d, AI1 is %d,AI2 is %d\n", AI[0], AI[1], AI[2]);
48        robot.Sleep(10);
49    }
50
51    //Attesa DI0 se è 1, tempo attesa 100ms, stampa risultato
52    int ret = robot.FieldBusSlaveWaitDI(0, 1, 100);
53    printf("FieldBusSlaveWaitDI result is  %d\n", ret);
54
55    //Attesa AI0 se maggiore di 400, tempo attesa 100ms, stampa risultato
56    ret = robot.FieldBusSlaveWaitAI(0,0,400.00,100);
57    printf("FieldBusSlaveWaitAI result is  %d\n", ret);
58
59    robot.CloseRPC();
60}

11.72. Accensione/spegnimento periferica laser

Nuovo nella versione C++SDK-v3.8.6.

1/**
2 * @brief Funzione accensione/spegnimento periferica laser
3 * @param [in] OnOff 0-Spegni 1-Accendi
4 * @param [in] weldId ID saldatura predefinito 0
5 * @return Codice di errore
6 */
7errno_t LaserTrackingLaserOnOff(int OnOff,int weldId);

11.73. Inizio/fine tracciamento laser

Nuovo nella versione C++SDK-v3.8.6.

1/**
2 * @brief Funzione inizio/fine tracciamento laser
3 * @param [in] OnOff 0-Fine 1-Inizio
4 * @param [in] coordId Numero sistema coordinate utensile periferica laser
5 * @return Codice di errore
6 */
7errno_t LaserTrackingTrackOnOff(int OnOff, int coordId);

11.74. Inizio posizionamento laser - direzione fissa

Nuovo nella versione C++SDK-v3.8.6.

 1/**
 2* @brief Posizionamento laser - direzione fissa
 3* @param [in] direction 0-x+ 1-x- 2-y+ 3-y- 4-z+ 5-z-
 4* @param [in] vel Velocità unità %
 5* @param [in] distance Distanza massima posizionamento unità mm
 6* @param [in] distance Tempo timeout posizionamento unità ms
 7* @param [in] posSensorNum Numero coordinate utensile calibrate laser
 8* @return Codice di errore
 9*/
10errno_t LaserTrackingSearchStart_xyz(int direction, int vel, int distance, int timeout, int posSensorNum);

11.75. Inizio posizionamento laser - direzione punto arbitrario

Nuovo nella versione C++SDK-v3.8.6.

 1/**
 2 * @brief Posizionamento laser - direzione arbitraria
 3 * @param [in] directionPoint Coordinate xyz punto input posizionamento
 4 * @param [in] vel Velocità unità %
 5 * @param [in] distance Distanza massima posizionamento unità mm
 6 * @param [in] distance Tempo timeout posizionamento unità ms
 7 * @param [in] posSensorNum Numero coordinate utensile calibrate laser
 8 * @return Codice di errore
 9 */
10errno_t LaserTrackingSearchStart_point(DescTran directionPoint, int vel, int distance, int timeout, int posSensorNum);

11.76. Fine posizionamento laser

Nuovo nella versione C++SDK-v3.8.6.

1/**
2 * @brief Fine posizionamento laser
3 * @return Codice di errore
4 */
5errno_t LaserTrackingSearchStop();

11.77. Configurazione parametri rete laser

Nuovo nella versione C++SDK-v3.8.6.

1/**
2 * @brief Configurazione parametri rete laser
3 * @param [in] ip Indirizzo IP periferica laser
4 * @param [in] port Numero porta periferica laser
5 * @return Codice di errore
6 */
7errno_t LaserTrackingSensorConfig(std::string ip, int port);

11.78. Configurazione periodo campionamento periferica laser

Nuovo nella versione C++SDK-v3.8.6.

1/**
2* @brief Configurazione periodo campionamento periferica laser
3* @param [in] period Periodo campionamento periferica laser unità ms
4* @return Codice di errore
5*/
6errno_t LaserTrackingSensorSamplePeriod(int period);

11.79. Caricamento driver periferica laser

Nuovo nella versione C++SDK-v3.8.6.

1/**
2 * @brief Caricamento driver periferica laser
3 * @param [in] type Tipo protocollo driver periferica laser 101-Ruiniu 102-Chuangxiang 103-Quanshi 104-Tongzhou 105-Aotai
4 * @return Codice di errore
5 */
6errno_t LoadPosSensorDriver(int type);

11.80. Scaricamento driver periferica laser

Nuovo nella versione C++SDK-v3.8.6.

1/**
2 * @brief Scaricamento driver periferica laser
3 * @return Codice di errore
4 */
5errno_t UnLoadPosSensorDriver();

11.81. Registrazione traiettoria saldatura laser

Nuovo nella versione C++SDK-v3.8.6.

1/**
2* @brief Registrazione traiettoria saldatura laser
3* @param [in] status 0-Ferma registrazione 1-Tracciamento tempo reale  2-Inizia registrazione
4* @param [in] delayTime Tempo ritardo unità ms
5* @return Codice di errore
6*/
7errno_t LaserSensorRecord1(int status, int delayTime);

11.82. Riproduzione traiettoria saldatura laser

Nuovo nella versione C++SDK-v3.8.6.

1/**
2 * @brief Riproduzione traiettoria saldatura laser
3 * @param [in] delayTime Tempo ritardo unità ms
4 * @param [in] speed Velocità unità %
5 * @return Codice di errore
6 */
7errno_t LaserSensorReplay(int delayTime, double speed);

11.83. Riproduzione tracciamento laser

Nuovo nella versione C++SDK-v3.8.6.

1/**
2 * @brief Riproduzione tracciamento laser
3 * @return Codice di errore
4 */
5errno_t MoveLTR();

11.84. Registrazione e riproduzione traiettoria saldatura laser

Nuovo nella versione C++SDK-v3.8.6.

 1/**
 2* @brief Registrazione e riproduzione traiettoria saldatura laser
 3* @param [in] delayMode Modalità 0-Tempo Ritardo 1-Distanza Ritardo
 4* @param [in] delayTime Tempo di ritardo in millisecondi (ms)
 5* @param [in] delayDisExAxisNum Numero Asse Esteso
 6* @param [in] delayDis Distanza di ritardo in millimetri (mm)
 7* @param [in] sensitivePara Coefficiente di Sensibilità della Compensazione
 8* @param [in] trackMode Tipo Tracciamento a Punto Fisso. 0-Movimento Asincrono Asse Esteso; 1-Robot
 9* @param [in] triggerMode Metodo di Attivazione Tracciamento a Punto Fisso. 0-Durata Tracciamento; 1-IO
10* @param [in] runTime Durata Tracciamento a Punto Fisso del Robot in secondi (s)
11* @param [in] speed Velocità in percentuale (%)
12* @return Codice Errore
13*/
14errno_t LaserSensorRecordandReplay(int delayMode, int delayTime, int delayDisExAxisNum, double delayDis, double sensitivePara, int trackMode, int triggerMode, double runTime, double speed);

11.85. Movimento al punto iniziale saldatura registrata

Nuovo nella versione C++SDK-v3.8.6.

1/**
2* @brief Movimento al punto iniziale saldatura registrata
3* @param [in] moveType 0-moveJ 1-moveL
4* @param [in] ovl Velocità unità %
5* @return Codice di errore
6*/
7errno_t MoveToLaserRecordStart(int moveType, double ovl);

11.86. Movimento al punto finale saldatura registrata

Nuovo nella versione C++SDK-v3.8.6.

1/**
2* @brief Movimento al punto finale saldatura registrata
3* @param [in] moveType 0-moveJ 1-moveL
4* @param [in] ovl Velocità unità %
5* @return Codice di errore
6*/
7errno_t MoveToLaserRecordEnd(int moveType, double ovl);

11.87. Movimento al punto posizionamento sensore laser

Nuovo nella versione C++SDK-v3.8.6.

 1/**
 2* @brief Movimento al punto posizionamento sensore laser
 3* @param [in] moveFlag Tipo movimento: 0-PTP; 1-LIN
 4* @param [in] ovl Fattore scala velocità, 0-100
 5* @param [in] dataFlag Selezione dati cache saldatura: 0-Esegui dati pianificati; 1-Esegui dati registrati
 6* @param [in] plateType Tipo lamiera: 0-Lastra ondulata; 1-Lastra ondulata a doppia onda; 2-Lastra recinzione; 3-Fusto; 4-Acciaio corazzato ondulato
 7* @param [in] trackOffectType Tipo offset sensore laser: 0-Nessun offset; 1-Offset sistema coordinate base; 2-Offset sistema coordinate utensile; 3-Offset dati originali sensore laser
 8* @param [in] offset Quantità offset
 9* @return Codice di errore
10*/
11errno_t MoveToLaserSeamPos(int moveFlag, double ovl, int dataFlag, int plateType, int trackOffectType, DescPose offset);

11.88. Ottenere coordinate punto posizionamento sensore laser

Nuovo nella versione C++SDK-v3.8.6.

 1/**
 2* @brief Ottiene informazioni coordinate punto posizionamento sensore laser
 3* @param [in] trackOffectType Tipo offset sensore laser: 0-Nessun offset; 1-Offset sistema coordinate base; 2-Offset sistema coordinate utensile; 3-Offset dati originali sensore laser
 4* @param [in] offset Quantità offset
 5* @param [out] jPos Posizione giunti [°]
 6* @param [out] descPos Posizione cartesiana [mm]
 7* @param [out] tool Sistema coordinate utensile
 8* @param [out] user Sistema coordinate pezzo
 9* @param [out] exaxis Posizione asse esteso [mm]
10* @return Codice di errore
11*/
12errno_t GetLaserSeamPos(int trackOffectType, DescPose offset, JointPos& jPos, DescPose& descPos, int& tool, int& user, ExaxisPos& exaxis);

11.89. Esempio codice configurazione e debug parametri sensore periferica laser

Nuovo nella versione C++SDK-v3.8.6.

 1void testLaserConfig()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot;
 5    uint8_t ctrl[20];
 6    uint8_t state;
 7    int pressVlaue;
 8    int error;
 9    robot.CloseRPC();
10    robot.LoggerInit();
11    robot.SetLoggerLevel(1);
12    int rtn = robot.RPC("192.168.58.2");
13    if (rtn != 0)
14    {
15        return;
16    }
17    robot.SetReConnectParam(true, 30000, 500);
18    //Impostare indirizzo IP e numero porta
19    robot.LaserTrackingSensorConfig("192.168.58.20", 5020);
20    //Impostare periodo campionamento
21    robot.LaserTrackingSensorSamplePeriod(20);
22    //Caricare driver
23    robot.LoadPosSensorDriver(101);
24    //Spegnere periferica laser
25    robot.LaserTrackingLaserOnOff(0,0);
26    robot.Sleep(3000);
27    //Accendere periferica laser
28    robot.LaserTrackingLaserOnOff(1, 0);
29    robot.CloseRPC();
30}

11.90. Esempio codice scansione traiettoria laser e riproduzione traiettoria

Nuovo nella versione C++SDK-v3.8.6.

 1void testLaserRecordAndReplay()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot;
 5    uint8_t ctrl[20];
 6    uint8_t state;
 7    int pressVlaue;
 8    int error;
 9    robot.CloseRPC();
10    robot.LoggerInit();
11    robot.SetLoggerLevel(1);
12    int rtn = robot.RPC("192.168.58.2");
13    if (rtn != 0)
14    {
15        return;
16    }
17    robot.SetReConnectParam(true, 30000, 500);
18
19    //Upload e caricamento file protocollo aperto
20    robot.OpenLuaUpload("E://openlua/CtrlDev_laser_ruiniu-0117.lua");
21    robot.Sleep(2000);
22    robot.SetCtrlOpenLUAName(0, "CtrlDev_laser_ruiniu-0117.lua");
23    robot.UnloadCtrlOpenLUA(0);
24    robot.LoadCtrlOpenLUA(0);
25    robot.Sleep(8000);
26    int cnt = 1;
27    while(cnt<31)
28    {
29        //Movimento al punto iniziale scansione
30        JointPos startjointPos(56.205, -117.951, 141.872, -118.149, -94.217, -122.176);
31        DescPose startdescPose(-97.552, -282.855, 26.675, 174.182, -1.338, -91.707);
32        ExaxisPos exaxisPos(0, 0, 0, 0);
33        DescPose offdese(0, 0, 0, 0, 0, 0);
34        robot.MoveL(&startjointPos, &startdescPose, 1, 0, 100, 100, 100, -1, &exaxisPos, 0, 0, &offdese, 1, 1);
35        //Inizio registrazione traiettoria
36        robot.LaserSensorRecord1(2, 10);
37        //Movimento al punto finale da registrare
38        JointPos endjointPos(68.809, -87.100, 121.120, -127.233, -95.038, -109.555);
39        DescPose enddescPose(-103.555, -464.234, 13.076, 174.179, -1.344, -91.709);
40        robot.MoveL(&endjointPos, &enddescPose, 1, 0, 30, 100, 100, -1, &exaxisPos, 0, 0, &offdese, 1, 1);
41        //Ferma registrazione
42        robot.LaserSensorRecord1(0, 10);
43        //Movimento al punto iniziale saldatura registrata
44        robot.MoveToLaserRecordStart(1, 30);
45        //Inizio riproduzione traiettoria
46        robot.LaserSensorReplay(10, 100);
47        robot.MoveLTR();
48        //Ferma riproduzione traiettoria
49        robot.LaserSensorRecord1(0, 10);
50        printf("Test stabilità scansione laser + riproduzione traiettoria %d次\n", cnt);
51        cnt++;
52    }
53    robot.CloseRPC();
54}

11.91. Esempio codice posizionamento laser e tracciamento tempo reale

Nuovo nella versione C++SDK-v3.8.6.

 1void testLasertrack()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot;
 5    uint8_t ctrl[20];
 6    uint8_t state;
 7    int pressVlaue;
 8    int error;
 9    robot.CloseRPC();
10    robot.LoggerInit();
11    robot.SetLoggerLevel(1);
12    int rtn = robot.RPC("192.168.58.2");
13
14    if (rtn != 0)
15    {
16        return;
17    }
18    robot.SetReConnectParam(true, 30000, 500);
19
20    //Upload e caricamento file protocollo aperto
21    robot.OpenLuaUpload("E://openlua/CtrlDev_laser_ruiniu-0117.lua");
22    robot.Sleep(2000);
23    robot.SetCtrlOpenLUAName(0, "CtrlDev_laser_ruiniu-0117.lua");
24    robot.UnloadCtrlOpenLUA(0);
25    robot.LoadCtrlOpenLUA(0);
26    robot.Sleep(8000);
27    int cnt = 1;
28    while (cnt < 2)
29    {
30        //Movimento al punto iniziale posizionamento
31        JointPos startjointPos(58.337, -119.628, 146.037, -116.358, -92.224, -117.654);
32        DescPose startdescPose(-53.375, -255.363, 0.919, 178.054, 1.077, -94.026);
33        ExaxisPos exaxisPos(0, 0, 0, 0);
34        DescPose offdese(0, 0, 0, 0, 0, 0);
35        DescTran directionPoint;
36        robot.MoveL(&startjointPos, &startdescPose, 1, 0, 100, 100, 100, -1, &exaxisPos, 0, 0, &offdese, 1, 1);
37
38        //Inizio posizionamento direzione -y
39        int ret = robot.LaserTrackingSearchStart_xyz(3, 100, 300, 1000, 2);
40        robot.LaserTrackingSearchStop();
41        //Se posizionamento riuscito
42        if (ret == 0)
43        {
44            //Movimento al punto posizionamento
45            robot.MoveToLaserSeamPos(1, 30, 0, 0, 0, offdese);
46            //Inizio tracciamento laser lungo punto posizionamento
47            robot.LaserTrackingTrackOnOff(1, 2);
48            JointPos endjointPos(70.580, -90.918, 126.593, -125.154, -92.162, -105.403);
49            DescPose enddescPose(-53.375, -419.020, 0.920, 178.054, 1.076, -94.026);
50            robot.MoveL(&endjointPos, &enddescPose, 1, 0, 20, 100, 100, -1, &exaxisPos, 0, 0, &offdese, 1, 1);
51            //Ferma tracciamento
52            robot.LaserTrackingTrackOnOff(0, 2);
53
54        }
55        cnt++;
56    }
57    robot.CloseRPC();
58}

11.92. Esempio codice tracciamento laser sincronizzato con assi estesi e robot

Nuovo nella versione C++SDK-v3.8.6.

 1void testLasertrackandExitAxis()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot;
 5    uint8_t ctrl[20];
 6    uint8_t state;
 7    int pressVlaue;
 8    int error;
 9    robot.CloseRPC();
10    robot.LoggerInit();
11    robot.SetLoggerLevel(1);
12    int rtn = robot.RPC("192.168.58.2");
13
14    if (rtn != 0)
15    {
16        return;
17    }
18    robot.SetReConnectParam(true, 30000, 500);
19
20    ExaxisPos startexaxisPos = { 0,0,0,0 };
21    ExaxisPos seamexaxisPos = { -10,0,0,0 };
22    ExaxisPos endexaxisPos = { -30, 0, 0, 0 };
23    DescPose offdese = { 0, 0, 0, 0, 0, 0 };
24    JointPos seamjointPos(0, 0, 0, 0, 0, 0);
25    DescPose seamdescPose(0, 0, 0, 0, 0, 0);
26
27    int cnt = 1;
28    while (cnt < 31)
29    {
30        //Movimento al punto iniziale posizionamento
31        JointPos startjointPos(58.337, -119.628, 146.037, -116.358, -92.224, -117.654);
32        DescPose startdescPose(-53.375, -255.363, 0.919, 178.054, 1.077, -94.026);
33        robot.ExtAxisSyncMoveJ(startjointPos, startdescPose, 1, 0, 100, 100, 100, startexaxisPos, -1, 0, offdese);
34
35        //Inizio posizionamento direzione -y
36        int ret = robot.LaserTrackingSearchStart_xyz(3, 100, 300, 1000, 2);
37        robot.LaserTrackingSearchStop();
38        int tool = 0;
39        int user = 0;
40        robot.GetLaserSeamPos(0, offdese, seamjointPos, seamdescPose, tool, user, startexaxisPos);
41        printf("%f, %f, %f,%f, %f, %f,%f, %f, %f,%f, %f, %f\n", seamjointPos.jPos[0], seamjointPos.jPos[1], seamjointPos.jPos[2], seamjointPos.jPos[3], seamjointPos.jPos[4], seamjointPos.jPos[5], seamdescPose.tran.x, seamdescPose.tran.y, seamdescPose.tran.z, seamdescPose.rpy.rx, seamdescPose.rpy.ry, seamdescPose.rpy.rz);
42
43        //Se posizionamento riuscito
44        if (ret == 0)
45        {
46            //Movimento sincrono robot e assi estesi al punto posizionamento
47            robot.ExtAxisSyncMoveJ(seamjointPos, seamdescPose, 1, 0, 100, 100, 100, seamexaxisPos, -1, 0, offdese);
48
49            //Inizio tracciamento laser lungo punto posizionamento e movimento sincrono con assi estesi
50            robot.LaserTrackingTrackOnOff(1, 2);
51            JointPos endjointPos(70.580, -90.918, 126.593, -125.154, -92.162, -105.403);
52            DescPose enddescPose(-53.375, -419.020, 0.920, 178.054, 1.076, -94.026);
53            robot.ExtAxisSyncMoveL(endjointPos, enddescPose, 1, 0, 20, 100, 100, -1, endexaxisPos, 0, offdese);;
54            //Ferma tracciamento
55            robot.LaserTrackingTrackOnOff(0, 2);
56        }
57        cnt++;
58        printf("Tracciamento laser sincronizzato con assi estesi e robot  第%d次\n", cnt);
59    }
60    robot.CloseRPC();
61}

11.93. Abilita/Disabilita Funzione di Trasmissione Trasparente dell’End-Effector

1/**
2* @brief Abilita/disabilita la funzione di trasmissione trasparente dell'end-effector
3* @param [in] abilitazione, 0-disabilita, 1-abilita
4* @return Codice di errore
5*/
6errno_t SetAxleGenComEnable(int mode);

11.94. Trasmissione e Ricezione Dati Non Periodici della Funzione di Trasmissione Trasparente dell’End-Effector

1/**
2* @brief Trasmissione e ricezione dati non periodici della funzione di trasmissione trasparente dell'end-effector
3* @param [in] len_snd Lunghezza dei dati da inviare
4* @param [in] sndBuff Dati da inviare
5* @param [in] len_rcv Lunghezza dei dati da ricevere
6* @param [out] rcvBuff Dati di risposta
7* @return Codice di errore
8*/
9errno_t SndRcvAxleGenComCmdData(int lenSnd, int sndBuff[130], int lenRcv, int rcvData[130]);

11.95. Esempio di Codice per Comunicazione Dati Non Periodici del DIO Health Care Moxibustion Head basato sulla Funzione di Trasmissione Trasparente dell’End-Effector

 1int testAxleGenCom()
 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 led_on[6] = { 0xAB, 0xBA, 0x12, 0x01, 0x01, 0x79 };
14  int led_off[6] = { 0xAB, 0xBA, 0x12, 0x01, 0x00, 0x78 };
15  int version[5] = { 0xAB, 0xBA, 0x11, 0x00, 0x76 };
16  int state[6] = { 0xAB, 0xBA, 0x1B, 0x01, 0xAA, 0x2B };
17  int cycleState[6] = { 0xAB, 0xBA, 0x12, 0x01, 0x00, 0x78 };
18  int rcvdata[16] = {0};
19  int ret = 0;
20  int cnt = 1;
21  JointPos p1Joint(88.708, -86.178, 140.989, -141.825, -89.162, -49.879);
22  DescPose p1Desc(188.007, -377.850, 260.207, 178.715, 2.823, -131.466);
23  JointPos p2Joint(112.131, -75.554, 126.989, -139.027, -88.044, -26.477);
24  DescPose p2Desc(368.003, -377.848, 260.211, 178.715, 2.823, -131.465);
25  ExaxisPos exaxisPos(0, 0, 0, 0);
26  DescPose offdese(0, 0, 0, 0, 0, 0);
27  //Abilita la funzione di trasmissione trasparente dell'end-effector
28  robot.SetAxleGenComEnable(1);
29  robot.SetAxleLuaEnable(1);
30  while (cnt <= 10000)
31  {
32    //Legge il numero di versione
33    ret = robot.SndRcvAxleGenComCmdData(5, version, 10, rcvdata);
34    printf(" hard version : %d,hard code:%d, soft version:%d %d, soft code:%d \n", rcvdata[4], rcvdata[5], rcvdata[6] ,rcvdata[7], rcvdata[8]);
35    if (ret != 0)
36    {
37      break;
38    }
39    robot.Sleep(1000);
40    //Legge lo stato di presenza della testa di moxibustione
41    ret = robot.SndRcvAxleGenComCmdData(6, state, 6, rcvdata);
42    printf(" state : %d \n", rcvdata[4]);
43    robot.Sleep(1000);
44    //Accende il laser della testa di moxibustione
45    ret = robot.SndRcvAxleGenComCmdData(6, led_on, 6, rcvdata);
46    printf("led on rcv data is: %d, %d, %d, %d, %d, %d  \n", rcvdata[0], rcvdata[1], rcvdata[2], rcvdata[3], rcvdata[4], rcvdata[5]);
47    robot.MoveJ(&p1Joint, &p1Desc, 0, 0, 100, 100, 100, &exaxisPos, -1, 0, &offdese);
48    robot.Sleep(4000);
49    //Spegne il laser della testa di moxibustione
50    ret = robot.SndRcvAxleGenComCmdData(6, led_off, 6, rcvdata);
51    printf("led off rcv data is: %d, %d, %d, %d, %d, %d \n", rcvdata[0], rcvdata[1], rcvdata[2], rcvdata[3], rcvdata[4], rcvdata[5]);
52    robot.MoveJ(&p2Joint, &p2Desc, 0, 0, 100, 100, 100, &exaxisPos, -1, 0, &offdese);
53    robot.Sleep(1000);
54    printf("***********************complate No. %d SDK test*****************************\n", cnt);
55    cnt++;
56  }
57  robot.CloseRPC();
58}

11.96. Scarica File Lua di Protocollo Aperto

1/**
2* @brief Scarica file Lua di protocollo aperto
3* @param [in] fileName Nome del file di protocollo aperto "CtrlDev_XXX.lua"
4* @param [in] savePath Percorso di salvataggio del file di protocollo aperto
5* @return Codice di errore
6*/
7errno_t OpenLuaDownload(std::string fileName, std::string savePath);

11.97. Elimina File Lua di Protocollo Aperto

1/**
2* @brief Elimina file Lua di protocollo aperto
3* @param [in] fileName Nome del file Lua di protocollo aperto da eliminare "CtrlDev_XXX.lua"
4* @return Codice di errore
5*/
6errno_t OpenLuaDelete(std::string fileName);

11.98. Elimina Tutti i File Lua di Protocollo Aperto

1/**
2* @brief Elimina tutti i file Lua di protocollo aperto
3* @return Codice di errore
4*/
5errno_t AllOpenLuaDelete();

11.99. Esempio di Codice per Caricamento, Download ed Eliminazione di Protocollo Aperto per Periferiche del Controller

 1int TestCtrlOpenLuaOperate()
 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 0;
11    }
12    robot.SetReConnectParam(true, 30000, 500);
13    rtn = robot.OpenLuaUpload("D://zUP/openlua/CtrlDev_WELDING_A.lua");
14    printf("OpenLuaUpload rtn is %d\n", rtn);
15    rtn = robot.OpenLuaUpload("D://zUP/openlua/CtrlDev_SWDPOLISH.lua");
16    printf("OpenLuaUpload rtn is %d\n", rtn);
17    rtn = robot.OpenLuaDownload("CtrlDev_WELDING_A.lua", "D://zDOWN/");
18    printf("OpenLuaDownload rtn is %d\n", rtn);
19    rtn = robot.OpenLuaDownload("CtrlDev_SWDPOLISH.lua", "D://zDOWN/");
20    printf("OpenLuaDownload rtn is %d\n", rtn);
21    rtn = robot.SetCtrlOpenLUAName(0, "CtrlDev_WELDING_A.lua");
22    printf("SetCtrlOpenLUAName rtn is %d\n", rtn);
23    rtn = robot.SetCtrlOpenLUAName(1, "CtrlDev_SWDPOLISH.lua");
24    printf("SetCtrlOpenLUAName rtn is %d\n", rtn);
25    std::string name[4] = {};
26    rtn = robot.GetCtrlOpenLUAName(name);
27    printf("ctrl open lua names : %s, %s, %s, %s\n", name[0].c_str(), name[1].c_str(), name[2].c_str(), name[3].c_str());
28    rtn = robot.LoadCtrlOpenLUA(1);
29    printf("LoadCtrlOpenLUA rtn is %d\n", rtn);
30    robot.Sleep(2000);
31    rtn = robot.UnloadCtrlOpenLUA(1);
32    printf("UnloadCtrlOpenLUA rtn is %d\n", rtn);
33    rtn = robot.OpenLuaDelete("CtrlDev_WELDING_A.lua");
34    printf("OpenLuaDelete rtn is %d\n", rtn);
35    rtn = robot.AllOpenLuaDelete();
36    printf("AllOpenLuaDelete rtn is %d\n", rtn);
37    robot.CloseRPC();
38    robot.Sleep(1000);
39    return 0;
40}