-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrpmtest.cpp
57 lines (52 loc) · 1.01 KB
/
rpmtest.cpp
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
#include <iostream>
#include "data.cpp"
#include "motion.cpp"
int running=1;
void sig_handler(int signo)
{
if (signo == SIGINT) {
printf("closing PWM nicely\n");
running = 0;
}
};
int main()
{
signal(SIGINT, sig_handler);
Motor* left = new Motor(0,2,4,false);
Motor* right = new Motor(4,6,2,true);
Location* location = new Location(0.0,0.0,0.0);
Odometry* odo = new Odometry(left, right, 0, 0, 0);
Motion* motion = new Motion(left,right,odo,location);
//motion->rotate(1.57);
left->forward();
right->forward();
int reps=25;
/*
for(double i=0.1;running&&i<=0.5;i+=0.05)
{
double ravg=0,lavg=0;
right->writeVolt(i);
left->stop();
usleep(500000);
for(int j=0;running&&j<reps;j++)
{
ravg+=right->rps();
usleep(10000);
}
ravg/=reps;
std::cout<<ravg<<std::endl;
left->stop(); right->stop();
sleep(1);
}
*/
left->setSpeed(0.5);
right->setSpeed(0.5);
while(running)
{
//motion->run();
usleep(100000);
}
left->stop(); right->stop();
sleep(1);
return 0;
}