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