diff --git a/CommandBase.cpp b/CommandBase.cpp index c68ce0e..dfd3a78 100644 --- a/CommandBase.cpp +++ b/CommandBase.cpp @@ -2,12 +2,10 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" -#include "Subsystems/DIO.h" #include "Subsystems/AirCompressor.h" Drivetrain* CommandBase::drivetrain = NULL; Collector* CommandBase::collector = NULL; Elevator* CommandBase::elevator = NULL; -DIO* CommandBase::dio = NULL; AirCompressor* CommandBase::airCompressor = NULL; OI* CommandBase::oi = NULL; CommandBase::CommandBase(char const *name) : Command(name) { @@ -18,7 +16,6 @@ void CommandBase::init(){ drivetrain = new Drivetrain(); collector = new Collector(); elevator = new Elevator(); - dio = new DIO(); airCompressor = new AirCompressor(); oi = new OI(); } diff --git a/CommandBase.h b/CommandBase.h index 18f90d0..e6891d1 100644 --- a/CommandBase.h +++ b/CommandBase.h @@ -5,7 +5,6 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" -#include "Subsystems/DIO.h" #include "Subsystems/AirCompressor.h" #include "OI.h" #include "WPILib.h" @@ -18,7 +17,6 @@ class CommandBase: public Command { static Drivetrain *drivetrain; static Collector *collector; static Elevator *elevator; - static DIO* dio; static AirCompressor *airCompressor; static OI *oi; }; diff --git a/Commands/Elevator/Calibrate.cpp b/Commands/Elevator/Calibrate.cpp index 2132127..55ff8b0 100644 --- a/Commands/Elevator/Calibrate.cpp +++ b/Commands/Elevator/Calibrate.cpp @@ -10,7 +10,7 @@ void Calibrate::Execute(){ DentRobot::elevator->Run(-0.4f); } bool Calibrate::IsFinished(){ - if(DentRobot::dio->Get(DIO::ELEVATORBOTTOM)){ + if(DentRobot::elevator->GetElevatorBottom()){ DentRobot::elevator->ResetEncoder(); DentRobot::elevator->SetOffset(0.99); return true; diff --git a/Commands/Elevator/Lower.cpp b/Commands/Elevator/Lower.cpp index 1e4e658..03cf6eb 100644 --- a/Commands/Elevator/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -10,7 +10,7 @@ void Lower::Execute(){ DentRobot::elevator->Run((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool Lower::IsFinished(){ - if (!DentRobot::dio->Get(DentRobot::dio->ELEVATORBOTTOM) || IsTimedOut()){ + if (DentRobot::elevator->GetElevatorBottom()||IsTimedOut()){ return true; }else{ return false; diff --git a/Commands/Elevator/Raise.cpp b/Commands/Elevator/Raise.cpp index 385ec52..1bbccba 100644 --- a/Commands/Elevator/Raise.cpp +++ b/Commands/Elevator/Raise.cpp @@ -10,7 +10,7 @@ void Raise::Execute(){ DentRobot::elevator->Run(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool Raise::IsFinished(){ - if (!DentRobot::dio->Get(DentRobot::dio->ELEVATORBOTTOM) || IsTimedOut()){ + if (DentRobot::elevator->GetElevatorTop()||IsTimedOut()){ return true; }else{ return false; diff --git a/DentRobot.cpp b/DentRobot.cpp index 26365f7..96b8fd2 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -4,7 +4,6 @@ OI* DentRobot::oi=NULL; Collector* DentRobot::collector=NULL; Drivetrain* DentRobot::drivetrain=NULL; Elevator* DentRobot::elevator=NULL; -DIO* DentRobot::dio = NULL; AirCompressor* DentRobot::airCompressor=NULL; CommandGroup* DentRobot::aut=NULL; DentRobot::DentRobot(){ @@ -12,7 +11,6 @@ DentRobot::DentRobot(){ collector=new Collector(); drivetrain=new Drivetrain(); elevator=new Elevator(); - dio = new DIO(); airCompressor=new AirCompressor(); aut=new Autonomous(); printf("Initialized"); diff --git a/DentRobot.h b/DentRobot.h index 1f72a33..9e30708 100644 --- a/DentRobot.h +++ b/DentRobot.h @@ -3,7 +3,6 @@ #include "WPILib.h" #include "OI.h" #include "Subsystems/Elevator.h" -#include "Subsystems/DIO.h" #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/AirCompressor.h" @@ -17,7 +16,6 @@ class DentRobot: public IterativeRobot { static Collector* collector; static Drivetrain* drivetrain; static Elevator* elevator; - static DIO* dio; static AirCompressor* airCompressor; static CommandGroup* aut; void RobotInit(); diff --git a/RobotMap.h b/RobotMap.h index 90b38e1..1bf5363 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -5,6 +5,8 @@ // Elevator #define ELEVATOR_CAN 1 +#define ELEVATOR_BOTTOM_DIO 0 +#define ELEVATOR_TOP_DIO 1 // Drivetrain #define DRIVE_FRONT_LEFT_CAN 2 @@ -17,7 +19,6 @@ #define COLLECTOR_WINDOW_RIGHT_CAN 7 #define COLLECTOR_LEFT_CAN 8 #define COLLECTOR_RIGHT_CAN 9 -#define COLLECTOR_CALIBRATOR_DIO 0 // Compressor #define COMPRESSOR_CAN 10 diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index a1fdee7..e039511 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -6,7 +6,6 @@ Collector::Collector() : Subsystem("Collector") { windowMotorRight=new CANTalon(COLLECTOR_WINDOW_RIGHT_CAN); collectorMotorLeft=new CANTalon(COLLECTOR_LEFT_CAN); collectorMotorRight=new CANTalon(COLLECTOR_RIGHT_CAN); - boxSwitch=new DigitalInput(COLLECTOR_CALIBRATOR_DIO); } void Collector::InitDefaultCommand() { } diff --git a/Subsystems/Collector.h b/Subsystems/Collector.h index 931744f..cf6b23c 100644 --- a/Subsystems/Collector.h +++ b/Subsystems/Collector.h @@ -6,7 +6,6 @@ class Collector: public Subsystem { private: CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorRight; - DigitalInput *boxSwitch; public: Collector(); void InitDefaultCommand(); diff --git a/Subsystems/DIO.cpp b/Subsystems/DIO.cpp deleted file mode 100644 index 470bf3a..0000000 --- a/Subsystems/DIO.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "DIO.h" -#include "../RobotMap.h" -DIO::DIO(){ - elevatorTop=new DigitalInput(0); - elevatorBottom=new DigitalInput(1); -} -void DIO::InitDefaultCommand(){ -} -bool DIO::Get(e_dioSig dioSig){ - switch (dioSig){ - case ELEVATORTOP: - return elevatorTop->Get(); - break; - case ELEVATORBOTTOM: - return elevatorBottom->Get(); - break; - default: - return false; - break; - } -} diff --git a/Subsystems/DIO.h b/Subsystems/DIO.h deleted file mode 100644 index 8862850..0000000 --- a/Subsystems/DIO.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef DIO_H -#define DIO_H - -#include "WPILib.h" -class DIO{ - private: - DigitalInput *elevatorTop, *elevatorBottom; - public: - DIO(); - enum e_dioSig{ - ELEVATORTOP, - ELEVATORBOTTOM - }; - void InitDefaultCommand(); - bool Get(e_dioSig); -}; -#endif diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index 2df51dc..1e18c3e 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -5,6 +5,8 @@ Elevator::Elevator()/* : PIDSubsystem("Elevator", kP_real, kI_real, 0.0)*/{ elevatorEncoder=new Encoder(0,1,false); offset=0; height=0; + elevatorBottom=new DigitalInput(ELEVATOR_BOTTOM_DIO); + elevatorTop=new DigitalInput(ELEVATOR_TOP_DIO); //SetAbsoluteTolerance(0.004); } void Elevator::InitDefaultCommand(){ @@ -22,3 +24,9 @@ void Elevator::ResetEncoder(){ double Elevator::GetHeight(){ return elevatorEncoder->Get()+offset; } +bool Elevator::GetElevatorBottom(){ + return elevatorBottom->Get(); +} +bool Elevator::GetElevatorTop(){ + return elevatorTop->Get(); +} diff --git a/Subsystems/Elevator.h b/Subsystems/Elevator.h index 26902d8..072f8e3 100644 --- a/Subsystems/Elevator.h +++ b/Subsystems/Elevator.h @@ -9,6 +9,7 @@ class Elevator/*: public PIDSubsystem*/{ Encoder *elevatorEncoder; static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2; double offset, height; + DigitalInput *elevatorBottom, *elevatorTop; public: Elevator(); void InitDefaultCommand(); @@ -16,5 +17,7 @@ class Elevator/*: public PIDSubsystem*/{ void SetOffset(double); void ResetEncoder(); double GetHeight(); + bool GetElevatorTop(); + bool GetElevatorBottom(); }; #endif