forked from pddring/robo-arm-pi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobot.cpp
More file actions
79 lines (60 loc) · 2.01 KB
/
robot.cpp
File metadata and controls
79 lines (60 loc) · 2.01 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <stdlib.h>
#include <stdio.h>
#include <curses.h>
#include "robotarm.h"
int main(void) {
try {
initscr();
timeout(-1);
printw("Robot arm interface by P. Dring\n");
printw("Grip commands: i, o, p\n\r");
printw("Base commands: k, l, ;\n\r");
printw("Wrist commands: w, s, x\n\r");
printw("Elbow commands: e, d, c\n\r");
printw("Shoulder commands: r, f, v\n\r");
printw("Toggle LED: space\n\r");
printw("Quit: q\n\r");
RobotArm roboarm;
roboarm.connect();
bool LED = false;
bool running = true;
while(running) {
int key = getch();
switch(key) {
// grip
case 'i': roboarm.setGrip(RobotArm::ARM_OPEN); break;
case 'o': roboarm.setGrip(RobotArm::ARM_STOP); break;
case 'p': roboarm.setGrip(RobotArm::ARM_CLOSE); break;
// base
case 'k': roboarm.setBase(RobotArm::ARM_ANTICLOCKWISE); break;
case 'l': roboarm.setBase(RobotArm::ARM_STOP); break;
case ';': roboarm.setBase(RobotArm::ARM_CLOCKWISE); break;
// wrist
case 'w': roboarm.setWrist(RobotArm::ARM_UP); break;
case 's': roboarm.setWrist(RobotArm::ARM_STOP); break;
case 'x': roboarm.setWrist(RobotArm::ARM_DOWN); break;
// elbow
case 'e': roboarm.setElbow(RobotArm::ARM_UP); break;
case 'd': roboarm.setElbow(RobotArm::ARM_STOP); break;
case 'c': roboarm.setElbow(RobotArm::ARM_DOWN); break;
// shoulder
case 'r': roboarm.setShoulder(RobotArm::ARM_UP); break;
case 'f': roboarm.setShoulder(RobotArm::ARM_STOP); break;
case 'v': roboarm.setShoulder(RobotArm::ARM_DOWN); break;
// LED
case ' ': roboarm.setLED(LED = !LED); break;
// quit
case 'q': roboarm.stopAll(); running = false; break;
}
}
roboarm.stopAll();
roboarm.disconnect();
endwin();
} catch(const char * message) {
endwin();
printf("%s\n\r", message);
return(1);
}
printf("Find out more at https://github.com/pddring/robo-arm-pi\n");
return 0;
}