mirror of
https://github.com/team2059/Zaphod
synced 2024-12-18 20:12:28 -05:00
Templated everything. "Zaphod" has been removed from every file and replaced with HH
This commit is contained in:
parent
d6e8a5ec18
commit
56bb724966
@ -1,7 +1,7 @@
|
|||||||
#include "HHBase.h"
|
#include "HHBase.h"
|
||||||
|
|
||||||
HHBase::HHBase():
|
HHBase::HHBase():
|
||||||
hHBot(new ZaphodRobot()){
|
hHBot(new HHRobot()){
|
||||||
printf("Done\n");
|
printf("Done\n");
|
||||||
}
|
}
|
||||||
void HHBase::RobotInit(){
|
void HHBase::RobotInit(){
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
#ifndef __HH_BASE_H__
|
#ifndef __HH_BASE_H__
|
||||||
#define __HH_BASE_H__
|
#define __HH_BASE_H__
|
||||||
#include <WPILib.h>
|
#include <WPILib.h>
|
||||||
#include "ZaphodRobot.h"
|
#include "HHRobot.h"
|
||||||
#include "Subsystems/Controller.h"
|
#include "Subsystems/Controller.h"
|
||||||
#include "Subsystems/Shooter.h"
|
#include "Subsystems/Shooter.h"
|
||||||
#include "Subsystems/Collector.h"
|
#include "Subsystems/Collector.h"
|
||||||
#include "Subsystems/Compressor.h"
|
#include "Subsystems/Compressor.h"
|
||||||
#include "Subsystems/Dashboard.h"
|
#include "Subsystems/Dashboard.h"
|
||||||
//Because this is the first header to be included, classes need to be declared here
|
//Because this is the first header to be included, classes need to be declared here
|
||||||
class ZaphodRobot;
|
class HHRobot;
|
||||||
class HHShooter;
|
class HHShooter;
|
||||||
class HHCollector;
|
class HHCollector;
|
||||||
class HHCompressor;
|
class HHCompressor;
|
||||||
class JoystickController;
|
class JoystickController;
|
||||||
class HHBase : public IterativeRobot{
|
class HHBase : public IterativeRobot{
|
||||||
private:
|
private:
|
||||||
ZaphodRobot* hHBot;
|
HHRobot* hHBot;
|
||||||
public:
|
public:
|
||||||
HHBase();
|
HHBase();
|
||||||
void RobotInit();
|
void RobotInit();
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#include "ZaphodRobot.h"
|
#include "HHRobot.h"
|
||||||
#include "HHBase.h"
|
#include "HHBase.h"
|
||||||
ZaphodRobot::ZaphodRobot():
|
HHRobot::HHRobot():
|
||||||
ControlSystem(new JoystickController()),
|
ControlSystem(new JoystickController()),
|
||||||
shooter(new ZaphodShooter()),
|
shooter(new HHShooter()),
|
||||||
collector(new ZaphodCollector()),
|
collector(new HHCollector()),
|
||||||
compressorSystem(new HHCompressor()),
|
compressorSystem(new HHCompressor()),
|
||||||
dashboard(new ZaphodDashboard()){
|
dashboard(new HHDashboard()){
|
||||||
left1=new Jaguar(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_ONE);
|
left1=new Jaguar(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_ONE);
|
||||||
left2=new Jaguar(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_TWO);
|
left2=new Jaguar(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_TWO);
|
||||||
left3=new Jaguar(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_THREE);
|
left3=new Jaguar(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_THREE);
|
||||||
@ -22,7 +22,7 @@ ZaphodRobot::ZaphodRobot():
|
|||||||
rearSonarRightA=new AnalogChannel(SONAR_REAR_RIGHT_ANA);
|
rearSonarRightA=new AnalogChannel(SONAR_REAR_RIGHT_ANA);
|
||||||
}
|
}
|
||||||
//Functions to get sonar values and return as INCH values
|
//Functions to get sonar values and return as INCH values
|
||||||
float ZaphodRobot::getFrontSonar(){
|
float HHRobot::getFrontSonar(){
|
||||||
frontSonarLeftD->Set(1);
|
frontSonarLeftD->Set(1);
|
||||||
frontSonarLeftV=(frontSonarLeftA->GetAverageVoltage()/0.00488f)/2.54f;
|
frontSonarLeftV=(frontSonarLeftA->GetAverageVoltage()/0.00488f)/2.54f;
|
||||||
frontSonarLeftD->Set(0);
|
frontSonarLeftD->Set(0);
|
||||||
@ -33,7 +33,7 @@ float ZaphodRobot::getFrontSonar(){
|
|||||||
//Returns the average (useful for throwing out useless readings)
|
//Returns the average (useful for throwing out useless readings)
|
||||||
return (frontSonarRightV+frontSonarLeftV)/2;
|
return (frontSonarRightV+frontSonarLeftV)/2;
|
||||||
}
|
}
|
||||||
float ZaphodRobot::getRearSonar(){
|
float HHRobot::getRearSonar(){
|
||||||
rearSonarLeftD->Set(1);
|
rearSonarLeftD->Set(1);
|
||||||
rearSonarLeftV=(rearSonarLeftA->GetAverageVoltage()/0.00488f)/2.54f;
|
rearSonarLeftV=(rearSonarLeftA->GetAverageVoltage()/0.00488f)/2.54f;
|
||||||
rearSonarLeftD->Set(0);
|
rearSonarLeftD->Set(0);
|
||||||
@ -44,7 +44,7 @@ float ZaphodRobot::getRearSonar(){
|
|||||||
//Returns the average (useful for throwing out useless readings)
|
//Returns the average (useful for throwing out useless readings)
|
||||||
return (rearSonarRightV+rearSonarLeftV)/2;
|
return (rearSonarRightV+rearSonarLeftV)/2;
|
||||||
}
|
}
|
||||||
bool ZaphodRobot::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)) {
|
||||||
@ -56,7 +56,7 @@ bool ZaphodRobot::checkJoystickValues(){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ZaphodRobot::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) {
|
||||||
@ -71,11 +71,11 @@ void ZaphodRobot::driveRobot(float x, float y){
|
|||||||
left2->SetRaw(int(leftPower));
|
left2->SetRaw(int(leftPower));
|
||||||
left3->SetRaw(int(leftPower));
|
left3->SetRaw(int(leftPower));
|
||||||
}
|
}
|
||||||
void ZaphodRobot::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 ZaphodRobot::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();
|
@ -4,23 +4,23 @@
|
|||||||
#include "HHBase.h"
|
#include "HHBase.h"
|
||||||
#include "Definitions.h"
|
#include "Definitions.h"
|
||||||
class JoystickController;
|
class JoystickController;
|
||||||
class ZaphodShooter;
|
class HHShooter;
|
||||||
class ZaphodCollector;
|
class HHCollector;
|
||||||
class HHCompressor;
|
class HHCompressor;
|
||||||
class ZaphodDashboard;
|
class HHDashboard;
|
||||||
class ZaphodRobot;
|
class HHRobot;
|
||||||
class ZaphodRobot{
|
class HHRobot{
|
||||||
private:
|
private:
|
||||||
Jaguar *right1, *right2, *right3, *left1, *left2, *left3;
|
Jaguar *right1, *right2, *right3, *left1, *left2, *left3;
|
||||||
DigitalOutput *frontSonarLeftD, *frontSonarRightD, *rearSonarLeftD, *rearSonarRightD;
|
DigitalOutput *frontSonarLeftD, *frontSonarRightD, *rearSonarLeftD, *rearSonarRightD;
|
||||||
AnalogChannel *frontSonarLeftA, *frontSonarRightA, *rearSonarLeftA, *rearSonarRightA;
|
AnalogChannel *frontSonarLeftA, *frontSonarRightA, *rearSonarLeftA, *rearSonarRightA;
|
||||||
JoystickController *ControlSystem;
|
JoystickController *ControlSystem;
|
||||||
ZaphodShooter *shooter;
|
HHShooter *shooter;
|
||||||
ZaphodCollector *collector;
|
HHCollector *collector;
|
||||||
HHCompressor *compressorSystem;
|
HHCompressor *compressorSystem;
|
||||||
ZaphodDashboard *dashboard;
|
HHDashboard *dashboard;
|
||||||
public:
|
public:
|
||||||
ZaphodRobot();
|
HHRobot();
|
||||||
float frontSonarLeftV, frontSonarRightV, rearSonarLeftV, rearSonarRightV;
|
float frontSonarLeftV, frontSonarRightV, rearSonarLeftV, rearSonarRightV;
|
||||||
float getFrontSonar();
|
float getFrontSonar();
|
||||||
float getRearSonar();
|
float getRearSonar();
|
@ -1,8 +1,8 @@
|
|||||||
#include "Collector.h"
|
#include "Collector.h"
|
||||||
ZaphodCollector::ZaphodCollector(){
|
HHCollector::HHCollector(){
|
||||||
collectorMotor = new Jaguar(COLLECTOR_SIDECAR, COLLECTOR_MOTOR);
|
collectorMotor = new Jaguar(COLLECTOR_SIDECAR, COLLECTOR_MOTOR);
|
||||||
}
|
}
|
||||||
void ZaphodCollector::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){
|
||||||
@ -19,9 +19,9 @@ void ZaphodCollector::updateCollector(bool shooting, float angle){
|
|||||||
collectorMotor->Set(0);
|
collectorMotor->Set(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ZaphodCollector::collectBall(){
|
void HHCollector::collectBall(){
|
||||||
collectorMotor->Set(1);
|
collectorMotor->Set(1);
|
||||||
}
|
}
|
||||||
void ZaphodCollector::releaseBall(){
|
void HHCollector::releaseBall(){
|
||||||
collectorMotor->Set(255);
|
collectorMotor->Set(255);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include <WPILib.h>
|
#include <WPILib.h>
|
||||||
#include "../Definitions.h"
|
#include "../Definitions.h"
|
||||||
class ZaphodCollector
|
class HHCollector{
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
Jaguar *collectorMotor;
|
Jaguar *collectorMotor;
|
||||||
public:
|
public:
|
||||||
@ -10,7 +9,7 @@ class ZaphodCollector
|
|||||||
RELEASE,
|
RELEASE,
|
||||||
STOP
|
STOP
|
||||||
}e_CollectorState;
|
}e_CollectorState;
|
||||||
ZaphodCollector();
|
HHCollector();
|
||||||
void updateCollector(bool, float);
|
void updateCollector(bool, float);
|
||||||
void collectBall();
|
void collectBall();
|
||||||
void releaseBall();
|
void releaseBall();
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
#include "Dashboard.h"
|
#include "Dashboard.h"
|
||||||
ZaphodDashboard::ZaphodDashboard(){
|
HHDashboard::HHDashboard(){
|
||||||
//Add Dashboard Initalizations here (for now)
|
//Add Dashboard Initalizations here (for now)
|
||||||
SmartDashboard::PutNumber("Shooting Power", 0.0f);
|
SmartDashboard::PutNumber("Shooting Power", 0.0f);
|
||||||
SmartDashboard::PutBoolean("Joysticks Valid", false);
|
SmartDashboard::PutBoolean("Joysticks Valid", false);
|
||||||
}
|
}
|
||||||
float ZaphodDashboard::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 ZaphodDashboard::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 ZaphodDashboard::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 ZaphodDashboard::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;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include "SmartDashboard/SmartDashboard.h"
|
#include "SmartDashboard/SmartDashboard.h"
|
||||||
#include <WPILib.h>
|
#include <WPILib.h>
|
||||||
#include "../Definitions.h"
|
#include "../Definitions.h"
|
||||||
class ZaphodDashboard{
|
class HHDashboard{
|
||||||
public:
|
public:
|
||||||
ZaphodDashboard();
|
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);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "Shooter.h"
|
#include "Shooter.h"
|
||||||
ZaphodShooter::ZaphodShooter(){
|
HHShooter::HHShooter(){
|
||||||
shooterLeft1=new Jaguar(SHOOTER_LEFT_SIDECAR, SHOOTER_LEFT_MOTOR_ONE);
|
shooterLeft1=new Jaguar(SHOOTER_LEFT_SIDECAR, SHOOTER_LEFT_MOTOR_ONE);
|
||||||
shooterLeft2=new Jaguar(SHOOTER_LEFT_SIDECAR, SHOOTER_LEFT_MOTOR_TWO);
|
shooterLeft2=new Jaguar(SHOOTER_LEFT_SIDECAR, SHOOTER_LEFT_MOTOR_TWO);
|
||||||
shooterRight1=new Jaguar(SHOOTER_RIGHT_SIDECAR, SHOOTER_RIGHT_MOTOR_ONE);
|
shooterRight1=new Jaguar(SHOOTER_RIGHT_SIDECAR, SHOOTER_RIGHT_MOTOR_ONE);
|
||||||
@ -7,13 +7,13 @@ ZaphodShooter::ZaphodShooter(){
|
|||||||
shooterAngle=new AnalogChannel(SHOOTER_ANGLE_POT);
|
shooterAngle=new AnalogChannel(SHOOTER_ANGLE_POT);
|
||||||
e_ShooterState=IDLE_PRESHOT;
|
e_ShooterState=IDLE_PRESHOT;
|
||||||
}
|
}
|
||||||
void ZaphodShooter::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 ZaphodShooter::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;
|
||||||
@ -24,7 +24,7 @@ void ZaphodShooter::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 ZaphodShooter::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;
|
||||||
@ -35,20 +35,20 @@ void ZaphodShooter::lower(float desiredAngle){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Not needed anywhere other than after/before the shooting process
|
//Not needed anywhere other than after/before the shooting process
|
||||||
void ZaphodShooter::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 ZaphodShooter::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 ZaphodShooter::updateShooterPosition(){
|
void HHShooter::updateShooterPosition(){
|
||||||
if(e_ShooterState == IDLE_PRESHOT){
|
if(e_ShooterState == IDLE_PRESHOT){
|
||||||
isShooting=false;
|
isShooting=false;
|
||||||
stopShooter();
|
stopShooter();
|
||||||
@ -62,11 +62,11 @@ void ZaphodShooter::updateShooterPosition(){
|
|||||||
lower(40);
|
lower(40);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float ZaphodShooter::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 ZaphodShooter::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;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#include <WPILib.h>
|
#include <WPILib.h>
|
||||||
#include "../Definitions.h"
|
#include "../Definitions.h"
|
||||||
class ZaphodShooter{
|
class HHShooter{
|
||||||
private:
|
private:
|
||||||
Jaguar*shooterLeft1, *shooterLeft2, *shooterRight1, *shooterRight2;
|
Jaguar*shooterLeft1, *shooterLeft2, *shooterRight1, *shooterRight2;
|
||||||
AnalogChannel*shooterAngle;
|
AnalogChannel*shooterAngle;
|
||||||
public:
|
public:
|
||||||
ZaphodShooter();
|
HHShooter();
|
||||||
enum {
|
enum {
|
||||||
IDLE_PRESHOT,
|
IDLE_PRESHOT,
|
||||||
FIRING,
|
FIRING,
|
||||||
|
Loading…
Reference in New Issue
Block a user