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

Changed function names ToThisCase instead of camelCase

This commit is contained in:
Austen Adler 2014-07-26 18:39:52 -04:00
parent de4a4f448a
commit e6310554c8
15 changed files with 100 additions and 102 deletions

View File

@ -7,7 +7,7 @@ HHBase::HHBase():
void HHBase::RobotInit(){ void HHBase::RobotInit(){
//Checks the state of the drive joystick to make sure it was not moved //Checks the state of the drive joystick to make sure it was not moved
//while plugged in, giving inaccurate readings //while plugged in, giving inaccurate readings
if(!hHBot->checkJoystickValues()){ if(!hHBot->CheckJoystickValues()){
printf("***UNPLUG AND REPLUG THE JOYSTICKS***\n"); printf("***UNPLUG AND REPLUG THE JOYSTICKS***\n");
} }
} }
@ -20,7 +20,7 @@ void HHBase::TeleopContinuous(){}
void HHBase::DisabledPeriodic(){} void HHBase::DisabledPeriodic(){}
void HHBase::AutonomousPeriodic(){} void HHBase::AutonomousPeriodic(){}
void HHBase::TeleopPeriodic(){ void HHBase::TeleopPeriodic(){
hHBot->handler(); hHBot->Handler();
} }
void HHBase::Test(){} void HHBase::Test(){}
START_ROBOT_CLASS(HHBase); START_ROBOT_CLASS(HHBase);

View File

@ -8,19 +8,19 @@ HHRobot::HHRobot():
dashboard(new HHDashboard()), dashboard(new HHDashboard()),
sonar(new HHSonar()){ sonar(new HHSonar()){
} }
bool HHRobot::checkJoystickValues(){ bool HHRobot::CheckJoystickValues(){
float x=ControlSystem->rightJoystickAxisValues[1]; float x=ControlSystem->rightJoystickAxisValues[1];
float y=ControlSystem->rightJoystickAxisValues[2]; float y=ControlSystem->rightJoystickAxisValues[2];
if((-.1 < x && x < .1) && (-.1 < y && y < .1)) { if((-.1 < x && x < .1) && (-.1 < y && y < .1)) {
dashboard->putBoolValue("Joysticks Valid", true); dashboard->PutBoolValue("Joysticks Valid", true);
return true; return true;
} else { } else {
dashboard->putBoolValue("Joysticks Valid", false); dashboard->PutBoolValue("Joysticks Valid", false);
return true; return true;
return false; return false;
} }
} }
void HHRobot::driveRobot(float x, float y){ void HHRobot::DriveRobot(float x, float y){
if(y>1.0f) { if(y>1.0f) {
y=1.0f; y=1.0f;
} else if(y!=0.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)); left2->SetRaw(int(leftPower));
left3->SetRaw(int(leftPower)); left3->SetRaw(int(leftPower));
} }
void HHRobot::updateDashboard(){ void HHRobot::UpdateDashboard(){
dashboard->putFloatValue("Shooting Power", ControlSystem->throttle); dashboard->PutFloatValue("Shooting Power", ControlSystem->throttle);
} }
//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(){
//Periodic tasks that should be run by every loop //Periodic tasks that should be run by every loop
ControlSystem->updateJoysticks(); ControlSystem->UpdateJoysticks();
shooter->updateShooterPosition(); shooter->UpdateShooterPosition();
//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();
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]);
} }
updateDashboard(); UpdateDashboard();
//Button assignments to actions //Button assignments to actions
if(ControlSystem->leftJoystickValues[SHOOTER_FIRE]) { if(ControlSystem->leftJoystickValues[SHOOTER_FIRE]) {
shooter->startShootingSequence(ControlSystem->throttle); shooter->StartShootingSequence(ControlSystem->throttle);
} }
if(ControlSystem->rightJoystickValues[COLLECTOR_INTAKE]) { if(ControlSystem->rightJoystickValues[COLLECTOR_INTAKE]) {
collector->collectBall(); collector->CollectBall();
} }
if(ControlSystem->rightJoystickValues[COLLECTOR_OUTTAKE]) { if(ControlSystem->rightJoystickValues[COLLECTOR_OUTTAKE]) {
collector->releaseBall(); collector->ReleaseBall();
} }
if(ControlSystem->rightJoystickValues[COLLECTOR_EXTEND]) { if(ControlSystem->rightJoystickValues[COLLECTOR_EXTEND]) {
compressorSystem->extendCollector(); compressorSystem->ExtendCollector();
} }
if(ControlSystem->rightJoystickValues[COLLECTOR_RETRACT]) { if(ControlSystem->rightJoystickValues[COLLECTOR_RETRACT]) {
compressorSystem->retractCollector(); compressorSystem->RetractCollector();
} }
} }

View File

@ -24,11 +24,9 @@ class HHRobot{
public: public:
HHRobot(); HHRobot();
float frontSonarLeftV, frontSonarRightV, rearSonarLeftV, rearSonarRightV; float frontSonarLeftV, frontSonarRightV, rearSonarLeftV, rearSonarRightV;
float getFrontSonar(); bool CheckJoystickValues();
float getRearSonar(); void DriveRobot(float,float);
bool checkJoystickValues(); void UpdateDashboard();
void driveRobot(float,float); void Handler();
void updateDashboard();
void handler();
}; };
#endif #endif

View File

@ -2,26 +2,26 @@
HHCollector::HHCollector(){ HHCollector::HHCollector(){
collectorMotor = new Jaguar(COLLECTOR_SIDECAR, COLLECTOR_MOTOR); 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 //Needed for the auto running of collector when shooting
if(shooting){ if(shooting){
if(angle <= 40){ if(angle <= 40){
collectBall(); CollectBall();
} }
} }
if(e_CollectorState == COLLECTING){ if(e_CollectorState == COLLECTING){
collectBall(); CollectBall();
} }
if(e_CollectorState == RELEASE){ if(e_CollectorState == RELEASE){
releaseBall(); ReleaseBall();
} }
if(e_CollectorState == STOP){ if(e_CollectorState == STOP){
collectorMotor->Set(0); collectorMotor->Set(0);
} }
} }
void HHCollector::collectBall(){ void HHCollector::CollectBall(){
collectorMotor->Set(1); collectorMotor->Set(1);
} }
void HHCollector::releaseBall(){ void HHCollector::ReleaseBall(){
collectorMotor->Set(255); collectorMotor->Set(255);
} }

View File

@ -4,14 +4,14 @@ class HHCollector{
private: private:
Jaguar *collectorMotor; Jaguar *collectorMotor;
public: public:
HHCollector();
enum{ enum{
COLLECTING, COLLECTING,
RELEASE, RELEASE,
STOP STOP
}e_CollectorState; }e_CollectorState;
HHCollector(); void UpdateCollector(bool, float);
void updateCollector(bool, float); void CollectBall();
void collectBall(); void ReleaseBall();
void releaseBall(); void SpinWithShot(float);
void spinWithShot(float);
}; };

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(){
switch(e_CollectorSolenoidState){ switch(e_CollectorSolenoidState){
case EXTENDED: case EXTENDED:
solenoid1->Set(false); solenoid1->Set(false);
@ -19,15 +19,15 @@ void HHCompressor::compressorSystemPeriodic(){
} }
e_CollectorSolenoidState=IDLE; e_CollectorSolenoidState=IDLE;
} }
void HHCompressor::startCompressing(){ void HHCompressor::StartCompressing(){
compressor->Start(); compressor->Start();
} }
void HHCompressor::stopCompressing(){ void HHCompressor::StopCompressing(){
compressor->Stop(); compressor->Stop();
} }
void HHCompressor::extendCollector(){ void HHCompressor::ExtendCollector(){
e_CollectorSolenoidState=EXTENDED; e_CollectorSolenoidState=EXTENDED;
} }
void HHCompressor::retractCollector(){ void HHCompressor::RetractCollector(){
e_CollectorSolenoidState=RETRACTED; e_CollectorSolenoidState=RETRACTED;
} }

View File

@ -11,9 +11,9 @@ class HHCompressor{
IDLE IDLE
}e_CollectorSolenoidState; }e_CollectorSolenoidState;
HHCompressor(); HHCompressor();
void compressorSystemPeriodic(); void CompressorSystemPeriodic();
void extendCollector(); void ExtendCollector();
void retractCollector(); void RetractCollector();
void startCompressing(); void StartCompressing();
void stopCompressing(); void StopCompressing();
}; };

View File

@ -3,29 +3,29 @@ JoystickController::JoystickController(){
rightJoystick=new Joystick(JOYSTICK_RIGHT); rightJoystick=new Joystick(JOYSTICK_RIGHT);
leftJoystick=new Joystick(JOYSTICK_LEFT); leftJoystick=new Joystick(JOYSTICK_LEFT);
} }
void JoystickController::updateJoysticks(){ void JoystickController::UpdateJoysticks(){
getRightJoystick(); GetRightJoystick();
getLeftJoystick(); GetLeftJoystick();
getRightJoystickAxis(); GetRightJoystickAxis();
getLeftJoystickAxis(); GetLeftJoystickAxis();
throttle=(-leftJoystickAxisValues[4]+1)/2; throttle=(-leftJoystickAxisValues[4]+1)/2;
} }
void JoystickController::getRightJoystick(){ void JoystickController::GetRightJoystick(){
for(int i=1;i<13;i++){ for(int i=1;i<13;i++){
rightJoystickValues[i]=rightJoystick->GetRawButton(i); rightJoystickValues[i]=rightJoystick->GetRawButton(i);
} }
} }
void JoystickController::getLeftJoystick(){ void JoystickController::GetLeftJoystick(){
for(int i=1;i<13;i++){ for(int i=1;i<13;i++){
leftJoystickValues[i]=leftJoystick->GetRawButton(i); leftJoystickValues[i]=leftJoystick->GetRawButton(i);
} }
} }
void JoystickController::getRightJoystickAxis(){ void JoystickController::GetRightJoystickAxis(){
for(int i=1;i<7;i++){ for(int i=1;i<7;i++){
rightJoystickAxisValues[i]=rightJoystick->GetRawAxis(i); rightJoystickAxisValues[i]=rightJoystick->GetRawAxis(i);
} }
} }
void JoystickController::getLeftJoystickAxis(){ void JoystickController::GetLeftJoystickAxis(){
for(int i=1;i<7;i++){ for(int i=1;i<7;i++){
leftJoystickAxisValues[i]=leftJoystick->GetRawAxis(i); leftJoystickAxisValues[i]=leftJoystick->GetRawAxis(i);
} }

View File

@ -11,9 +11,9 @@ class JoystickController
float rightJoystickAxisValues[]; float rightJoystickAxisValues[];
float throttle; float throttle;
JoystickController(); JoystickController();
void updateJoysticks(); void UpdateJoysticks();
void getRightJoystick(); void GetRightJoystick();
void getLeftJoystick(); void GetLeftJoystick();
void getLeftJoystickAxis(); void GetLeftJoystickAxis();
void getRightJoystickAxis(); void GetRightJoystickAxis();
}; };

View File

@ -4,19 +4,19 @@ HHDashboard::HHDashboard(){
SmartDashboard::PutNumber("Shooting Power", 0.0f); SmartDashboard::PutNumber("Shooting Power", 0.0f);
SmartDashboard::PutBoolean("Joysticks Valid", false); SmartDashboard::PutBoolean("Joysticks Valid", false);
} }
float HHDashboard::getFloatValue(const char* key){ float HHDashboard::GetFloatValue(const char* key){
float value=SmartDashboard::GetNumber(key); float value=SmartDashboard::GetNumber(key);
return value; return value;
} }
bool HHDashboard::putFloatValue(const char* key, float value){ bool HHDashboard::PutFloatValue(const char* key, float value){
SmartDashboard::PutNumber(key,value); SmartDashboard::PutNumber(key,value);
return true; return true;
} }
bool HHDashboard::getBoolValue(const char* key){ bool HHDashboard::GetBoolValue(const char* key){
bool value=SmartDashboard::GetBoolean(key); bool value=SmartDashboard::GetBoolean(key);
return value; return value;
} }
bool HHDashboard::putBoolValue(const char* key, bool value){ bool HHDashboard::PutBoolValue(const char* key, bool value){
SmartDashboard::PutBoolean(key,value); SmartDashboard::PutBoolean(key,value);
return true; return true;
} }

View File

@ -6,8 +6,8 @@ class HHDashboard{
HHDashboard(); HHDashboard();
//Array used to track the values in the dashboard //Array used to track the values in the dashboard
bool DashboardValues[]; bool DashboardValues[];
float getFloatValue(const char* key); float GetFloatValue(const char* key);
bool putFloatValue(const char* key, float value); bool PutFloatValue(const char* key, float value);
bool getBoolValue(const char* key); bool GetBoolValue(const char* key);
bool putBoolValue(const char* key, bool value); bool PutBoolValue(const char* key, bool value);
}; };

View File

@ -7,15 +7,15 @@ HHShooter::HHShooter(){
shooterAngle=new AnalogChannel(SHOOTER_ANGLE_POT); shooterAngle=new AnalogChannel(SHOOTER_ANGLE_POT);
e_ShooterState=IDLE_PRESHOT; e_ShooterState=IDLE_PRESHOT;
} }
void HHShooter::startShootingSequence(float throttle){ void HHShooter::StartShootingSequence(float throttle){
//Changes the enum to tell the shooter to be firing //Changes the enum to tell the shooter to be firing
e_ShooterState=FIRING; e_ShooterState=FIRING;
shootingPower=throttle; shootingPower=throttle;
} }
//First step in shooting process //First step in shooting process
void HHShooter::shootForAngle(float power, float desiredAngle){ void HHShooter::ShootForAngle(float power, float desiredAngle){
if(getAngle() <= desiredAngle && power >= 15){ if(GetAngle() <= desiredAngle && power >= 15){
shootRaw(power); ShootRaw(power);
e_ShooterState=FIRING; e_ShooterState=FIRING;
} }
else{ else{
@ -23,50 +23,50 @@ void HHShooter::shootForAngle(float power, float desiredAngle){
} }
} }
//Second step in shooting process //Second step in shooting process
//Probably wont need to be used without shootForAngle //Probably wont need to be used without ShootForAngle
void HHShooter::lower(float desiredAngle){ void HHShooter::Lower(float desiredAngle){
if(getAngle() >= desiredAngle){ if(GetAngle() >= desiredAngle){
shootRaw(-0.1f); ShootRaw(-0.1f);
e_ShooterState=LOWERING; e_ShooterState=LOWERING;
} }
else{ else{
shootRaw(0.0f); ShootRaw(0.0f);
e_ShooterState=IDLE_PRESHOT; e_ShooterState=IDLE_PRESHOT;
} }
} }
//Not needed anywhere other than after/before the shooting process //Not needed anywhere other than after/before the shooting process
void HHShooter::stopShooter(){ void HHShooter::StopShooter(){
if(e_ShooterState == IDLE_PRESHOT){ if(e_ShooterState == IDLE_PRESHOT){
shootRaw(0.0f); ShootRaw(0.0f);
} }
} }
//Shouldn't be used in any other class but this one //Shouldn't be used in any other class but this one
void HHShooter::shootRaw(float power){ void HHShooter::ShootRaw(float power){
shooterLeft1->SetRaw(int(floatToPWM(power))); shooterLeft1->SetRaw(int(FloatToPWM(power)));
shooterLeft2->SetRaw(int(floatToPWM(power))); shooterLeft2->SetRaw(int(FloatToPWM(power)));
shooterRight1->SetRaw(int(floatToPWM(-power))); shooterRight1->SetRaw(int(FloatToPWM(-power)));
shooterRight2->SetRaw(int(floatToPWM(-power))); shooterRight2->SetRaw(int(FloatToPWM(-power)));
} }
//Should be run in a loop //Should be run in a loop
void HHShooter::updateShooterPosition(){ void HHShooter::UpdateShooterPosition(){
if(e_ShooterState == IDLE_PRESHOT){ if(e_ShooterState == IDLE_PRESHOT){
isShooting=false; isShooting=false;
stopShooter(); StopShooter();
} }
if(e_ShooterState == FIRING){ if(e_ShooterState == FIRING){
isShooting=true; isShooting=true;
shootForAngle(shootingPower,110); ShootForAngle(shootingPower,110);
} }
if(e_ShooterState == IDLE_POSTSHOT){ if(e_ShooterState == IDLE_POSTSHOT){
isShooting=false; isShooting=false;
lower(40); Lower(40);
} }
} }
float HHShooter::floatToPWM(float input){ float HHShooter::FloatToPWM(float input){
return input*127.0+128; return input*127.0+128;
} }
//Returns angle measure in degrees //Returns angle measure in degrees
float HHShooter::getAngle(){ float HHShooter::GetAngle(){
float max=-.0003948; float max=-.0003948;
float min=5.0245547; float min=5.0245547;
float b=shooterAngle->GetAverageVoltage()-max; float b=shooterAngle->GetAverageVoltage()-max;

View File

@ -14,12 +14,12 @@ class HHShooter{
}e_ShooterState; }e_ShooterState;
bool isShooting; bool isShooting;
float shootingPower; float shootingPower;
void startShootingSequence(float); void StartShootingSequence(float);
void shootForAngle(float, float); void ShootForAngle(float, float);
void shootRaw(float); void ShootRaw(float);
void lower(float); void Lower(float);
void stopShooter(); void StopShooter();
void updateShooterPosition(); void UpdateShooterPosition();
float floatToPWM(float input); float FloatToPWM(float input);
float getAngle(); float GetAngle();
}; };

View File

@ -9,7 +9,7 @@ HHSonar::HHSonar(){
AnalogChannel backLeftA=new AnalogChannel(SONAR_BACK_LEFT_ANA); AnalogChannel backLeftA=new AnalogChannel(SONAR_BACK_LEFT_ANA);
AnalogChannel backRightA=new AnalogChannel(SONAR_BACK_RIGHT_ANA); AnalogChannel backRightA=new AnalogChannel(SONAR_BACK_RIGHT_ANA);
} }
float HHSonar::getInches(std::string from){ float HHSonar::GetInches(std::string from){
switch(from){ switch(from){
case "FRONT": case "FRONT":
frontLeftD->Set(1); frontLeftD->Set(1);

View File

@ -7,5 +7,5 @@ class HHSonar{
public: public:
HHSonar(); HHSonar();
//from is (in string form) "FRONT", "BACK", "FRONTLEFT", "FRONTRIGHT"... //from is (in string form) "FRONT", "BACK", "FRONTLEFT", "FRONTRIGHT"...
float getInches(std::string from); float GetInches(std::string from);
}; };