2015-01-16 19:29:55 -05:00
|
|
|
#include "Raise.h"
|
2015-02-03 15:55:11 -05:00
|
|
|
#include "../../DentRobot.h"
|
2015-02-04 20:57:33 -05:00
|
|
|
#include "../../OI.h"
|
2015-03-09 07:25:11 -04:00
|
|
|
Raise::Raise(double timeout): Command("Raise"){
|
2015-03-07 13:27:11 -05:00
|
|
|
SetTimeout(timeout);
|
2015-01-16 19:29:55 -05:00
|
|
|
}
|
|
|
|
void Raise::Initialize(){
|
|
|
|
}
|
|
|
|
void Raise::Execute(){
|
2015-02-07 17:04:16 -05:00
|
|
|
DentRobot::elevator->Run(1.0);
|
2015-01-16 19:29:55 -05:00
|
|
|
}
|
|
|
|
bool Raise::IsFinished(){
|
2015-02-15 08:36:19 -05:00
|
|
|
//if(!DentRobot::elevator->GetElevatorMiddle()){
|
2015-03-23 10:52:02 -04:00
|
|
|
// DentRobot::elevator->stoppedAtSensor = true;
|
2015-02-15 08:36:19 -05:00
|
|
|
//}
|
2015-03-09 07:25:11 -04:00
|
|
|
//if((DentRobot::elevator->stoppedAtSensor)){
|
2015-02-15 08:36:19 -05:00
|
|
|
// printf("Stopped at the middle sensor\n");
|
2015-03-23 10:52:02 -04:00
|
|
|
// DentRobot::elevator->stoppedAtSensor = false;
|
2015-02-15 08:36:19 -05:00
|
|
|
// return true;
|
2015-03-09 07:25:11 -04:00
|
|
|
//}else if(!DentRobot::elevator->GetElevatorTop()){
|
|
|
|
if(!DentRobot::elevator->GetElevatorTop()||!DentRobot::elevator->GetElevatorMiddle()||IsTimedOut()){
|
2015-02-15 17:10:20 -05:00
|
|
|
printf("Robot stopped raising. Sensor based? %d\n", !DentRobot::elevator->GetElevatorTop()||!DentRobot::elevator->GetElevatorMiddle());
|
2015-02-07 12:50:36 -05:00
|
|
|
return true;
|
2015-02-07 07:23:10 -05:00
|
|
|
}else{
|
2015-02-07 12:50:36 -05:00
|
|
|
return false;
|
2015-02-07 07:23:10 -05:00
|
|
|
}
|
2015-01-16 19:29:55 -05:00
|
|
|
}
|
|
|
|
void Raise::End(){
|
2015-02-12 21:18:48 -05:00
|
|
|
// If the elevator is at the top
|
|
|
|
if(DentRobot::elevator->GetElevatorTop()){
|
|
|
|
DentRobot::elevator->SetUseEncoder(true);
|
|
|
|
}
|
2015-01-17 13:28:27 -05:00
|
|
|
DentRobot::elevator->Run(0.0f);
|
2015-01-16 19:29:55 -05:00
|
|
|
}
|
|
|
|
void Raise::Interrupted(){
|
2015-01-17 13:28:27 -05:00
|
|
|
End();
|
2015-01-16 19:29:55 -05:00
|
|
|
}
|
2015-02-08 12:26:15 -05:00
|
|
|
// vim: ts=2:sw=2:et
|