-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloctest.cpp
More file actions
53 lines (50 loc) · 1.15 KB
/
Copy pathloctest.cpp
File metadata and controls
53 lines (50 loc) · 1.15 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
#include <iostream>
#include "wallfollower.cpp"
#include "localize.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);
IR* irf = new IR(0);
IR* irr = new IR(1);
IR* irlf = new IR(3);
IR* irlb = new IR(2);
mraa::Gpio* uirb = new mraa::Gpio(8);
Wallfollower* wf= new Wallfollower(left,right,irf,irr,irlf,irlb,uirb,location);
Localize* loc=new Localize("example.txt",location);
int channel=1,mode=1,pm=1;
bool localized = false,hitWall=false;
sleep(1);
while(running&&!localized) {
pm=mode;
channel = wf->run_follower(channel);
mode=wf->locating_channel();
//std::cout<<"Returned channel "<<mode<<std::endl;
if(mode!=pm)
{
if(pm==3&&!hitWall)
{
loc->wallFound(irlf->getDistance());
hitWall=true;
//sleep(3);
}
else if(pm==3||mode==4||mode==5)
{
localized=loc->atCorner(irf->getDistance(),mode);
}
}
}
left->stop();
right->stop();
sleep(1);
return 0;
}