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"
|
||||
|
||||
HHBase::HHBase():
|
||||
hHBot(new ZaphodRobot()){
|
||||
hHBot(new HHRobot()){
|
||||
printf("Done\n");
|
||||
}
|
||||
void HHBase::RobotInit(){
|
||||
|
@ -1,21 +1,21 @@
|
||||
#ifndef __HH_BASE_H__
|
||||
#define __HH_BASE_H__
|
||||
#include <WPILib.h>
|
||||
#include "ZaphodRobot.h"
|
||||
#include "HHRobot.h"
|
||||
#include "Subsystems/Controller.h"
|
||||
#include "Subsystems/Shooter.h"
|
||||
#include "Subsystems/Collector.h"
|
||||
#include "Subsystems/Compressor.h"
|
||||
#include "Subsystems/Dashboard.h"
|
||||
//Because this is the first header to be included, classes need to be declared here
|
||||
class ZaphodRobot;
|
||||
class HHRobot;
|
||||
class HHShooter;
|
||||
class HHCollector;
|
||||
class HHCompressor;
|
||||
class JoystickController;
|
||||
class HHBase : public IterativeRobot{
|
||||
private:
|
||||
ZaphodRobot* hHBot;
|
||||
HHRobot* hHBot;
|
||||
public:
|
||||
HHBase();
|
||||
void RobotInit();
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "ZaphodRobot.h"
|
||||
#include "HHRobot.h"
|
||||
#include "HHBase.h"
|
||||
ZaphodRobot::ZaphodRobot():
|
||||
HHRobot::HHRobot():
|
||||
ControlSystem(new JoystickController()),
|
||||
shooter(new ZaphodShooter()),
|
||||
collector(new ZaphodCollector()),
|
||||
shooter(new HHShooter()),
|
||||
collector(new HHCollector()),
|
||||
compressorSystem(new HHCompressor()),
|
||||
dashboard(new ZaphodDashboard()){
|
||||
dashboard(new HHDashboard()){
|
||||
left1=new Jaguar(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_ONE);
|
||||
left2=new Jaguar(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_TWO);
|
||||
left3=new Jaguar(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_THREE);
|
||||
@ -22,7 +22,7 @@ ZaphodRobot::ZaphodRobot():
|
||||
rearSonarRightA=new AnalogChannel(SONAR_REAR_RIGHT_ANA);
|
||||
}
|
||||
//Functions to get sonar values and return as INCH values
|
||||
float ZaphodRobot::getFrontSonar(){
|
||||
float HHRobot::getFrontSonar(){
|
||||
frontSonarLeftD->Set(1);
|
||||
frontSonarLeftV=(frontSonarLeftA->GetAverageVoltage()/0.00488f)/2.54f;
|
||||
frontSonarLeftD->Set(0);
|
||||
@ -33,7 +33,7 @@ float ZaphodRobot::getFrontSonar(){
|
||||
//Returns the average (useful for throwing out useless readings)
|
||||
return (frontSonarRightV+frontSonarLeftV)/2;
|
||||
}
|
||||
float ZaphodRobot::getRearSonar(){
|
||||
float HHRobot::getRearSonar(){
|
||||
rearSonarLeftD->Set(1);
|
||||
rearSonarLeftV=(rearSonarLeftA->GetAverageVoltage()/0.00488f)/2.54f;
|
||||
rearSonarLeftD->Set(0);
|
||||
@ -44,7 +44,7 @@ float ZaphodRobot::getRearSonar(){
|
||||
//Returns the average (useful for throwing out useless readings)
|
||||
return (rearSonarRightV+rearSonarLeftV)/2;
|
||||
}
|
||||
bool ZaphodRobot::checkJoystickValues(){
|
||||
bool HHRobot::checkJoystickValues(){
|
||||
float x=ControlSystem->rightJoystickAxisValues[1];
|
||||
float y=ControlSystem->rightJoystickAxisValues[2];
|
||||
if((-.1 < x && x < .1) && (-.1 < y && y < .1)) {
|
||||
@ -56,7 +56,7 @@ bool ZaphodRobot::checkJoystickValues(){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void ZaphodRobot::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) {
|
||||
@ -71,11 +71,11 @@ void ZaphodRobot::driveRobot(float x, float y){
|
||||
left2->SetRaw(int(leftPower));
|
||||
left3->SetRaw(int(leftPower));
|
||||
}
|
||||
void ZaphodRobot::updateDashboard(){
|
||||
void HHRobot::updateDashboard(){
|
||||
dashboard->putFloatValue("Shooting Power", ControlSystem->throttle);
|
||||
}
|
||||
//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
|
||||
ControlSystem->updateJoysticks();
|
||||
shooter->updateShooterPosition();
|
@ -4,23 +4,23 @@
|
||||
#include "HHBase.h"
|
||||
#include "Definitions.h"
|
||||
class JoystickController;
|
||||
class ZaphodShooter;
|
||||
class ZaphodCollector;
|
||||
class HHShooter;
|
||||
class HHCollector;
|
||||
class HHCompressor;
|
||||
class ZaphodDashboard;
|
||||
class ZaphodRobot;
|
||||
class ZaphodRobot{
|
||||
class HHDashboard;
|
||||
class HHRobot;
|
||||
class HHRobot{
|
||||
private:
|
||||
Jaguar *right1, *right2, *right3, *left1, *left2, *left3;
|
||||
DigitalOutput *frontSonarLeftD, *frontSonarRightD, *rearSonarLeftD, *rearSonarRightD;
|
||||
AnalogChannel *frontSonarLeftA, *frontSonarRightA, *rearSonarLeftA, *rearSonarRightA;
|
||||
JoystickController *ControlSystem;
|
||||
ZaphodShooter *shooter;
|
||||
ZaphodCollector *collector;
|
||||
HHShooter *shooter;
|
||||
HHCollector *collector;
|
||||
HHCompressor *compressorSystem;
|
||||
ZaphodDashboard *dashboard;
|
||||
HHDashboard *dashboard;
|
||||
public:
|
||||
ZaphodRobot();
|
||||
HHRobot();
|
||||
float frontSonarLeftV, frontSonarRightV, rearSonarLeftV, rearSonarRightV;
|
||||
float getFrontSonar();
|
||||
float getRearSonar();
|
@ -1,8 +1,8 @@
|
||||
#include "Collector.h"
|
||||
ZaphodCollector::ZaphodCollector(){
|
||||
HHCollector::HHCollector(){
|
||||
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
|
||||
if(shooting){
|
||||
if(angle <= 40){
|
||||
@ -19,9 +19,9 @@ void ZaphodCollector::updateCollector(bool shooting, float angle){
|
||||
collectorMotor->Set(0);
|
||||
}
|
||||
}
|
||||
void ZaphodCollector::collectBall(){
|
||||
void HHCollector::collectBall(){
|
||||
collectorMotor->Set(1);
|
||||
}
|
||||
void ZaphodCollector::releaseBall(){
|
||||
void HHCollector::releaseBall(){
|
||||
collectorMotor->Set(255);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <WPILib.h>
|
||||
#include "../Definitions.h"
|
||||
class ZaphodCollector
|
||||
{
|
||||
class HHCollector{
|
||||
private:
|
||||
Jaguar *collectorMotor;
|
||||
public:
|
||||
@ -10,7 +9,7 @@ class ZaphodCollector
|
||||
RELEASE,
|
||||
STOP
|
||||
}e_CollectorState;
|
||||
ZaphodCollector();
|
||||
HHCollector();
|
||||
void updateCollector(bool, float);
|
||||
void collectBall();
|
||||
void releaseBall();
|
||||
|
@ -1,22 +1,22 @@
|
||||
#include "Dashboard.h"
|
||||
ZaphodDashboard::ZaphodDashboard(){
|
||||
HHDashboard::HHDashboard(){
|
||||
//Add Dashboard Initalizations here (for now)
|
||||
SmartDashboard::PutNumber("Shooting Power", 0.0f);
|
||||
SmartDashboard::PutBoolean("Joysticks Valid", false);
|
||||
}
|
||||
float ZaphodDashboard::getFloatValue(const char* key){
|
||||
float HHDashboard::getFloatValue(const char* key){
|
||||
float value=SmartDashboard::GetNumber(key);
|
||||
return value;
|
||||
}
|
||||
bool ZaphodDashboard::putFloatValue(const char* key, float value){
|
||||
bool HHDashboard::putFloatValue(const char* key, float value){
|
||||
SmartDashboard::PutNumber(key,value);
|
||||
return true;
|
||||
}
|
||||
bool ZaphodDashboard::getBoolValue(const char* key){
|
||||
bool HHDashboard::getBoolValue(const char* key){
|
||||
bool value=SmartDashboard::GetBoolean(key);
|
||||
return value;
|
||||
}
|
||||
bool ZaphodDashboard::putBoolValue(const char* key, bool value){
|
||||
bool HHDashboard::putBoolValue(const char* key, bool value){
|
||||
SmartDashboard::PutBoolean(key,value);
|
||||
return true;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "SmartDashboard/SmartDashboard.h"
|
||||
#include <WPILib.h>
|
||||
#include "../Definitions.h"
|
||||
class ZaphodDashboard{
|
||||
class HHDashboard{
|
||||
public:
|
||||
ZaphodDashboard();
|
||||
HHDashboard();
|
||||
//Array used to track the values in the dashboard
|
||||
bool DashboardValues[];
|
||||
float getFloatValue(const char* key);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "Shooter.h"
|
||||
ZaphodShooter::ZaphodShooter(){
|
||||
HHShooter::HHShooter(){
|
||||
shooterLeft1=new Jaguar(SHOOTER_LEFT_SIDECAR, SHOOTER_LEFT_MOTOR_ONE);
|
||||
shooterLeft2=new Jaguar(SHOOTER_LEFT_SIDECAR, SHOOTER_LEFT_MOTOR_TWO);
|
||||
shooterRight1=new Jaguar(SHOOTER_RIGHT_SIDECAR, SHOOTER_RIGHT_MOTOR_ONE);
|
||||
@ -7,13 +7,13 @@ ZaphodShooter::ZaphodShooter(){
|
||||
shooterAngle=new AnalogChannel(SHOOTER_ANGLE_POT);
|
||||
e_ShooterState=IDLE_PRESHOT;
|
||||
}
|
||||
void ZaphodShooter::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 ZaphodShooter::shootForAngle(float power, float desiredAngle){
|
||||
void HHShooter::shootForAngle(float power, float desiredAngle){
|
||||
if(getAngle() <= desiredAngle && power >= 15){
|
||||
shootRaw(power);
|
||||
e_ShooterState=FIRING;
|
||||
@ -24,7 +24,7 @@ void ZaphodShooter::shootForAngle(float power, float desiredAngle){
|
||||
}
|
||||
//Second step in shooting process
|
||||
//Probably wont need to be used without shootForAngle
|
||||
void ZaphodShooter::lower(float desiredAngle){
|
||||
void HHShooter::lower(float desiredAngle){
|
||||
if(getAngle() >= desiredAngle){
|
||||
shootRaw(-0.1f);
|
||||
e_ShooterState=LOWERING;
|
||||
@ -35,20 +35,20 @@ void ZaphodShooter::lower(float desiredAngle){
|
||||
}
|
||||
}
|
||||
//Not needed anywhere other than after/before the shooting process
|
||||
void ZaphodShooter::stopShooter(){
|
||||
void HHShooter::stopShooter(){
|
||||
if(e_ShooterState == IDLE_PRESHOT){
|
||||
shootRaw(0.0f);
|
||||
}
|
||||
}
|
||||
//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)));
|
||||
shooterLeft2->SetRaw(int(floatToPWM(power)));
|
||||
shooterRight1->SetRaw(int(floatToPWM(-power)));
|
||||
shooterRight2->SetRaw(int(floatToPWM(-power)));
|
||||
}
|
||||
//Should be run in a loop
|
||||
void ZaphodShooter::updateShooterPosition(){
|
||||
void HHShooter::updateShooterPosition(){
|
||||
if(e_ShooterState == IDLE_PRESHOT){
|
||||
isShooting=false;
|
||||
stopShooter();
|
||||
@ -62,11 +62,11 @@ void ZaphodShooter::updateShooterPosition(){
|
||||
lower(40);
|
||||
}
|
||||
}
|
||||
float ZaphodShooter::floatToPWM(float input){
|
||||
float HHShooter::floatToPWM(float input){
|
||||
return input*127.0+128;
|
||||
}
|
||||
//Returns angle measure in degrees
|
||||
float ZaphodShooter::getAngle(){
|
||||
float HHShooter::getAngle(){
|
||||
float max=-.0003948;
|
||||
float min=5.0245547;
|
||||
float b=shooterAngle->GetAverageVoltage()-max;
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include <WPILib.h>
|
||||
#include "../Definitions.h"
|
||||
class ZaphodShooter{
|
||||
class HHShooter{
|
||||
private:
|
||||
Jaguar*shooterLeft1, *shooterLeft2, *shooterRight1, *shooterRight2;
|
||||
AnalogChannel*shooterAngle;
|
||||
public:
|
||||
ZaphodShooter();
|
||||
HHShooter();
|
||||
enum {
|
||||
IDLE_PRESHOT,
|
||||
FIRING,
|
||||
|
Loading…
Reference in New Issue
Block a user