-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjog_example.cpp
More file actions
65 lines (57 loc) · 1.88 KB
/
Copy pathjog_example.cpp
File metadata and controls
65 lines (57 loc) · 1.88 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
58
59
60
61
62
63
64
65
#include <ur_rtde/rtde_control_interface.h>
#include <ncurses.h>
#include <chrono>
#include <iostream>
#include <thread>
using namespace ur_rtde;
using namespace std::chrono;
int main(int argc, char* argv[])
{
RTDEControlInterface rtde_control("127.0.0.1");
// Curses Initialisations
initscr();
raw();
keypad(stdscr, TRUE);
noecho();
timeout(10);
// Parameters
double speed_magnitude = 0.15;
std::vector<double> speed_vector = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
rtde_control.jogStart(speed_vector, RTDEControlInterface::FEATURE_TOOL);
std::string instructions("[ Use arrow keys to control the robot, to exit press 'q' ]");
int c, row, col;
getmaxyx(stdscr, row, col);
mvprintw(row / 2, (col-strlen(instructions.c_str())) / 2, "%s", instructions.c_str());
while ((c = getch()) != 'q')
{
c = getch();
switch (c)
{
case KEY_UP:
speed_vector = {0.0, 0.0, -speed_magnitude, 0.0, 0.0, 0.0};
rtde_control.jogStart(speed_vector, RTDEControlInterface::FEATURE_TOOL);
break;
case KEY_DOWN:
speed_vector = {0.0, 0.0, speed_magnitude, 0.0, 0.0, 0.0};
rtde_control.jogStart(speed_vector, RTDEControlInterface::FEATURE_TOOL);
break;
case KEY_LEFT:
speed_vector = {speed_magnitude, 0.0, 0.0, 0.0, 0.0, 0.0};
rtde_control.jogStart(speed_vector, RTDEControlInterface::FEATURE_TOOL);
break;
case KEY_RIGHT:
speed_vector = {-speed_magnitude, 0.0, 0.0, 0.0, 0.0, 0.0};
rtde_control.jogStart(speed_vector, RTDEControlInterface::FEATURE_TOOL);
break;
default:
speed_vector = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
rtde_control.jogStart(speed_vector, RTDEControlInterface::FEATURE_TOOL);
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(2));
}
endwin();
rtde_control.jogStop();
rtde_control.stopScript();
return 0;
}