-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbracos.cpp
More file actions
57 lines (42 loc) · 1.54 KB
/
bracos.cpp
File metadata and controls
57 lines (42 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#define PI 3.14
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern "C" {
#include "simLib/simConst.h"
#include "extApi.h"
#include "extApiPlatform.h"
}
int main(int argc, char* argv[])
{
//variavei para handler das juntas
int handler = 0;
//conecta com o coppelia
int clientID = simxStart((simxChar*) "127.0.0.1", 19999, true, true, 2000, 5);
extApi_sleepMs(500);
//verifica conexao com simulador
if (clientID == -1) {
printf("Erro conectando ao Coppelia!\n");
return 0;
} else {
printf("Conectado ao Coppelia!\n");
}
//configura o handler da primeira junta
simxChar handlerName[150] = "/NiryoOne/Joint";
simxGetObjectHandle(clientID, handlerName, &handler, (simxInt)simx_opmode_oneshot_wait);
for (int i = 1; i <= 6; i++) {
printf("Testando junta %d\n", i);
//move a junta ate seu ponto maximo
simxSetJointTargetPosition(clientID, handler, (simxFloat) 0, (simxInt)simx_opmode_oneshot_wait);
extApi_sleepMs(2000);
simxSetJointTargetPosition(clientID, handler, (simxFloat) 3 / 2 * PI, (simxInt)simx_opmode_oneshot_wait);
extApi_sleepMs(2000);
simxSetJointTargetPosition(clientID, handler, (simxFloat) 0, (simxInt)simx_opmode_oneshot_wait);
//passa para a proxima junta
strcat(handlerName, "/Link/Joint");
simxGetObjectHandle(clientID, (simxChar*) handlerName, &handler, (simxInt)simx_opmode_oneshot_wait);
}
// Fecha a conexao
simxFinish(clientID);
return(0);
}