9. Riproduzione Traiettoria Robot
9.1. Impostare i parametri di registrazione traiettoria TPD
1/**
2* @brief Imposta i parametri di registrazione traiettoria TPD
3* @param [in] type Tipo dati registrazione, 1-Posizione giunti
4* @param [in] name Nome file traiettoria
5* @param [in] period_ms Periodo campionamento dati, valore fisso 2ms o 4ms o 8ms
6* @param [in] di_choose Selezione DI, bit0~bit7 corrisponde a control box DI0~DI7, bit8~bit9 corrisponde a terminale DI0~DI1, 0-Non selezionato, 1-Selezionato
7* @param [in] do_choose Selezione DO, bit0~bit7 corrisponde a control box DO0~DO7, bit8~bit9 corrisponde a terminale DO0~DO1, 0-Non selezionato, 1-Selezionato
8* @return Codice di errore
9*/
10errno_t SetTPDParam(int type, char name[30], int period_ms, uint16_t di_choose, uint16_t do_choose);
9.2. Iniziare la registrazione traiettoria TPD
1/**
2* @brief Inizia la registrazione traiettoria TPD
3* @param [in] type Tipo dati registrazione, 1-Posizione giunti
4* @param [in] name Nome file traiettoria
5* @param [in] period_ms Periodo campionamento dati, valore fisso 2ms o 4ms o 8ms
6* @param [in] di_choose Selezione DI, bit0~bit7 corrisponde a control box DI0~DI7, bit8~bit9 corrisponde a terminale DI0~DI1, 0-Non selezionato, 1-Selezionato
7* @param [in] do_choose Selezione DO, bit0~bit7 corrisponde a control box DO0~DO7, bit8~bit9 corrisponde a terminale DO0~DO1, 0-Non selezionato, 1-Selezionato
8* @return Codice di errore
9*/
10errno_t SetTPDStart(int type, char name[30], int period_ms, uint16_t di_choose, uint16_t do_choose);
9.3. Fermare la registrazione traiettoria TPD
1/**
2* @brief Ferma la registrazione traiettoria TPD
3* @return Codice di errore
4*/
5errno_t SetWebTPDStop();
9.4. Eliminare la registrazione traiettoria TPD
1/**
2* @brief Elimina la registrazione traiettoria TPD
3* @param [in] name Nome file traiettoria
4* @return Codice di errore
5*/
6errno_t SetTPDDelete(char name[30]);
9.5. Precaricamento traiettoria TPD
1/**
2* @brief Precaricamento traiettoria TPD
3* @param [in] name Nome file traiettoria
4* @return Codice di errore
5*/
6errno_t LoadTPD(char name[30]);
9.6. Riproduzione traiettoria TPD
1/**
2* @brief Riproduzione traiettoria TPD
3* @param [in] name Nome file traiettoria
4* @param [in] blend 0-Non smoothing, 1-Smoothing
5* @param [in] ovl Percentuale scala velocità, intervallo [0~100]
6* @return Codice di errore
7*/
8errno_t MoveTPD(char name[30], uint8_t blend, float ovl);
9.7. Ottenere la posa iniziale TPD
1/**
2 * @brief Ottiene la posa iniziale TPD
3 * @param [in] name Nome file TPD, non necessita estensione file
4 * @return Codice di errore
5 */
6errno_t GetTPDStartPose(char name[30], DescPose *desc_pose);
9.8. Esempio di codice per registrazione traiettoria TPD robot
1int TestTPD(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 type = 1;
14 char name[30] = "tpd2025";
15 int period_ms = 4;
16 uint16_t di_choose = 0;
17 uint16_t do_choose = 0;
18 robot.SetTPDParam(type, name, period_ms, di_choose, do_choose);
19 robot.Mode(1);
20 robot.Sleep(1000);
21 robot.DragTeachSwitch(1);
22 robot.SetTPDStart(type, name, period_ms, di_choose, do_choose);
23 robot.Sleep(10000);
24 robot.SetWebTPDStop();
25 robot.DragTeachSwitch(0);
26 float ovl = 100.0;
27 uint8_t blend = 0;
28 DescPose start_pose = {};
29 rtn = robot.LoadTPD(name);
30 printf("LoadTPD rtn is: %d\n", rtn);
31 robot.GetTPDStartPose(name, &start_pose);
32 printf("start pose, xyz is: %f %f %f. rpy is: %f %f %f \n", start_pose.tran.x, start_pose.tran.y, start_pose.tran.z, start_pose.rpy.rx, start_pose.rpy.ry, start_pose.rpy.rz);
33 robot.MoveCart(&start_pose, 0, 0, 100, 100, ovl, -1, -1);
34 robot.Sleep(1000);
35 rtn = robot.MoveTPD(name, blend, ovl);
36 printf("MoveTPD rtn is: %d\n", rtn);
37 std::this_thread::sleep_for(std::chrono::milliseconds(5000));
38 robot.SetTPDDelete(name);
39 robot.CloseRPC();
40 return 0;
41}
9.9. Pre-elaborazione traiettoria
1/**
2 * @brief Pre-elaborazione traiettoria
3 * @param [in] name Nome file traiettoria
4 * @param [in] ovl Percentuale scala velocità, intervallo [0~100]
5 * @param [in] opt 1-Punto di controllo, predefinito 1
6 * @return Codice di errore
7 */
8errno_t LoadTrajectoryJ(char name[30], float ovl, int opt);
9.10. Riproduzione traiettoria
1/**
2 * @brief Riproduzione traiettoria
3 * @return Codice di errore
4 */
5errno_t MoveTrajectoryJ();
9.11. Ottenere la posa iniziale della traiettoria
1/**
2 * @brief Ottiene la posa iniziale della traiettoria
3 * @param [in] name Nome file traiettoria
4 * @return Codice di errore
5 */
6errno_t GetTrajectoryStartPose(char name[30], DescPose *desc_pose);
9.12. Ottenere il numero di punti della traiettoria
1/**
2 * @brief Ottiene il numero di punti della traiettoria
3 * @return Codice di errore
4 */
5errno_t GetTrajectoryPointNum(int *pnum);
9.13. Impostare la velocità durante la riproduzione della traiettoria
1/**
2 * @brief Imposta la velocità durante la riproduzione della traiettoria
3 * @param [in] ovl Percentuale velocità
4 * @return Codice di errore
5 */
6errno_t SetTrajectoryJSpeed(float ovl);
9.14. Impostare forza e coppia durante la riproduzione della traiettoria
1/**
2 * @brief Imposta forza e coppia durante la riproduzione della traiettoria
3 * @param [in] ft Forza e coppia in tre direzioni, unità N e Nm
4 * @return Codice di errore
5 */
6errno_t SetTrajectoryJForceTorque(ForceTorque *ft);
9.15. Impostare la forza lungo la direzione x durante la riproduzione della traiettoria
1/**
2 * @brief Imposta la forza lungo la direzione x durante la riproduzione della traiettoria
3 * @param [in] fx Forza lungo direzione x, unità N
4 * @return Codice di errore
5 */
6errno_t SetTrajectoryJForceFx(double fx);
9.16. Impostare la forza lungo la direzione y durante la riproduzione della traiettoria
1/**
2 * @brief Imposta la forza lungo la direzione y durante la riproduzione della traiettoria
3 * @param [in] fy Forza lungo direzione y, unità N
4 * @return Codice di errore
5 */
6errno_t SetTrajectoryJForceFy(double fy);
9.17. Impostare la forza lungo la direzione z durante la riproduzione della traiettoria
1/**
2 * @brief Imposta la forza lungo la direzione z durante la riproduzione della traiettoria
3 * @param [in] fz Forza lungo direzione x, unità N
4 * @return Codice di errore
5 */
6errno_t SetTrajectoryJForceFz(double fz);
9.18. Impostare la coppia attorno all’asse x durante la riproduzione della traiettoria
1/**
2 * @brief Imposta la coppia attorno all'asse x durante la riproduzione della traiettoria
3 * @param [in] tx Coppia attorno asse x, unità Nm
4 * @return Codice di errore
5 */
6errno_t SetTrajectoryJTorqueTx(double tx);
9.19. Impostare la coppia attorno all’asse y durante la riproduzione della traiettoria
1/**
2 * @brief Imposta la coppia attorno all'asse y durante la riproduzione della traiettoria
3 * @param [in] ty Coppia attorno asse y, unità Nm
4 * @return Codice di errore
5 */
6errno_t SetTrajectoryJTorqueTy(double ty);
9.20. Impostare la coppia attorno all’asse z durante la riproduzione della traiettoria
1/**
2 * @brief Imposta la coppia attorno all'asse z durante la riproduzione della traiettoria
3 * @param [in] tz Coppia attorno asse z, unità Nm
4 * @return Codice di errore
5 */
6errno_t SetTrajectoryJTorqueTz(double tz);
9.21. Caricare file traiettoria J
Nuovo nella versione V3.7.7.
1/**
2 * @brief Carica file traiettoria J
3 * @param [in] filePath Nome percorso completo file traiettoria da caricare C://test/testJ.txt
4 * @return Codice di errore
5 */
6errno_t TrajectoryJUpLoad(const std::string& filePath);
9.22. Eliminare file traiettoria J
Nuovo nella versione V3.7.7.
1/**
2 * @brief Elimina file traiettoria J
3 * @param [in] fileName Nome file testJ.txt
4 * @return Codice di errore
5 */
6errno_t TrajectoryJDelete(const std::string& fileName);
9.23. Esempio di codice per riproduzione file traiettoria J robot
1int TestTraj(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.TrajectoryJUpLoad("D://zUP/traj1.txt");
14 printf("Upload TrajectoryJ A %d\n", rtn);
15 char traj_file_name[30] = "/fruser/traj/traj1.txt";
16 rtn = robot.LoadTrajectoryJ(traj_file_name, 100, 1);
17 printf("LoadTrajectoryJ %s, rtn is: %d\n", traj_file_name, rtn);
18 DescPose traj_start_pose;
19 memset(&traj_start_pose, 0, sizeof(DescPose));
20 rtn = robot.GetTrajectoryStartPose(traj_file_name, &traj_start_pose);
21 printf("GetTrajectoryStartPose is: %d\n", rtn);
22 printf("desc_pos:%f,%f,%f,%f,%f,%f\n", traj_start_pose.tran.x, traj_start_pose.tran.y, traj_start_pose.tran.z, traj_start_pose.rpy.rx, traj_start_pose.rpy.ry, traj_start_pose.rpy.rz);
23 std::this_thread::sleep_for(std::chrono::seconds(1));
24 robot.SetSpeed(50);
25 robot.MoveCart(&traj_start_pose, 0, 0, 100, 100, 100, -1, -1);
26 int traj_num = 0;
27 rtn = robot.GetTrajectoryPointNum(&traj_num);
28 printf("GetTrajectoryStartPose rtn is: %d, traj num is: %d\n", rtn, traj_num);
29 rtn = robot.SetTrajectoryJSpeed(50.0);
30 printf("SetTrajectoryJSpeed is: %d\n", rtn);
31 ForceTorque traj_force;
32 memset(&traj_force, 0, sizeof(ForceTorque));
33 traj_force.fx = 10;
34 rtn = robot.SetTrajectoryJForceTorque(&traj_force);
35 printf("SetTrajectoryJForceTorque rtn is: %d\n", rtn);
36 rtn = robot.SetTrajectoryJForceFx(10.0);
37 printf("SetTrajectoryJForceFx rtn is: %d\n", rtn);
38 rtn = robot.SetTrajectoryJForceFy(0.0);
39 printf("SetTrajectoryJForceFy rtn is: %d\n", rtn);
40 rtn = robot.SetTrajectoryJForceFz(0.0);
41 printf("SetTrajectoryJForceFz rtn is: %d\n", rtn);
42 rtn = robot.SetTrajectoryJTorqueTx(10.0);
43 printf("SetTrajectoryJTorqueTx rtn is: %d\n", rtn);
44 rtn = robot.SetTrajectoryJTorqueTy(10.0);
45 printf("SetTrajectoryJTorqueTy rtn is: %d\n", rtn);
46 rtn = robot.SetTrajectoryJTorqueTz(10.0);
47 printf("SetTrajectoryJTorqueTz rtn is: %d\n", rtn);
48 rtn = robot.MoveTrajectoryJ();
49 printf("MoveTrajectoryJ rtn is: %d\n", rtn);
50 robot.CloseRPC();
51 return 0;
52}
9.24. Pre-elaborazione traiettoria (traiettoria lookahead)
1/**
2 * @brief Pre-elaborazione traiettoria (traiettoria lookahead)
3 * @param [in] name Nome file traiettoria
4 * @param [in] mode Modalità campionamento, 0-Non campionare; 1-Campionamento a intervalli dati uguali; 2-Campionamento con limite errore uguale
5 * @param [in] errorLim Limite errore, efficace quando si usa interpolazione lineare
6 * @param [in] type Metodo smoothing, 0-Smoothing Bezier
7 * @param [in] precision Precisione smoothing, efficace quando si usa smoothing Bezier
8 * @param [in] vamx Velocità massima impostata, mm/s
9 * @param [in] amax Accelerazione massima impostata, mm/s2
10 * @param [in] jmax Jerk massimo impostato, mm/s3
11 * @param [in] flag Interruttore lookahead velocità costante 0-Non attivare; 1-Attivare
12 * @return Codice di errore
13 */
14errno_t LoadTrajectoryLA(char name[30], int mode, double errorLim, int type, double precision, double vamx, double amax, double jmax, int flag = 0);
9.25. Riproduzione traiettoria (traiettoria lookahead)
1/**
2* @brief Riproduzione traiettoria (traiettoria lookahead)
3* @return Codice di errore
4*/
5errno_t MoveTrajectoryLA();
9.26. Esempio di codice per riproduzione traiettoria (traiettoria lookahead)
1int TestLoadTrajLA(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.TrajectoryJUpLoad("D://zUP/traj.txt");
14 printf("Upload TrajectoryJ A %d\n", rtn);
15 char traj_file_name[30] = "/fruser/traj/traj.txt";
16 rtn = robot.LoadTrajectoryLA(traj_file_name, 1, 2, 0, 2, 100, 200, 1000);
17 printf("LoadTrajectoryLA %s, rtn is: %d\n", traj_file_name, rtn);
18 DescPose traj_start_pose;
19 memset(&traj_start_pose, 0, sizeof(DescPose));
20 rtn = robot.GetTrajectoryStartPose(traj_file_name, &traj_start_pose);
21 printf("GetTrajectoryStartPose is: %d\n", rtn);
22 printf("desc_pos:%f,%f,%f,%f,%f,%f\n", traj_start_pose.tran.x, traj_start_pose.tran.y, traj_start_pose.tran.z, traj_start_pose.rpy.rx, traj_start_pose.rpy.ry, traj_start_pose.rpy.rz);
23 std::this_thread::sleep_for(std::chrono::seconds(1));
24 robot.SetSpeed(50);
25 robot.MoveCart(&traj_start_pose, 0, 0, 100, 100, 100, -1, -1);
26 rtn = robot.MoveTrajectoryLA();
27 printf("MoveTrajectoryLA rtn is: %d\n", rtn);
28 robot.CloseRPC();
29 return 0;
30}