From e6310554c82ad70ee8157b879f01660bdd3fcd0f Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 26 Jul 2014 18:39:52 -0400 Subject: [PATCH] Changed function names ToThisCase instead of camelCase --- src/HHBase.cpp | 4 ++-- src/HHRobot.cpp | 38 +++++++++++++++--------------- src/HHRobot.h | 10 ++++---- src/Subsystems/Collector.cpp | 12 +++++----- src/Subsystems/Collector.h | 10 ++++---- src/Subsystems/Compressor.cpp | 10 ++++---- src/Subsystems/Compressor.h | 10 ++++---- src/Subsystems/Controller.cpp | 18 +++++++------- src/Subsystems/Controller.h | 10 ++++---- src/Subsystems/Dashboard.cpp | 8 +++---- src/Subsystems/Dashboard.h | 8 +++---- src/Subsystems/Shooter.cpp | 44 +++++++++++++++++------------------ src/Subsystems/Shooter.h | 16 ++++++------- src/Subsystems/Sonar.cpp | 2 +- src/Subsystems/Sonar.h | 2 +- 15 files changed, 100 insertions(+), 102 deletions(-) diff --git a/src/HHBase.cpp b/src/HHBase.cpp index 01e9dd8..1d641b2 100644 --- a/src/HHBase.cpp +++ b/src/HHBase.cpp @@ -7,7 +7,7 @@ HHBase::HHBase(): void HHBase::RobotInit(){ //Checks the state of the drive joystick to make sure it was not moved //while plugged in, giving inaccurate readings - if(!hHBot->checkJoystickValues()){ + if(!hHBot->CheckJoystickValues()){ printf("***UNPLUG AND REPLUG THE JOYSTICKS***\n"); } } @@ -20,7 +20,7 @@ void HHBase::TeleopContinuous(){} void HHBase::DisabledPeriodic(){} void HHBase::AutonomousPeriodic(){} void HHBase::TeleopPeriodic(){ - hHBot->handler(); + hHBot->Handler(); } void HHBase::Test(){} START_ROBOT_CLASS(HHBase); diff --git a/src/HHRobot.cpp b/src/HHRobot.cpp index 9f8c7a4..12c41ec 100644 --- a/src/HHRobot.cpp +++ b/src/HHRobot.cpp @@ -8,19 +8,19 @@ HHRobot::HHRobot(): dashboard(new HHDashboard()), sonar(new HHSonar()){ } -bool HHRobot::checkJoystickValues(){ +bool HHRobot::CheckJoystickValues(){ float x=ControlSystem->rightJoystickAxisValues[1]; float y=ControlSystem->rightJoystickAxisValues[2]; if((-.1 < x && x < .1) && (-.1 < y && y < .1)) { - dashboard->putBoolValue("Joysticks Valid", true); + dashboard->PutBoolValue("Joysticks Valid", true); return true; } else { - dashboard->putBoolValue("Joysticks Valid", false); + dashboard->PutBoolValue("Joysticks Valid", false); return true; return false; } } -void HHRobot::driveRobot(float x, float y){ +void HHRobot::DriveRobot(float x, float y){ if(y>1.0f) { y=1.0f; } else if(y!=0.0f&&y<-1.0f) { @@ -35,35 +35,35 @@ void HHRobot::driveRobot(float x, float y){ left2->SetRaw(int(leftPower)); left3->SetRaw(int(leftPower)); } -void HHRobot::updateDashboard(){ - dashboard->putFloatValue("Shooting Power", ControlSystem->throttle); +void HHRobot::UpdateDashboard(){ + dashboard->PutFloatValue("Shooting Power", ControlSystem->throttle); } //Main function used to handle periodic tasks on the robot -void HHRobot::handler(){ +void HHRobot::Handler(){ //Periodic tasks that should be run by every loop - ControlSystem->updateJoysticks(); - shooter->updateShooterPosition(); + ControlSystem->UpdateJoysticks(); + shooter->UpdateShooterPosition(); //TODO Need to implement a timing system to not break the spike (this function doesn't run the compressor at the moment) - compressorSystem->compressorSystemPeriodic(); - collector->updateCollector(shooter->isShooting, shooter->getAngle()); - if(checkJoystickValues()) { - driveRobot(ControlSystem->rightJoystickAxisValues[3]+ControlSystem->rightJoystickAxisValues[1], -ControlSystem->rightJoystickAxisValues[2]); + compressorSystem->CompressorSystemPeriodic(); + collector->UpdateCollector(shooter->isShooting, shooter->GetAngle()); + if(CheckJoystickValues()) { + DriveRobot(ControlSystem->rightJoystickAxisValues[3]+ControlSystem->rightJoystickAxisValues[1], -ControlSystem->rightJoystickAxisValues[2]); } - updateDashboard(); + UpdateDashboard(); //Button assignments to actions if(ControlSystem->leftJoystickValues[SHOOTER_FIRE]) { - shooter->startShootingSequence(ControlSystem->throttle); + shooter->StartShootingSequence(ControlSystem->throttle); } if(ControlSystem->rightJoystickValues[COLLECTOR_INTAKE]) { - collector->collectBall(); + collector->CollectBall(); } if(ControlSystem->rightJoystickValues[COLLECTOR_OUTTAKE]) { - collector->releaseBall(); + collector->ReleaseBall(); } if(ControlSystem->rightJoystickValues[COLLECTOR_EXTEND]) { - compressorSystem->extendCollector(); + compressorSystem->ExtendCollector(); } if(ControlSystem->rightJoystickValues[COLLECTOR_RETRACT]) { - compressorSystem->retractCollector(); + compressorSystem->RetractCollector(); } } diff --git a/src/HHRobot.h b/src/HHRobot.h index 3650172..27368dc 100644 --- a/src/HHRobot.h +++ b/src/HHRobot.h @@ -24,11 +24,9 @@ class HHRobot{ public: HHRobot(); float frontSonarLeftV, frontSonarRightV, rearSonarLeftV, rearSonarRightV; - float getFrontSonar(); - float getRearSonar(); - bool checkJoystickValues(); - void driveRobot(float,float); - void updateDashboard(); - void handler(); + bool CheckJoystickValues(); + void DriveRobot(float,float); + void UpdateDashboard(); + void Handler(); }; #endif diff --git a/src/Subsystems/Collector.cpp b/src/Subsystems/Collector.cpp index d889e62..2fa58a1 100644 --- a/src/Subsystems/Collector.cpp +++ b/src/Subsystems/Collector.cpp @@ -2,26 +2,26 @@ HHCollector::HHCollector(){ collectorMotor = new Jaguar(COLLECTOR_SIDECAR, COLLECTOR_MOTOR); } -void HHCollector::updateCollector(bool shooting, float angle){ +void HHCollector::UpdateCollector(bool shooting, float angle){ //Needed for the auto running of collector when shooting if(shooting){ if(angle <= 40){ - collectBall(); + CollectBall(); } } if(e_CollectorState == COLLECTING){ - collectBall(); + CollectBall(); } if(e_CollectorState == RELEASE){ - releaseBall(); + ReleaseBall(); } if(e_CollectorState == STOP){ collectorMotor->Set(0); } } -void HHCollector::collectBall(){ +void HHCollector::CollectBall(){ collectorMotor->Set(1); } -void HHCollector::releaseBall(){ +void HHCollector::ReleaseBall(){ collectorMotor->Set(255); } diff --git a/src/Subsystems/Collector.h b/src/Subsystems/Collector.h index 64c6f80..9ae8bdc 100644 --- a/src/Subsystems/Collector.h +++ b/src/Subsystems/Collector.h @@ -4,14 +4,14 @@ class HHCollector{ private: Jaguar *collectorMotor; public: + HHCollector(); enum{ COLLECTING, RELEASE, STOP }e_CollectorState; - HHCollector(); - void updateCollector(bool, float); - void collectBall(); - void releaseBall(); - void spinWithShot(float); + void UpdateCollector(bool, float); + void CollectBall(); + void ReleaseBall(); + void SpinWithShot(float); }; diff --git a/src/Subsystems/Compressor.cpp b/src/Subsystems/Compressor.cpp index 337ed64..90509c7 100644 --- a/src/Subsystems/Compressor.cpp +++ b/src/Subsystems/Compressor.cpp @@ -4,7 +4,7 @@ HHCompressor::HHCompressor(){ solenoid1=new Solenoid(COMPRESSOR_SOLENOID_ONE); solenoid2=new Solenoid(COMPRESSOR_SOLENOID_TWO); } -void HHCompressor::compressorSystemPeriodic(){ +void HHCompressor::CompressorSystemPeriodic(){ switch(e_CollectorSolenoidState){ case EXTENDED: solenoid1->Set(false); @@ -19,15 +19,15 @@ void HHCompressor::compressorSystemPeriodic(){ } e_CollectorSolenoidState=IDLE; } -void HHCompressor::startCompressing(){ +void HHCompressor::StartCompressing(){ compressor->Start(); } -void HHCompressor::stopCompressing(){ +void HHCompressor::StopCompressing(){ compressor->Stop(); } -void HHCompressor::extendCollector(){ +void HHCompressor::ExtendCollector(){ e_CollectorSolenoidState=EXTENDED; } -void HHCompressor::retractCollector(){ +void HHCompressor::RetractCollector(){ e_CollectorSolenoidState=RETRACTED; } diff --git a/src/Subsystems/Compressor.h b/src/Subsystems/Compressor.h index bc91ec5..9dcfc4b 100644 --- a/src/Subsystems/Compressor.h +++ b/src/Subsystems/Compressor.h @@ -11,9 +11,9 @@ class HHCompressor{ IDLE }e_CollectorSolenoidState; HHCompressor(); - void compressorSystemPeriodic(); - void extendCollector(); - void retractCollector(); - void startCompressing(); - void stopCompressing(); + void CompressorSystemPeriodic(); + void ExtendCollector(); + void RetractCollector(); + void StartCompressing(); + void StopCompressing(); }; diff --git a/src/Subsystems/Controller.cpp b/src/Subsystems/Controller.cpp index 354c4c0..725bf6b 100644 --- a/src/Subsystems/Controller.cpp +++ b/src/Subsystems/Controller.cpp @@ -3,29 +3,29 @@ JoystickController::JoystickController(){ rightJoystick=new Joystick(JOYSTICK_RIGHT); leftJoystick=new Joystick(JOYSTICK_LEFT); } -void JoystickController::updateJoysticks(){ - getRightJoystick(); - getLeftJoystick(); - getRightJoystickAxis(); - getLeftJoystickAxis(); +void JoystickController::UpdateJoysticks(){ + GetRightJoystick(); + GetLeftJoystick(); + GetRightJoystickAxis(); + GetLeftJoystickAxis(); throttle=(-leftJoystickAxisValues[4]+1)/2; } -void JoystickController::getRightJoystick(){ +void JoystickController::GetRightJoystick(){ for(int i=1;i<13;i++){ rightJoystickValues[i]=rightJoystick->GetRawButton(i); } } -void JoystickController::getLeftJoystick(){ +void JoystickController::GetLeftJoystick(){ for(int i=1;i<13;i++){ leftJoystickValues[i]=leftJoystick->GetRawButton(i); } } -void JoystickController::getRightJoystickAxis(){ +void JoystickController::GetRightJoystickAxis(){ for(int i=1;i<7;i++){ rightJoystickAxisValues[i]=rightJoystick->GetRawAxis(i); } } -void JoystickController::getLeftJoystickAxis(){ +void JoystickController::GetLeftJoystickAxis(){ for(int i=1;i<7;i++){ leftJoystickAxisValues[i]=leftJoystick->GetRawAxis(i); } diff --git a/src/Subsystems/Controller.h b/src/Subsystems/Controller.h index 2a4de9f..a19eb04 100644 --- a/src/Subsystems/Controller.h +++ b/src/Subsystems/Controller.h @@ -11,9 +11,9 @@ class JoystickController float rightJoystickAxisValues[]; float throttle; JoystickController(); - void updateJoysticks(); - void getRightJoystick(); - void getLeftJoystick(); - void getLeftJoystickAxis(); - void getRightJoystickAxis(); + void UpdateJoysticks(); + void GetRightJoystick(); + void GetLeftJoystick(); + void GetLeftJoystickAxis(); + void GetRightJoystickAxis(); }; diff --git a/src/Subsystems/Dashboard.cpp b/src/Subsystems/Dashboard.cpp index a805de0..4a1a145 100644 --- a/src/Subsystems/Dashboard.cpp +++ b/src/Subsystems/Dashboard.cpp @@ -4,19 +4,19 @@ HHDashboard::HHDashboard(){ SmartDashboard::PutNumber("Shooting Power", 0.0f); SmartDashboard::PutBoolean("Joysticks Valid", false); } -float HHDashboard::getFloatValue(const char* key){ +float HHDashboard::GetFloatValue(const char* key){ float value=SmartDashboard::GetNumber(key); return value; } -bool HHDashboard::putFloatValue(const char* key, float value){ +bool HHDashboard::PutFloatValue(const char* key, float value){ SmartDashboard::PutNumber(key,value); return true; } -bool HHDashboard::getBoolValue(const char* key){ +bool HHDashboard::GetBoolValue(const char* key){ bool value=SmartDashboard::GetBoolean(key); return value; } -bool HHDashboard::putBoolValue(const char* key, bool value){ +bool HHDashboard::PutBoolValue(const char* key, bool value){ SmartDashboard::PutBoolean(key,value); return true; } diff --git a/src/Subsystems/Dashboard.h b/src/Subsystems/Dashboard.h index c6973eb..279a039 100644 --- a/src/Subsystems/Dashboard.h +++ b/src/Subsystems/Dashboard.h @@ -6,8 +6,8 @@ class HHDashboard{ HHDashboard(); //Array used to track the values in the dashboard bool DashboardValues[]; - float getFloatValue(const char* key); - bool putFloatValue(const char* key, float value); - bool getBoolValue(const char* key); - bool putBoolValue(const char* key, bool value); + float GetFloatValue(const char* key); + bool PutFloatValue(const char* key, float value); + bool GetBoolValue(const char* key); + bool PutBoolValue(const char* key, bool value); }; diff --git a/src/Subsystems/Shooter.cpp b/src/Subsystems/Shooter.cpp index bf64cff..9b6eb6c 100644 --- a/src/Subsystems/Shooter.cpp +++ b/src/Subsystems/Shooter.cpp @@ -7,15 +7,15 @@ HHShooter::HHShooter(){ shooterAngle=new AnalogChannel(SHOOTER_ANGLE_POT); e_ShooterState=IDLE_PRESHOT; } -void HHShooter::startShootingSequence(float throttle){ +void HHShooter::StartShootingSequence(float throttle){ //Changes the enum to tell the shooter to be firing e_ShooterState=FIRING; shootingPower=throttle; } //First step in shooting process -void HHShooter::shootForAngle(float power, float desiredAngle){ - if(getAngle() <= desiredAngle && power >= 15){ - shootRaw(power); +void HHShooter::ShootForAngle(float power, float desiredAngle){ + if(GetAngle() <= desiredAngle && power >= 15){ + ShootRaw(power); e_ShooterState=FIRING; } else{ @@ -23,50 +23,50 @@ void HHShooter::shootForAngle(float power, float desiredAngle){ } } //Second step in shooting process -//Probably wont need to be used without shootForAngle -void HHShooter::lower(float desiredAngle){ - if(getAngle() >= desiredAngle){ - shootRaw(-0.1f); +//Probably wont need to be used without ShootForAngle +void HHShooter::Lower(float desiredAngle){ + if(GetAngle() >= desiredAngle){ + ShootRaw(-0.1f); e_ShooterState=LOWERING; } else{ - shootRaw(0.0f); + ShootRaw(0.0f); e_ShooterState=IDLE_PRESHOT; } } //Not needed anywhere other than after/before the shooting process -void HHShooter::stopShooter(){ +void HHShooter::StopShooter(){ if(e_ShooterState == IDLE_PRESHOT){ - shootRaw(0.0f); + ShootRaw(0.0f); } } //Shouldn't be used in any other class but this one -void HHShooter::shootRaw(float power){ - shooterLeft1->SetRaw(int(floatToPWM(power))); - shooterLeft2->SetRaw(int(floatToPWM(power))); - shooterRight1->SetRaw(int(floatToPWM(-power))); - shooterRight2->SetRaw(int(floatToPWM(-power))); +void HHShooter::ShootRaw(float power){ + shooterLeft1->SetRaw(int(FloatToPWM(power))); + shooterLeft2->SetRaw(int(FloatToPWM(power))); + shooterRight1->SetRaw(int(FloatToPWM(-power))); + shooterRight2->SetRaw(int(FloatToPWM(-power))); } //Should be run in a loop -void HHShooter::updateShooterPosition(){ +void HHShooter::UpdateShooterPosition(){ if(e_ShooterState == IDLE_PRESHOT){ isShooting=false; - stopShooter(); + StopShooter(); } if(e_ShooterState == FIRING){ isShooting=true; - shootForAngle(shootingPower,110); + ShootForAngle(shootingPower,110); } if(e_ShooterState == IDLE_POSTSHOT){ isShooting=false; - lower(40); + Lower(40); } } -float HHShooter::floatToPWM(float input){ +float HHShooter::FloatToPWM(float input){ return input*127.0+128; } //Returns angle measure in degrees -float HHShooter::getAngle(){ +float HHShooter::GetAngle(){ float max=-.0003948; float min=5.0245547; float b=shooterAngle->GetAverageVoltage()-max; diff --git a/src/Subsystems/Shooter.h b/src/Subsystems/Shooter.h index a0e4172..e177073 100644 --- a/src/Subsystems/Shooter.h +++ b/src/Subsystems/Shooter.h @@ -14,12 +14,12 @@ class HHShooter{ }e_ShooterState; bool isShooting; float shootingPower; - void startShootingSequence(float); - void shootForAngle(float, float); - void shootRaw(float); - void lower(float); - void stopShooter(); - void updateShooterPosition(); - float floatToPWM(float input); - float getAngle(); + void StartShootingSequence(float); + void ShootForAngle(float, float); + void ShootRaw(float); + void Lower(float); + void StopShooter(); + void UpdateShooterPosition(); + float FloatToPWM(float input); + float GetAngle(); }; diff --git a/src/Subsystems/Sonar.cpp b/src/Subsystems/Sonar.cpp index e97685f..fafecc9 100644 --- a/src/Subsystems/Sonar.cpp +++ b/src/Subsystems/Sonar.cpp @@ -9,7 +9,7 @@ HHSonar::HHSonar(){ AnalogChannel backLeftA=new AnalogChannel(SONAR_BACK_LEFT_ANA); AnalogChannel backRightA=new AnalogChannel(SONAR_BACK_RIGHT_ANA); } -float HHSonar::getInches(std::string from){ +float HHSonar::GetInches(std::string from){ switch(from){ case "FRONT": frontLeftD->Set(1); diff --git a/src/Subsystems/Sonar.h b/src/Subsystems/Sonar.h index 3063b27..9d35987 100644 --- a/src/Subsystems/Sonar.h +++ b/src/Subsystems/Sonar.h @@ -7,5 +7,5 @@ class HHSonar{ public: HHSonar(); //from is (in string form) "FRONT", "BACK", "FRONTLEFT", "FRONTRIGHT"... - float getInches(std::string from); + float GetInches(std::string from); };