mirror of
https://github.com/team2059/Zaphod
synced 2024-12-18 20:12:28 -05:00
Fixed compressor (not fully tested)
This commit is contained in:
parent
33bc43da83
commit
ed81f52e2f
@ -18,6 +18,8 @@ HHRobot::HHRobot():
|
|||||||
left2 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_TWO);
|
left2 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_TWO);
|
||||||
left3 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_THREE);
|
left3 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_THREE);
|
||||||
shooterTable->PutNumber("Target Shooter Angle",90);
|
shooterTable->PutNumber("Target Shooter Angle",90);
|
||||||
|
timer = new Timer();
|
||||||
|
lastTime = 0;
|
||||||
}
|
}
|
||||||
void HHRobot::Init(){
|
void HHRobot::Init(){
|
||||||
printf("Initing\n");
|
printf("Initing\n");
|
||||||
@ -26,6 +28,8 @@ void HHRobot::Init(){
|
|||||||
//Put table values initally to avoid annoying refreshing
|
//Put table values initally to avoid annoying refreshing
|
||||||
shooterTable->PutNumber("Target Shooter Angle",90);
|
shooterTable->PutNumber("Target Shooter Angle",90);
|
||||||
shooterTable->PutNumber("Current Shooter Angle",-420);
|
shooterTable->PutNumber("Current Shooter Angle",-420);
|
||||||
|
timer->Start();
|
||||||
|
compressorSystem->StartCompressor();
|
||||||
}
|
}
|
||||||
bool HHRobot::CheckJoystickValues(){
|
bool HHRobot::CheckJoystickValues(){
|
||||||
float x=controlSystem->GetJoystickAxis(1,"x");
|
float x=controlSystem->GetJoystickAxis(1,"x");
|
||||||
@ -79,6 +83,7 @@ void HHRobot::UpdateDashboard(){
|
|||||||
dashboard->PutFloatValue("Shooting Power",controlSystem->GetThrottle());
|
dashboard->PutFloatValue("Shooting Power",controlSystem->GetThrottle());
|
||||||
}
|
}
|
||||||
void HHRobot::RunAuto(){
|
void HHRobot::RunAuto(){
|
||||||
|
timer->Reset();
|
||||||
int step,time;
|
int step,time;
|
||||||
compressorSystem->ExtendCollector();
|
compressorSystem->ExtendCollector();
|
||||||
//TODO I have no idea what rate this loop runs at so we are going to have to fine tune the times
|
//TODO I have no idea what rate this loop runs at so we are going to have to fine tune the times
|
||||||
@ -108,11 +113,14 @@ 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(){
|
||||||
double targetAngle = shooterTable->GetNumber("Target Shooter Angle");
|
double targetAngle = shooterTable->GetNumber("Target Shooter Angle");
|
||||||
bool allowCompressing;
|
bool allowCompressing = true;
|
||||||
//Periodic tasks that should be run by every loop
|
//Periodic tasks that should be run by every loop
|
||||||
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)
|
if(timer->Get()-lastTime>=0.5f){
|
||||||
compressorSystem->CompressorSystemPeriodic(allowCompressing);
|
// Update compressor when current time-last time is more than .5 seconds
|
||||||
|
lastTime=timer->Get();
|
||||||
|
compressorSystem->CompressorSystemPeriodic(allowCompressing);
|
||||||
|
}
|
||||||
collector->UpdateCollector(shooter->isShooting,shooter->GetAngle());
|
collector->UpdateCollector(shooter->isShooting,shooter->GetAngle());
|
||||||
//TODO Fix whatever the heck is wrong with this
|
//TODO Fix whatever the heck is wrong with this
|
||||||
DriveRobot(controlSystem->GetJoystickAxis(1,"z")+controlSystem->GetJoystickAxis(1,"x"),controlSystem->GetJoystickAxis(1,"y"));
|
DriveRobot(controlSystem->GetJoystickAxis(1,"z")+controlSystem->GetJoystickAxis(1,"x"),controlSystem->GetJoystickAxis(1,"y"));
|
||||||
@ -152,13 +160,6 @@ void HHRobot::Handler(){
|
|||||||
}
|
}
|
||||||
shooterTable->PutNumber("Target Shooter Angle",targetAngle);
|
shooterTable->PutNumber("Target Shooter Angle",targetAngle);
|
||||||
//TODO: Fix whatever this is supposed to do
|
//TODO: Fix whatever this is supposed to do
|
||||||
//if(controlSystem->rightJoystickValues[DISABLE_COMPRESSOR]){}
|
|
||||||
if(false){
|
|
||||||
allowCompressing=false;
|
|
||||||
}else{
|
|
||||||
allowCompressing=true;
|
|
||||||
}
|
|
||||||
//TODO: Fix whatever this is supposed to do
|
|
||||||
//if(controlSystem->rightJoystickValues[DRIVE_FOR_DISTANCE]){}
|
//if(controlSystem->rightJoystickValues[DRIVE_FOR_DISTANCE]){}
|
||||||
if(false){
|
if(false){
|
||||||
targetAngle=100;
|
targetAngle=100;
|
||||||
|
@ -21,6 +21,8 @@ class HHRobot{
|
|||||||
HHCompressor *compressorSystem;
|
HHCompressor *compressorSystem;
|
||||||
HHDashboard *dashboard;
|
HHDashboard *dashboard;
|
||||||
HHSonar *sonar;
|
HHSonar *sonar;
|
||||||
|
Timer *timer;
|
||||||
|
double lastTime;
|
||||||
public:
|
public:
|
||||||
HHRobot();
|
HHRobot();
|
||||||
bool CheckJoystickValues();
|
bool CheckJoystickValues();
|
||||||
|
@ -3,6 +3,7 @@ HHCompressor::HHCompressor(){
|
|||||||
compressor=new Compressor(COMPRESSOR_GAUGE_SIDECAR, COMPRESSOR_GAUGE, COMPRESSOR_RELAY_SIDECAR, COMPRESSOR_RELAY);
|
compressor=new Compressor(COMPRESSOR_GAUGE_SIDECAR, COMPRESSOR_GAUGE, COMPRESSOR_RELAY_SIDECAR, COMPRESSOR_RELAY);
|
||||||
solenoid1=new Solenoid(COMPRESSOR_SOLENOID_ONE);
|
solenoid1=new Solenoid(COMPRESSOR_SOLENOID_ONE);
|
||||||
solenoid2=new Solenoid(COMPRESSOR_SOLENOID_TWO);
|
solenoid2=new Solenoid(COMPRESSOR_SOLENOID_TWO);
|
||||||
|
compressing=false;
|
||||||
}
|
}
|
||||||
void HHCompressor::CompressorSystemPeriodic(bool compressorEnabled){
|
void HHCompressor::CompressorSystemPeriodic(bool compressorEnabled){
|
||||||
switch(e_CollectorSolenoidState){
|
switch(e_CollectorSolenoidState){
|
||||||
@ -20,13 +21,23 @@ void HHCompressor::CompressorSystemPeriodic(bool compressorEnabled){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(compressorEnabled){
|
if(compressorEnabled){
|
||||||
if(compressor->GetPressureSwitchValue()==1){
|
printf("Compressor is enabled\n");
|
||||||
compressor->Start();
|
if(compressing&&compressor->GetPressureSwitchValue()==1){
|
||||||
}else{
|
// It is compressing, but the pressure is too high
|
||||||
compressor->Stop();
|
printf("Condition 1");
|
||||||
|
StopCompressor();
|
||||||
|
}else if(!compressing&&compressor->GetPressureSwitchValue()==0){
|
||||||
|
// It is not compressing and the pressure isn't too high
|
||||||
|
printf("Condition 2");
|
||||||
|
StartCompressor();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
compressor->Stop();
|
printf("Condition 3");
|
||||||
|
if(compressing){
|
||||||
|
// If the compressor is not enabled, but it's still compressing
|
||||||
|
printf("Condition 4");
|
||||||
|
StopCompressor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
e_CollectorSolenoidState=IDLE;
|
e_CollectorSolenoidState=IDLE;
|
||||||
}
|
}
|
||||||
@ -36,4 +47,14 @@ void HHCompressor::ExtendCollector(){
|
|||||||
void HHCompressor::RetractCollector(){
|
void HHCompressor::RetractCollector(){
|
||||||
e_CollectorSolenoidState=RETRACTED;
|
e_CollectorSolenoidState=RETRACTED;
|
||||||
}
|
}
|
||||||
|
void HHCompressor::StopCompressor(){
|
||||||
|
printf("Stopping compressor\n");
|
||||||
|
compressor->Stop();
|
||||||
|
compressing=false;
|
||||||
|
}
|
||||||
|
void HHCompressor::StartCompressor(){
|
||||||
|
printf("Starting compressor\n");
|
||||||
|
compressor->Start();
|
||||||
|
compressing=true;
|
||||||
|
}
|
||||||
// vim: ts=2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -5,6 +5,7 @@ class HHCompressor{
|
|||||||
private:
|
private:
|
||||||
Compressor *compressor;
|
Compressor *compressor;
|
||||||
Solenoid *solenoid1, *solenoid2;
|
Solenoid *solenoid1, *solenoid2;
|
||||||
|
bool compressing;
|
||||||
public:
|
public:
|
||||||
enum{
|
enum{
|
||||||
EXTENDED,
|
EXTENDED,
|
||||||
@ -15,5 +16,7 @@ class HHCompressor{
|
|||||||
void CompressorSystemPeriodic(bool compressorEnabled);
|
void CompressorSystemPeriodic(bool compressorEnabled);
|
||||||
void ExtendCollector();
|
void ExtendCollector();
|
||||||
void RetractCollector();
|
void RetractCollector();
|
||||||
|
void StopCompressor();
|
||||||
|
void StartCompressor();
|
||||||
};
|
};
|
||||||
// vim: ts=2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
Loading…
Reference in New Issue
Block a user