forked from berndporr/alphabot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestStep.cpp
More file actions
46 lines (39 loc) · 795 Bytes
/
testStep.cpp
File metadata and controls
46 lines (39 loc) · 795 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
46
#include "alphabot.h"
#include <unistd.h>
#include <cstdio>
class Callback :public AlphaBot::StepCallback { //every 100ms the callback updates the plan
public:
int ct=0;
float R=.5;
float L=.5;
bool end=0;
Callback(int &_ct){
ct=_ct;
}
void step( AlphaBot &motors){
ct++;
printf("ct = %i\n", ct);
motors.setRightWheelSpeed(R);
motors.setLeftWheelSpeed(L);
printf("R=%f, L=%f\n", R, L);
if (ct>64){
motors.setRightWheelSpeed(0);
motors.setLeftWheelSpeed(0);
}
}
};
int main(int, char**){
AlphaBot robot;
int ct=0;
Callback cb(ct);
robot.registerStepCallback(&cb);
robot.start();
while(ct<51){
}
// usleep(10000000);
robot.setRightWheelSpeed(0);
robot.setLeftWheelSpeed(0);
robot.stop();
return 1;
}
//.66cm in 51 steps at 1.0PMW