2
0
mirror of https://github.com/team2059/Zaphod synced 2025-01-27 22:21:07 -05:00

Added feature to disable the compressor on the fly

This commit is contained in:
Adam Long 2014-10-11 20:03:01 -04:00
parent 64c22c0699
commit a7f201d1f3
5 changed files with 24 additions and 10 deletions

View File

@ -43,6 +43,7 @@
#define SHOOTER_ANGLE_POT 6 #define SHOOTER_ANGLE_POT 6
//Ultrasonic (DIO, Analog, etc) //Ultrasonic (DIO, Analog, etc)
#define SONAR_FRONT_RIGHT_DIO 4 #define SONAR_FRONT_RIGHT_DIO 4
#define SONAR_FRONT_LEFT_DIO 4 #define SONAR_FRONT_LEFT_DIO 4
#define SONAR_BACK_LEFT_DIO 5 #define SONAR_BACK_LEFT_DIO 5
@ -61,6 +62,7 @@
//Static button assignments //Static button assignments
#define SHOOTER_FIRE 1 #define SHOOTER_FIRE 1
#define DISABLE_COMPRESSOR 2
#define COLLECTOR_INTAKE 1 #define COLLECTOR_INTAKE 1
#define COLLECTOR_OUTTAKE 2 #define COLLECTOR_OUTTAKE 2
#define COLLECTOR_EXTEND 9 #define COLLECTOR_EXTEND 9
@ -69,6 +71,10 @@
#define SHOOTER_ANGLE_TWO 4 #define SHOOTER_ANGLE_TWO 4
#define SHOOTER_ANGLE_THREE 5 #define SHOOTER_ANGLE_THREE 5
#define SHOOTER_ANGLE_FOUR 6 #define SHOOTER_ANGLE_FOUR 6
//#define SHOOTER_POWER_ONE
//#define SHOOTER_POWER_TWO
//#define SHOOTER_POWER_THREE
//#define SHOOTER_POWER_FOUR
#define DRIVE_FOR_DISTANCE 11 #define DRIVE_FOR_DISTANCE 11
//Drive threshold definitions //Drive threshold definitions

View File

@ -53,11 +53,12 @@ void HHRobot::RunAuto(){
//Main function used to handle periodic tasks on the robot //Main function used to handle periodic tasks on the robot
void HHRobot::Handler(){ void HHRobot::Handler(){
int targetAngle; int targetAngle;
bool allowCompressing = true;
//Periodic tasks that should be run by every loop //Periodic tasks that should be run by every loop
ControlSystem->UpdateJoysticks(); ControlSystem->UpdateJoysticks();
shooter->UpdateShooterPosition(targetAngle); shooter->UpdateShooterPosition(targetAngle);
//TODO Need to implement a timing system to not break the spike (this function doesn't run the compressor at the moment) //TODO Need to implement a timing system to not break the spike (this function doesn't run the compressor at the moment)
compressorSystem->CompressorSystemPeriodic(); compressorSystem->CompressorSystemPeriodic(alowCompressing);
collector->UpdateCollector(shooter->isShooting, shooter->GetAngle()); collector->UpdateCollector(shooter->isShooting, shooter->GetAngle());
if(CheckJoystickValues()) { if(CheckJoystickValues()) {
DriveRobot(ControlSystem->rightJoystickAxisValues[3]+ControlSystem->rightJoystickAxisValues[1], -ControlSystem->rightJoystickAxisValues[2]); DriveRobot(ControlSystem->rightJoystickAxisValues[3]+ControlSystem->rightJoystickAxisValues[1], -ControlSystem->rightJoystickAxisValues[2]);
@ -83,14 +84,18 @@ void HHRobot::Handler(){
targetAngle = 100; targetAngle = 100;
} }
if(ControlSystem->leftJoystickValues[SHOOTER_ANGLE_TWO]){ if(ControlSystem->leftJoystickValues[SHOOTER_ANGLE_TWO]){
targetAngle = 120; targetAngle = 120;
} }
if(ControlSystem->leftJoystickValues[SHOOTER_ANGLE_THREE]){ if(ControlSystem->leftJoystickValues[SHOOTER_ANGLE_THREE]){
targetAngle = 90; targetAngle = 90;
} }
if(ControlSystem->leftJoystickValues[SHOOTER_ANGLE_FOUR]){ if(ControlSystem->leftJoystickValues[SHOOTER_ANGLE_FOUR]){
targetAngle = 130; targetAngle = 130;
} }
if(ControlSystem->rightJoystickValues[DISABLE_COMPRESSOR]){
allowCompressing = false;
}else{
allowCompressing = true;
if(ControlSystem->rightJoystickValues[DRIVE_FOR_DISTANCE]){ if(ControlSystem->rightJoystickValues[DRIVE_FOR_DISTANCE]){
targetAngle = 100; targetAngle = 100;
if(sonar->GetInches("FRONTLEFT") >= 45){ if(sonar->GetInches("FRONTLEFT") >= 45){

View File

@ -20,7 +20,7 @@ void HHCollector::UpdateCollector(bool shooting, float angle){
} }
} }
void HHCollector::CollectBallAtSpeed(float speed){ void HHCollector::CollectBallAtSpeed(float speed){
collectorMotor->Set(speed); collectorMotor->Set(speed);
} }
void HHCollector::CollectBall(){ void HHCollector::CollectBall(){
collectorMotor->Set(1); collectorMotor->Set(1);

View File

@ -4,7 +4,7 @@ HHCompressor::HHCompressor(){
solenoid1=new Solenoid(COMPRESSOR_SOLENOID_ONE); solenoid1=new Solenoid(COMPRESSOR_SOLENOID_ONE);
solenoid2=new Solenoid(COMPRESSOR_SOLENOID_TWO); solenoid2=new Solenoid(COMPRESSOR_SOLENOID_TWO);
} }
void HHCompressor::CompressorSystemPeriodic(){ void HHCompressor::CompressorSystemPeriodic(bool compressorEnabled){
switch(e_CollectorSolenoidState){ switch(e_CollectorSolenoidState){
case EXTENDED: case EXTENDED:
solenoid1->Set(false); solenoid1->Set(false);
@ -19,8 +19,12 @@ void HHCompressor::CompressorSystemPeriodic(){
default: default:
break; break;
} }
if(compressor->GetPressureSwitchValue()==1){ if(compressorEnabled){
compressor->Start(); if(compressor->GetPressureSwitchValue()==1){
compressor->Start();
}else{
compressor->Stop();
}
}else{ }else{
compressor->Stop(); compressor->Stop();
} }

View File

@ -5,7 +5,6 @@ class HHCompressor{
private: private:
Compressor *compressor; Compressor *compressor;
Solenoid *solenoid1, *solenoid2; Solenoid *solenoid1, *solenoid2;
time_t t;
public: public:
enum{ enum{
EXTENDED, EXTENDED,
@ -13,7 +12,7 @@ class HHCompressor{
IDLE IDLE
}e_CollectorSolenoidState; }e_CollectorSolenoidState;
HHCompressor(); HHCompressor();
void CompressorSystemPeriodic(); void CompressorSystemPeriodic(bool compressorEnabled);
void ExtendCollector(); void ExtendCollector();
void RetractCollector(); void RetractCollector();
}; };