forked from berndporr/alphabot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestTurn.cpp
More file actions
45 lines (39 loc) · 802 Bytes
/
Copy pathtestTurn.cpp
File metadata and controls
45 lines (39 loc) · 802 Bytes
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
#include "alphabot.h"
#include <unistd.h>
#include <cstdio>
class Callback :public AlphaBot::StepCallback { //every 100ms the callback updates the plan
int ct=0;
public:
bool end=0;
Callback(){}
void step( AlphaBot &motors){
if (ct<15){
printf("finished L\n");
motors.setRightWheelSpeed(0.5);
motors.setLeftWheelSpeed(-0.5);
}
else if(ct<15+15){
motors.setRightWheelSpeed(0);
motors.setLeftWheelSpeed(0);
}
else if(ct<30+15){
motors.setRightWheelSpeed(-0.5);
motors.setLeftWheelSpeed(0.5);
}
else{end=1;
motors.setRightWheelSpeed(0);
motors.setLeftWheelSpeed(0);
}
ct++;
}
};
int main(int, char**){
AlphaBot robot;
Callback cb;
robot.registerStepCallback(&cb);
robot.start();
do {
}while (!getchar());
robot.stop();
return 1;
}