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);
|
||||
}
|
||||
void RollIn::Execute(){
|
||||
//TODO check this value to move the motors in the right direction
|
||||
DentRobot::collector->MoveRollers((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2);
|
||||
double throttle=DentRobot::oi->GetLeftThrottle();
|
||||
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(){
|
||||
return IsTimedOut();
|
||||
|
@ -8,7 +8,7 @@ void RollOut::Initialize(){
|
||||
void RollOut::Execute(){
|
||||
//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
|
||||
DentRobot::collector->MoveRollers(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2);
|
||||
DentRobot::collector->MoveRollers(-DentRobot::oi->GetLeftThrottle());
|
||||
}
|
||||
bool RollOut::IsFinished(){
|
||||
return IsTimedOut();
|
||||
|
@ -18,8 +18,8 @@ bool Raise::IsFinished(){
|
||||
// DentRobot::elevator->stoppedAtSensor=false;
|
||||
// return true;
|
||||
//}else if (!DentRobot::elevator->GetElevatorTop()) {
|
||||
if (!DentRobot::elevator->GetElevatorTop()||IsTimedOut()){
|
||||
printf("Robot stopped raising. Sensor based? %d\n", !DentRobot::elevator->GetElevatorTop());
|
||||
if (!DentRobot::elevator->GetElevatorTop()||!DentRobot::elevator->GetElevatorMiddle()||IsTimedOut()){
|
||||
printf("Robot stopped raising. Sensor based? %d\n", !DentRobot::elevator->GetElevatorTop()||!DentRobot::elevator->GetElevatorMiddle());
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
|
6
OI.cpp
6
OI.cpp
@ -46,4 +46,10 @@ Joystick* OI::GetRightStick(){
|
||||
Joystick* OI::GetLeftStick(){
|
||||
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
|
||||
|
4
OI.h
4
OI.h
@ -10,9 +10,11 @@ class OI
|
||||
Joystick *leftStick, *rightStick;
|
||||
public:
|
||||
OI();
|
||||
Command *raise, *lower, *binLower, *binRaise;
|
||||
Joystick* GetRightStick();
|
||||
Joystick* GetLeftStick();
|
||||
Command *raise, *lower, *binLower, *binRaise;
|
||||
double GetLeftThrottle();
|
||||
double GetRightThrottle();
|
||||
};
|
||||
#endif
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -6,8 +6,8 @@
|
||||
// Elevator
|
||||
#define ELEVATOR_CAN 1
|
||||
#define ELEVATOR_BOTTOM_DIO 9
|
||||
#define ELEVATOR_MIDDLE_DIO 7
|
||||
#define ELEVATOR_TOP_DIO 8
|
||||
#define ELEVATOR_MIDDLE_DIO 8
|
||||
#define ELEVATOR_TOP_DIO 7
|
||||
#define ELEVATOR_ENCODERA 4
|
||||
#define ELEVATOR_ENCODERB 9
|
||||
|
||||
|
@ -15,9 +15,9 @@ void Collector::MoveRollers(double a){
|
||||
collectorMotorBottom->Set(a);
|
||||
collectorMotorRamp->Set(a);
|
||||
collectorMotorRight->Set(-a);
|
||||
GetSonarDistance();
|
||||
printf("%f\n",GetSonarDistance());
|
||||
}
|
||||
float Collector::GetSonarDistance(){
|
||||
printf("Sonar Distance %f\n",sonarAnalog->GetAverageVoltage());
|
||||
double Collector::GetSonarDistance(){
|
||||
return sonarAnalog->GetAverageVoltage();
|
||||
}
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -12,7 +12,7 @@ class Collector: public Subsystem
|
||||
Collector();
|
||||
void InitDefaultCommand();
|
||||
void MoveRollers(double);
|
||||
float GetSonarDistance();
|
||||
double GetSonarDistance();
|
||||
};
|
||||
#endif
|
||||
// vim: ts=2:sw=2:et
|
||||
|
Loading…
Reference in New Issue
Block a user