mirror of
https://github.com/team2059/Zaphod
synced 2025-01-07 22:14:14 -05:00
Changed function names ToThisCase instead of camelCase
This commit is contained in:
parent
de4a4f448a
commit
e6310554c8
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user