mirror of
https://github.com/team2059/Zaphod
synced 2025-01-07 22:14:14 -05:00
Added feature to disable the compressor on the fly
This commit is contained in:
parent
64c22c0699
commit
a7f201d1f3
@ -43,6 +43,7 @@
|
||||
#define SHOOTER_ANGLE_POT 6
|
||||
|
||||
//Ultrasonic (DIO, Analog, etc)
|
||||
|
||||
#define SONAR_FRONT_RIGHT_DIO 4
|
||||
#define SONAR_FRONT_LEFT_DIO 4
|
||||
#define SONAR_BACK_LEFT_DIO 5
|
||||
@ -61,6 +62,7 @@
|
||||
//Static button assignments
|
||||
|
||||
#define SHOOTER_FIRE 1
|
||||
#define DISABLE_COMPRESSOR 2
|
||||
#define COLLECTOR_INTAKE 1
|
||||
#define COLLECTOR_OUTTAKE 2
|
||||
#define COLLECTOR_EXTEND 9
|
||||
@ -69,6 +71,10 @@
|
||||
#define SHOOTER_ANGLE_TWO 4
|
||||
#define SHOOTER_ANGLE_THREE 5
|
||||
#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
|
||||
|
||||
//Drive threshold definitions
|
||||
|
@ -53,11 +53,12 @@ void HHRobot::RunAuto(){
|
||||
//Main function used to handle periodic tasks on the robot
|
||||
void HHRobot::Handler(){
|
||||
int targetAngle;
|
||||
bool allowCompressing = true;
|
||||
//Periodic tasks that should be run by every loop
|
||||
ControlSystem->UpdateJoysticks();
|
||||
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)
|
||||
compressorSystem->CompressorSystemPeriodic();
|
||||
compressorSystem->CompressorSystemPeriodic(alowCompressing);
|
||||
collector->UpdateCollector(shooter->isShooting, shooter->GetAngle());
|
||||
if(CheckJoystickValues()) {
|
||||
DriveRobot(ControlSystem->rightJoystickAxisValues[3]+ControlSystem->rightJoystickAxisValues[1], -ControlSystem->rightJoystickAxisValues[2]);
|
||||
@ -83,14 +84,18 @@ void HHRobot::Handler(){
|
||||
targetAngle = 100;
|
||||
}
|
||||
if(ControlSystem->leftJoystickValues[SHOOTER_ANGLE_TWO]){
|
||||
targetAngle = 120;
|
||||
targetAngle = 120;
|
||||
}
|
||||
if(ControlSystem->leftJoystickValues[SHOOTER_ANGLE_THREE]){
|
||||
targetAngle = 90;
|
||||
targetAngle = 90;
|
||||
}
|
||||
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]){
|
||||
targetAngle = 100;
|
||||
if(sonar->GetInches("FRONTLEFT") >= 45){
|
||||
|
@ -20,7 +20,7 @@ void HHCollector::UpdateCollector(bool shooting, float angle){
|
||||
}
|
||||
}
|
||||
void HHCollector::CollectBallAtSpeed(float speed){
|
||||
collectorMotor->Set(speed);
|
||||
collectorMotor->Set(speed);
|
||||
}
|
||||
void HHCollector::CollectBall(){
|
||||
collectorMotor->Set(1);
|
||||
|
@ -4,7 +4,7 @@ HHCompressor::HHCompressor(){
|
||||
solenoid1=new Solenoid(COMPRESSOR_SOLENOID_ONE);
|
||||
solenoid2=new Solenoid(COMPRESSOR_SOLENOID_TWO);
|
||||
}
|
||||
void HHCompressor::CompressorSystemPeriodic(){
|
||||
void HHCompressor::CompressorSystemPeriodic(bool compressorEnabled){
|
||||
switch(e_CollectorSolenoidState){
|
||||
case EXTENDED:
|
||||
solenoid1->Set(false);
|
||||
@ -19,8 +19,12 @@ void HHCompressor::CompressorSystemPeriodic(){
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(compressor->GetPressureSwitchValue()==1){
|
||||
compressor->Start();
|
||||
if(compressorEnabled){
|
||||
if(compressor->GetPressureSwitchValue()==1){
|
||||
compressor->Start();
|
||||
}else{
|
||||
compressor->Stop();
|
||||
}
|
||||
}else{
|
||||
compressor->Stop();
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ class HHCompressor{
|
||||
private:
|
||||
Compressor *compressor;
|
||||
Solenoid *solenoid1, *solenoid2;
|
||||
time_t t;
|
||||
public:
|
||||
enum{
|
||||
EXTENDED,
|
||||
@ -13,7 +12,7 @@ class HHCompressor{
|
||||
IDLE
|
||||
}e_CollectorSolenoidState;
|
||||
HHCompressor();
|
||||
void CompressorSystemPeriodic();
|
||||
void CompressorSystemPeriodic(bool compressorEnabled);
|
||||
void ExtendCollector();
|
||||
void RetractCollector();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user