Skip to content

Instantly share code, notes, and snippets.

Created June 20, 2017 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/57da3c89308bf53d2db23338f7ec6db0 to your computer and use it in GitHub Desktop.
Save anonymous/57da3c89308bf53d2db23338f7ec6db0 to your computer and use it in GitHub Desktop.
Door Procedure
#include "config.h"
#include "classes.h"
#include <iostream>
using namespace std;
int door_procedure(emc::LaserData laser){
count_doorpr += 1;
if (count_doorpr < 2){ //ring bell once
io.sendOpendoorRequest();
cout<<"TRIIIINGNNGNGNGG"<<endl;
return 0;
}
if (count_doorpr > 5SEC){ //after 5 seconds
for(int i=FRONT_START; i<FRONT_END; i=i+1){ //For laser points in front
if (laser.ranges[i]<VIEW_DIST && laser.ranges[i]>MIN_DIST && laser.ranges[i+1]<VIEW_DIST && laser.ranges[i+1]>MIN_DIST &&laser.ranges[i+2]<VIEW_DIST && laser.ranges[i+2]>MIN_DIST){
return 1; // dead end
}
else {
return 2; // door has opened: continue
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment