mirror of
https://github.com/team2059/Dent
synced 2024-12-18 20:52:29 -05:00
Moved DIOs into individual classes (untested)
This commit is contained in:
parent
b26a63bcc1
commit
113f81a0b0
@ -2,12 +2,10 @@
|
|||||||
#include "Subsystems/Drivetrain.h"
|
#include "Subsystems/Drivetrain.h"
|
||||||
#include "Subsystems/Collector.h"
|
#include "Subsystems/Collector.h"
|
||||||
#include "Subsystems/Elevator.h"
|
#include "Subsystems/Elevator.h"
|
||||||
#include "Subsystems/DIO.h"
|
|
||||||
#include "Subsystems/AirCompressor.h"
|
#include "Subsystems/AirCompressor.h"
|
||||||
Drivetrain* CommandBase::drivetrain = NULL;
|
Drivetrain* CommandBase::drivetrain = NULL;
|
||||||
Collector* CommandBase::collector = NULL;
|
Collector* CommandBase::collector = NULL;
|
||||||
Elevator* CommandBase::elevator = NULL;
|
Elevator* CommandBase::elevator = NULL;
|
||||||
DIO* CommandBase::dio = NULL;
|
|
||||||
AirCompressor* CommandBase::airCompressor = NULL;
|
AirCompressor* CommandBase::airCompressor = NULL;
|
||||||
OI* CommandBase::oi = NULL;
|
OI* CommandBase::oi = NULL;
|
||||||
CommandBase::CommandBase(char const *name) : Command(name) {
|
CommandBase::CommandBase(char const *name) : Command(name) {
|
||||||
@ -18,7 +16,6 @@ void CommandBase::init(){
|
|||||||
drivetrain = new Drivetrain();
|
drivetrain = new Drivetrain();
|
||||||
collector = new Collector();
|
collector = new Collector();
|
||||||
elevator = new Elevator();
|
elevator = new Elevator();
|
||||||
dio = new DIO();
|
|
||||||
airCompressor = new AirCompressor();
|
airCompressor = new AirCompressor();
|
||||||
oi = new OI();
|
oi = new OI();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "Subsystems/Drivetrain.h"
|
#include "Subsystems/Drivetrain.h"
|
||||||
#include "Subsystems/Collector.h"
|
#include "Subsystems/Collector.h"
|
||||||
#include "Subsystems/Elevator.h"
|
#include "Subsystems/Elevator.h"
|
||||||
#include "Subsystems/DIO.h"
|
|
||||||
#include "Subsystems/AirCompressor.h"
|
#include "Subsystems/AirCompressor.h"
|
||||||
#include "OI.h"
|
#include "OI.h"
|
||||||
#include "WPILib.h"
|
#include "WPILib.h"
|
||||||
@ -18,7 +17,6 @@ class CommandBase: public Command {
|
|||||||
static Drivetrain *drivetrain;
|
static Drivetrain *drivetrain;
|
||||||
static Collector *collector;
|
static Collector *collector;
|
||||||
static Elevator *elevator;
|
static Elevator *elevator;
|
||||||
static DIO* dio;
|
|
||||||
static AirCompressor *airCompressor;
|
static AirCompressor *airCompressor;
|
||||||
static OI *oi;
|
static OI *oi;
|
||||||
};
|
};
|
||||||
|
@ -10,7 +10,7 @@ void Calibrate::Execute(){
|
|||||||
DentRobot::elevator->Run(-0.4f);
|
DentRobot::elevator->Run(-0.4f);
|
||||||
}
|
}
|
||||||
bool Calibrate::IsFinished(){
|
bool Calibrate::IsFinished(){
|
||||||
if(DentRobot::dio->Get(DIO::ELEVATORBOTTOM)){
|
if(DentRobot::elevator->GetElevatorBottom()){
|
||||||
DentRobot::elevator->ResetEncoder();
|
DentRobot::elevator->ResetEncoder();
|
||||||
DentRobot::elevator->SetOffset(0.99);
|
DentRobot::elevator->SetOffset(0.99);
|
||||||
return true;
|
return true;
|
||||||
|
@ -10,7 +10,7 @@ void Lower::Execute(){
|
|||||||
DentRobot::elevator->Run((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2);
|
DentRobot::elevator->Run((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2);
|
||||||
}
|
}
|
||||||
bool Lower::IsFinished(){
|
bool Lower::IsFinished(){
|
||||||
if (!DentRobot::dio->Get(DentRobot::dio->ELEVATORBOTTOM) || IsTimedOut()){
|
if (DentRobot::elevator->GetElevatorBottom()||IsTimedOut()){
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
@ -10,7 +10,7 @@ void Raise::Execute(){
|
|||||||
DentRobot::elevator->Run(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2);
|
DentRobot::elevator->Run(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2);
|
||||||
}
|
}
|
||||||
bool Raise::IsFinished(){
|
bool Raise::IsFinished(){
|
||||||
if (!DentRobot::dio->Get(DentRobot::dio->ELEVATORBOTTOM) || IsTimedOut()){
|
if (DentRobot::elevator->GetElevatorTop()||IsTimedOut()){
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
@ -4,7 +4,6 @@ OI* DentRobot::oi=NULL;
|
|||||||
Collector* DentRobot::collector=NULL;
|
Collector* DentRobot::collector=NULL;
|
||||||
Drivetrain* DentRobot::drivetrain=NULL;
|
Drivetrain* DentRobot::drivetrain=NULL;
|
||||||
Elevator* DentRobot::elevator=NULL;
|
Elevator* DentRobot::elevator=NULL;
|
||||||
DIO* DentRobot::dio = NULL;
|
|
||||||
AirCompressor* DentRobot::airCompressor=NULL;
|
AirCompressor* DentRobot::airCompressor=NULL;
|
||||||
CommandGroup* DentRobot::aut=NULL;
|
CommandGroup* DentRobot::aut=NULL;
|
||||||
DentRobot::DentRobot(){
|
DentRobot::DentRobot(){
|
||||||
@ -12,7 +11,6 @@ DentRobot::DentRobot(){
|
|||||||
collector=new Collector();
|
collector=new Collector();
|
||||||
drivetrain=new Drivetrain();
|
drivetrain=new Drivetrain();
|
||||||
elevator=new Elevator();
|
elevator=new Elevator();
|
||||||
dio = new DIO();
|
|
||||||
airCompressor=new AirCompressor();
|
airCompressor=new AirCompressor();
|
||||||
aut=new Autonomous();
|
aut=new Autonomous();
|
||||||
printf("Initialized");
|
printf("Initialized");
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "WPILib.h"
|
#include "WPILib.h"
|
||||||
#include "OI.h"
|
#include "OI.h"
|
||||||
#include "Subsystems/Elevator.h"
|
#include "Subsystems/Elevator.h"
|
||||||
#include "Subsystems/DIO.h"
|
|
||||||
#include "Subsystems/Drivetrain.h"
|
#include "Subsystems/Drivetrain.h"
|
||||||
#include "Subsystems/Collector.h"
|
#include "Subsystems/Collector.h"
|
||||||
#include "Subsystems/AirCompressor.h"
|
#include "Subsystems/AirCompressor.h"
|
||||||
@ -17,7 +16,6 @@ class DentRobot: public IterativeRobot {
|
|||||||
static Collector* collector;
|
static Collector* collector;
|
||||||
static Drivetrain* drivetrain;
|
static Drivetrain* drivetrain;
|
||||||
static Elevator* elevator;
|
static Elevator* elevator;
|
||||||
static DIO* dio;
|
|
||||||
static AirCompressor* airCompressor;
|
static AirCompressor* airCompressor;
|
||||||
static CommandGroup* aut;
|
static CommandGroup* aut;
|
||||||
void RobotInit();
|
void RobotInit();
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
// Elevator
|
// Elevator
|
||||||
#define ELEVATOR_CAN 1
|
#define ELEVATOR_CAN 1
|
||||||
|
#define ELEVATOR_BOTTOM_DIO 0
|
||||||
|
#define ELEVATOR_TOP_DIO 1
|
||||||
|
|
||||||
// Drivetrain
|
// Drivetrain
|
||||||
#define DRIVE_FRONT_LEFT_CAN 2
|
#define DRIVE_FRONT_LEFT_CAN 2
|
||||||
@ -17,7 +19,6 @@
|
|||||||
#define COLLECTOR_WINDOW_RIGHT_CAN 7
|
#define COLLECTOR_WINDOW_RIGHT_CAN 7
|
||||||
#define COLLECTOR_LEFT_CAN 8
|
#define COLLECTOR_LEFT_CAN 8
|
||||||
#define COLLECTOR_RIGHT_CAN 9
|
#define COLLECTOR_RIGHT_CAN 9
|
||||||
#define COLLECTOR_CALIBRATOR_DIO 0
|
|
||||||
|
|
||||||
// Compressor
|
// Compressor
|
||||||
#define COMPRESSOR_CAN 10
|
#define COMPRESSOR_CAN 10
|
||||||
|
@ -6,7 +6,6 @@ Collector::Collector() : Subsystem("Collector") {
|
|||||||
windowMotorRight=new CANTalon(COLLECTOR_WINDOW_RIGHT_CAN);
|
windowMotorRight=new CANTalon(COLLECTOR_WINDOW_RIGHT_CAN);
|
||||||
collectorMotorLeft=new CANTalon(COLLECTOR_LEFT_CAN);
|
collectorMotorLeft=new CANTalon(COLLECTOR_LEFT_CAN);
|
||||||
collectorMotorRight=new CANTalon(COLLECTOR_RIGHT_CAN);
|
collectorMotorRight=new CANTalon(COLLECTOR_RIGHT_CAN);
|
||||||
boxSwitch=new DigitalInput(COLLECTOR_CALIBRATOR_DIO);
|
|
||||||
}
|
}
|
||||||
void Collector::InitDefaultCommand() {
|
void Collector::InitDefaultCommand() {
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ class Collector: public Subsystem
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorRight;
|
CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorRight;
|
||||||
DigitalInput *boxSwitch;
|
|
||||||
public:
|
public:
|
||||||
Collector();
|
Collector();
|
||||||
void InitDefaultCommand();
|
void InitDefaultCommand();
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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
|
|
@ -5,6 +5,8 @@ Elevator::Elevator()/* : PIDSubsystem("Elevator", kP_real, kI_real, 0.0)*/{
|
|||||||
elevatorEncoder=new Encoder(0,1,false);
|
elevatorEncoder=new Encoder(0,1,false);
|
||||||
offset=0;
|
offset=0;
|
||||||
height=0;
|
height=0;
|
||||||
|
elevatorBottom=new DigitalInput(ELEVATOR_BOTTOM_DIO);
|
||||||
|
elevatorTop=new DigitalInput(ELEVATOR_TOP_DIO);
|
||||||
//SetAbsoluteTolerance(0.004);
|
//SetAbsoluteTolerance(0.004);
|
||||||
}
|
}
|
||||||
void Elevator::InitDefaultCommand(){
|
void Elevator::InitDefaultCommand(){
|
||||||
@ -22,3 +24,9 @@ void Elevator::ResetEncoder(){
|
|||||||
double Elevator::GetHeight(){
|
double Elevator::GetHeight(){
|
||||||
return elevatorEncoder->Get()+offset;
|
return elevatorEncoder->Get()+offset;
|
||||||
}
|
}
|
||||||
|
bool Elevator::GetElevatorBottom(){
|
||||||
|
return elevatorBottom->Get();
|
||||||
|
}
|
||||||
|
bool Elevator::GetElevatorTop(){
|
||||||
|
return elevatorTop->Get();
|
||||||
|
}
|
||||||
|
@ -9,6 +9,7 @@ class Elevator/*: public PIDSubsystem*/{
|
|||||||
Encoder *elevatorEncoder;
|
Encoder *elevatorEncoder;
|
||||||
static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2;
|
static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2;
|
||||||
double offset, height;
|
double offset, height;
|
||||||
|
DigitalInput *elevatorBottom, *elevatorTop;
|
||||||
public:
|
public:
|
||||||
Elevator();
|
Elevator();
|
||||||
void InitDefaultCommand();
|
void InitDefaultCommand();
|
||||||
@ -16,5 +17,7 @@ class Elevator/*: public PIDSubsystem*/{
|
|||||||
void SetOffset(double);
|
void SetOffset(double);
|
||||||
void ResetEncoder();
|
void ResetEncoder();
|
||||||
double GetHeight();
|
double GetHeight();
|
||||||
|
bool GetElevatorTop();
|
||||||
|
bool GetElevatorBottom();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user