mirror of
https://github.com/team2059/Dent
synced 2024-12-18 20:52:29 -05:00
Minor improvements
This commit is contained in:
parent
324ae06417
commit
f01373de39
@ -6,8 +6,13 @@ void RollIn::Initialize(){
|
|||||||
SetTimeout(2.0);
|
SetTimeout(2.0);
|
||||||
}
|
}
|
||||||
void RollIn::Execute(){
|
void RollIn::Execute(){
|
||||||
//TODO check this value to move the motors in the right direction
|
double throttle=DentRobot::oi->GetLeftThrottle();
|
||||||
DentRobot::collector->MoveRollers((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2);
|
double cvt=throttle*DentRobot::collector->GetSonarDistance()/0.4/5;
|
||||||
|
if(cvt>=1.0){
|
||||||
|
DentRobot::collector->MoveRollers(1.0);
|
||||||
|
}else{
|
||||||
|
DentRobot::collector->MoveRollers(cvt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool RollIn::IsFinished(){
|
bool RollIn::IsFinished(){
|
||||||
return IsTimedOut();
|
return IsTimedOut();
|
||||||
|
@ -8,7 +8,7 @@ void RollOut::Initialize(){
|
|||||||
void RollOut::Execute(){
|
void RollOut::Execute(){
|
||||||
//TODO check this value to move the motors in the right direction
|
//TODO check this value to move the motors in the right direction
|
||||||
// Devide by 2 twice because this speed should be half the collector speed
|
// Devide by 2 twice because this speed should be half the collector speed
|
||||||
DentRobot::collector->MoveRollers(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2);
|
DentRobot::collector->MoveRollers(-DentRobot::oi->GetLeftThrottle());
|
||||||
}
|
}
|
||||||
bool RollOut::IsFinished(){
|
bool RollOut::IsFinished(){
|
||||||
return IsTimedOut();
|
return IsTimedOut();
|
||||||
|
@ -18,8 +18,8 @@ bool Raise::IsFinished(){
|
|||||||
// DentRobot::elevator->stoppedAtSensor=false;
|
// DentRobot::elevator->stoppedAtSensor=false;
|
||||||
// return true;
|
// return true;
|
||||||
//}else if (!DentRobot::elevator->GetElevatorTop()) {
|
//}else if (!DentRobot::elevator->GetElevatorTop()) {
|
||||||
if (!DentRobot::elevator->GetElevatorTop()||IsTimedOut()){
|
if (!DentRobot::elevator->GetElevatorTop()||!DentRobot::elevator->GetElevatorMiddle()||IsTimedOut()){
|
||||||
printf("Robot stopped raising. Sensor based? %d\n", !DentRobot::elevator->GetElevatorTop());
|
printf("Robot stopped raising. Sensor based? %d\n", !DentRobot::elevator->GetElevatorTop()||!DentRobot::elevator->GetElevatorMiddle());
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
6
OI.cpp
6
OI.cpp
@ -46,4 +46,10 @@ Joystick* OI::GetRightStick(){
|
|||||||
Joystick* OI::GetLeftStick(){
|
Joystick* OI::GetLeftStick(){
|
||||||
return leftStick;
|
return leftStick;
|
||||||
}
|
}
|
||||||
|
double OI::GetRightThrottle(){
|
||||||
|
return (-rightStick->GetRawAxis(3)+1.0)/2;
|
||||||
|
}
|
||||||
|
double OI::GetLeftThrottle(){
|
||||||
|
return (-leftStick->GetRawAxis(3)+1.0)/2;
|
||||||
|
}
|
||||||
// vim: ts=2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
4
OI.h
4
OI.h
@ -10,9 +10,11 @@ class OI
|
|||||||
Joystick *leftStick, *rightStick;
|
Joystick *leftStick, *rightStick;
|
||||||
public:
|
public:
|
||||||
OI();
|
OI();
|
||||||
|
Command *raise, *lower, *binLower, *binRaise;
|
||||||
Joystick* GetRightStick();
|
Joystick* GetRightStick();
|
||||||
Joystick* GetLeftStick();
|
Joystick* GetLeftStick();
|
||||||
Command *raise, *lower, *binLower, *binRaise;
|
double GetLeftThrottle();
|
||||||
|
double GetRightThrottle();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
// vim: ts=2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
// Elevator
|
// Elevator
|
||||||
#define ELEVATOR_CAN 1
|
#define ELEVATOR_CAN 1
|
||||||
#define ELEVATOR_BOTTOM_DIO 9
|
#define ELEVATOR_BOTTOM_DIO 9
|
||||||
#define ELEVATOR_MIDDLE_DIO 7
|
#define ELEVATOR_MIDDLE_DIO 8
|
||||||
#define ELEVATOR_TOP_DIO 8
|
#define ELEVATOR_TOP_DIO 7
|
||||||
#define ELEVATOR_ENCODERA 4
|
#define ELEVATOR_ENCODERA 4
|
||||||
#define ELEVATOR_ENCODERB 9
|
#define ELEVATOR_ENCODERB 9
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ void Collector::MoveRollers(double a){
|
|||||||
collectorMotorBottom->Set(a);
|
collectorMotorBottom->Set(a);
|
||||||
collectorMotorRamp->Set(a);
|
collectorMotorRamp->Set(a);
|
||||||
collectorMotorRight->Set(-a);
|
collectorMotorRight->Set(-a);
|
||||||
GetSonarDistance();
|
printf("%f\n",GetSonarDistance());
|
||||||
}
|
}
|
||||||
float Collector::GetSonarDistance(){
|
double Collector::GetSonarDistance(){
|
||||||
printf("Sonar Distance %f\n",sonarAnalog->GetAverageVoltage());
|
return sonarAnalog->GetAverageVoltage();
|
||||||
}
|
}
|
||||||
// vim: ts=2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -12,7 +12,7 @@ class Collector: public Subsystem
|
|||||||
Collector();
|
Collector();
|
||||||
void InitDefaultCommand();
|
void InitDefaultCommand();
|
||||||
void MoveRollers(double);
|
void MoveRollers(double);
|
||||||
float GetSonarDistance();
|
double GetSonarDistance();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
// vim: ts=2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
Loading…
Reference in New Issue
Block a user