From b2a841ab39c3ea6d8a96631b84a06034aed7b31b Mon Sep 17 00:00:00 2001 From: ChampD Date: Wed, 3 Dec 2014 17:21:47 -0500 Subject: [PATCH 1/2] So this code is Jank as heck --- Shooter.cpp | 40 +++++++++++++++++++++++++++++----------- Shooter.h | 8 +++++++- main.cpp | 5 ++++- main.h | 4 ++++ ports.h | 7 ++++++- 5 files changed, 50 insertions(+), 14 deletions(-) diff --git a/Shooter.cpp b/Shooter.cpp index e1e702b..c0c3355 100644 --- a/Shooter.cpp +++ b/Shooter.cpp @@ -16,13 +16,16 @@ Shooter::Shooter(main_robot* r,uint8_t axisCan, uint8_t clampMod, uint32_t clampFChan, uint32_t clampRChan, uint8_t wormCan, uint8_t punchMod,uint32_t punchFChan,uint32_t punchRChan, - uint8_t bobMod) + uint8_t bobMod, + Pneumatics* pnum_7Wheel, DoubleSolenoid* solenoid_7Wheel) :isPickingUp(false),isPitchingUp(false), isPitchingDown(false),wormIsPulling(false),winching(false), hasTilted(false),isPickingUpStopping(false),autoPulling(false), smartFiring(false),accelWorking(true),smartFireTimer(new Timer()) { robot = r; + this.pnum_7Wheel = pnum_7Wheel; + this.solenoid_7Wheel = solenoid_7Wheel; axis = new CANJaguar(axisCan); attractor = new Talon(attractMod, attractChan); clamper = new DoubleSolenoid(clampMod, clampFChan, clampRChan); @@ -31,6 +34,8 @@ Shooter::Shooter(main_robot* r,uint8_t axisCan, bobTheAccelerometer = new ADXL345_I2C_612(bobMod); // bobThePot = new AnalogChannel(1,5); isPickingUp = false; + 7WheelExtend = false; + 7WheelOldState = false; shooterJoy = robot -> gunnerJoy; shooterJoy -> addJoyFunctions(&buttonHelper,(void*)this,CLAMP); shooterJoy -> addJoyFunctions(&buttonHelper,(void*)this,ENERGIZE); @@ -45,6 +50,7 @@ Shooter::Shooter(main_robot* r,uint8_t axisCan, Shooter::~Shooter() { delete axis; + delete pnum_7Wheel; delete attractor; delete clamper; delete bobTheAccelerometer; @@ -153,17 +159,28 @@ void Shooter::clampUp() clamp = up; } -void Shooter::wormPull() +void Shooter::7WheelUpdate() { - if(wormDone()) - { - return; - } - if(!wormIsPulling) - { - robot -> pnum -> setVectorValues(PUNCH_TIME, puncher, DoubleSolenoid::kForward); - } - wormIsPulling = true; + if(!(ShooterJoy -> GetSmoothButton(CLAMP)) + { + 7WheelOldState = false; + } + else + { + if(!7WheelOldState) + { + 7WheelOldState = true; + 7WheelExtend = !7WheelExtend; + } + } + if(7WheelExtend) + { + pnum_7Wheel->setVectorValues(TIME, solenoid_7Wheel, DoubleSolenoid::kForward); + } + else + { + pnum_7Wheel->setVectorValues(TIME, solenoid_7Wheel, DoubleSolenoid::kReverse); + } } void Shooter::wormStop() @@ -381,6 +398,7 @@ void Shooter::update() if (wormDone()) //checks if loader has reached farthest position wormStop(); } + 7WheelUpdate(); } void Shooter::updateHelper(void* instName) diff --git a/Shooter.h b/Shooter.h index 8627971..dca9ca3 100644 --- a/Shooter.h +++ b/Shooter.h @@ -23,10 +23,14 @@ class Shooter uint8_t clampMod, uint32_t clampFChan, uint32_t clampRChan, uint8_t wormCan, uint8_t punchMod,uint32_t punchFChan,uint32_t punchRChan, - uint8_t bobMod); + uint8_t bobMod, + Pneumatics* pnum_7Wheel); ~Shooter(); enum Clamp {down, up}; Clamp clamp; + Pneumatics* pnum_7Wheel; + DoubleSolenoid* solenoid_7Wheel; + void 7WheelUpdate(); void pitchUp(); void pitchDown(); void pitchStop(); @@ -63,6 +67,8 @@ class Shooter bool isPitchingUp; bool isPitchingDown; bool wormIsPulling; + bool 7WheelExtend; + bool 7WheelOldState; bool winching; bool hasTilted; bool isPickingUpStopping; diff --git a/main.cpp b/main.cpp index 12f1014..cd935fe 100755 --- a/main.cpp +++ b/main.cpp @@ -25,6 +25,8 @@ void main_robot::RobotInit() driverJoy = new SmoothJoystick(this, DRIVER_JOY_PORT); gunnerJoy = new SmoothJoystick(this, GUNNER_JOY_PORT); pnum = new Pneumatics(this, PNUM_DIGIN_MODULE, PNUM_DIGIN_CHANNEL, PNUM_RELAY_MODULE, PNUM_RELAY_CHANNEL); + pnum_7wheel = new Pneumatics(this, PNUM_7WHEEL_MODULE, PNUM_7WHEEL_CHANNEL, PNUM_7WHEEL_MODULE, PNUM_7WHEEL_CHANNEL); + solenoid_7Wheel = new DoubleSolenoid(SHOOT_7WHEEL_MODULE, SHOOT_7WHEEL_FCHAN, SHOOT_7WHEEL_RCHAN); shift = new Shifter(this, SHIFT_MOD, SHIFT_FCHAN, SHIFT_RCHAN); shift->setHigh(); drive = new DriveTrain(this, TALON_FL_MODULE, TALON_FL_CHANNEL, @@ -36,7 +38,8 @@ void main_robot::RobotInit() SHOOT_SLNOID_MODULE, SHOOT_SLNOID_FCHAN, SHOOT_SLNOID_RCHAN, WORM_JAG_CAN, PUNCH_SLNOID_MODULE, PUNCH_SLNOID_FCHAN, PUNCH_SLNOID_RCHAN, - SHOOT_ACCEL_MODULE); + SHOOT_ACCEL_MODULE, + pnum_7Wheel, solenoid_7Wheel); sensors = new Sensors(this, USMODNUMBER, USCHANNEL, ISMODNUMBER, ISCHANNEL, ILMODNUMBER, ILCHANNEL, GYMOD, GYCHAN); sensors->setGyroSens(1.0f); //default sensitivity printf("Welcome to 612-2014 AERIAL ASSIST\n"); diff --git a/main.h b/main.h index 8e8c02f..f46db1c 100755 --- a/main.h +++ b/main.h @@ -35,7 +35,11 @@ class main_robot: public IterativeRobot void TestPeriodic(); SmoothJoystick* driverJoy; SmoothJoystick* gunnerJoy; + Pneumatics* pnum; + Pneumatics* pnum_7wheel; + DoubleSolenoid* solenoid_7Wheel; + Shifter* shift; DriveTrain* drive; Shooter* shoot; diff --git a/ports.h b/ports.h index 7c80452..e786801 100755 --- a/ports.h +++ b/ports.h @@ -15,10 +15,11 @@ const static uint8_t TALON_RR_MODULE = 1; // Pneumatics Channels const static uint32_t PNUM_DIGIN_CHANNEL = 8; const static uint32_t PNUM_RELAY_CHANNEL = 8; +const static uint32_t PNUM_7WHEEL_CHANNEL= 10; // Pneumatics Modules const static uint8_t PNUM_DIGIN_MODULE = 1; const static uint8_t PNUM_RELAY_MODULE = 1; - +const static uint8_t PNUM_7WHEEL_MODULE = 1; // Shifter const static uint32_t SHIFT_FCHAN = 7; const static uint32_t SHIFT_RCHAN = 8; @@ -34,6 +35,10 @@ const static uint8_t SHOOT_SLNOID_MODULE = 1; // clamp const static uint32_t SHOOT_SLNOID_FCHAN = 5; const static uint32_t SHOOT_SLNOID_RCHAN = 6; +const static uint8_t SHOOT_7WHEEL_MODULE = 1; // 7th wheel +const static uint32_t SHOOT_7WHEEL_FCHAN = 8; +const static uint32_t SHOOT_7WHEEL_RCHAN = 9; + const static uint32_t WORM_JAG_CAN = 2; // worm drive const static uint8_t PUNCH_SLNOID_MODULE = 1; // dog clutch piston From d2ade51522ad59b1f7dcdde8418efe151b8c8faf Mon Sep 17 00:00:00 2001 From: ChampD Date: Wed, 10 Dec 2014 15:07:34 -0500 Subject: [PATCH 2/2] HAHA IT'S ALIVE --- Shooter.cpp | 38 +++++++++++++++++++++++++++++--------- Shooter.h | 13 +++++++++---- main.cpp | 2 +- main.h | 2 +- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/Shooter.cpp b/Shooter.cpp index c0c3355..6690b83 100644 --- a/Shooter.cpp +++ b/Shooter.cpp @@ -17,15 +17,15 @@ Shooter::Shooter(main_robot* r,uint8_t axisCan, uint8_t wormCan, uint8_t punchMod,uint32_t punchFChan,uint32_t punchRChan, uint8_t bobMod, - Pneumatics* pnum_7Wheel, DoubleSolenoid* solenoid_7Wheel) + Pneumatics* pnum7Wheel, DoubleSolenoid* solenoid7Wheel) :isPickingUp(false),isPitchingUp(false), isPitchingDown(false),wormIsPulling(false),winching(false), hasTilted(false),isPickingUpStopping(false),autoPulling(false), smartFiring(false),accelWorking(true),smartFireTimer(new Timer()) { robot = r; - this.pnum_7Wheel = pnum_7Wheel; - this.solenoid_7Wheel = solenoid_7Wheel; + pnum_7Wheel = pnum7Wheel; + solenoid_7Wheel = solenoid7Wheel; axis = new CANJaguar(axisCan); attractor = new Talon(attractMod, attractChan); clamper = new DoubleSolenoid(clampMod, clampFChan, clampRChan); @@ -34,8 +34,8 @@ Shooter::Shooter(main_robot* r,uint8_t axisCan, bobTheAccelerometer = new ADXL345_I2C_612(bobMod); // bobThePot = new AnalogChannel(1,5); isPickingUp = false; - 7WheelExtend = false; - 7WheelOldState = false; + //7WheelExtend = false; + //7WheelOldState = false; shooterJoy = robot -> gunnerJoy; shooterJoy -> addJoyFunctions(&buttonHelper,(void*)this,CLAMP); shooterJoy -> addJoyFunctions(&buttonHelper,(void*)this,ENERGIZE); @@ -159,9 +159,9 @@ void Shooter::clampUp() clamp = up; } -void Shooter::7WheelUpdate() +void Shooter::auto7Wheel() { - if(!(ShooterJoy -> GetSmoothButton(CLAMP)) + /*if(!(ShooterJoy -> GetSmoothButton(CLAMP)) { 7WheelOldState = false; } @@ -180,7 +180,26 @@ void Shooter::7WheelUpdate() else { pnum_7Wheel->setVectorValues(TIME, solenoid_7Wheel, DoubleSolenoid::kReverse); - } + }*/ + if(sevenWheel == up) + { + sevenWheelDown(); + } + else + { + sevenWheelUp(); + } +} +void Shooter::sevenWheelDown() +{ + robot -> pnum->setVectorValues(TIME, solenoid_7Wheel, DoubleSolenoid::kForward); + sevenWheel = down; +} + +void Shooter::sevenWheelUp() +{ + robot -> pnum->setVectorValues(TIME, solenoid_7Wheel, DoubleSolenoid::kReverse); + sevenWheel = up; } void Shooter::wormStop() @@ -235,6 +254,8 @@ void Shooter::buttonHelper(void* objPtr, uint32_t button) if(button==CLAMP) { shooterObj->autoClamp(); + shooterObj->auto7Wheel();//Not actually sure what button this should go on. Feel free to move this method + // if you arent happy. I dont think the clamp actually does anthing, however, so it should be fine. } if(button==ENERGIZE) { @@ -398,7 +419,6 @@ void Shooter::update() if (wormDone()) //checks if loader has reached farthest position wormStop(); } - 7WheelUpdate(); } void Shooter::updateHelper(void* instName) diff --git a/Shooter.h b/Shooter.h index dca9ca3..a1f50c4 100644 --- a/Shooter.h +++ b/Shooter.h @@ -24,13 +24,18 @@ class Shooter uint8_t wormCan, uint8_t punchMod,uint32_t punchFChan,uint32_t punchRChan, uint8_t bobMod, - Pneumatics* pnum_7Wheel); + Pneumatics* pnum_7Wheel, DoubleSolenoid* solenoid_7Wheel); ~Shooter(); enum Clamp {down, up}; Clamp clamp; + Clamp sevenWheel; + //enum SevenWheel {down, up}; + //SevenWheel sevenWheel; Pneumatics* pnum_7Wheel; DoubleSolenoid* solenoid_7Wheel; - void 7WheelUpdate(); + void auto7Wheel(); + void sevenWheelUp(); + void sevenWheelDown(); void pitchUp(); void pitchDown(); void pitchStop(); @@ -67,8 +72,8 @@ class Shooter bool isPitchingUp; bool isPitchingDown; bool wormIsPulling; - bool 7WheelExtend; - bool 7WheelOldState; + //bool 7WheelExtend; + //bool 7WheelOldState; bool winching; bool hasTilted; bool isPickingUpStopping; diff --git a/main.cpp b/main.cpp index cd935fe..d9ecfb8 100755 --- a/main.cpp +++ b/main.cpp @@ -25,7 +25,7 @@ void main_robot::RobotInit() driverJoy = new SmoothJoystick(this, DRIVER_JOY_PORT); gunnerJoy = new SmoothJoystick(this, GUNNER_JOY_PORT); pnum = new Pneumatics(this, PNUM_DIGIN_MODULE, PNUM_DIGIN_CHANNEL, PNUM_RELAY_MODULE, PNUM_RELAY_CHANNEL); - pnum_7wheel = new Pneumatics(this, PNUM_7WHEEL_MODULE, PNUM_7WHEEL_CHANNEL, PNUM_7WHEEL_MODULE, PNUM_7WHEEL_CHANNEL); + pnum_7Wheel = new Pneumatics(this, PNUM_7WHEEL_MODULE, PNUM_7WHEEL_CHANNEL, PNUM_7WHEEL_MODULE, PNUM_7WHEEL_CHANNEL); solenoid_7Wheel = new DoubleSolenoid(SHOOT_7WHEEL_MODULE, SHOOT_7WHEEL_FCHAN, SHOOT_7WHEEL_RCHAN); shift = new Shifter(this, SHIFT_MOD, SHIFT_FCHAN, SHIFT_RCHAN); shift->setHigh(); diff --git a/main.h b/main.h index f46db1c..03b7638 100755 --- a/main.h +++ b/main.h @@ -37,7 +37,7 @@ class main_robot: public IterativeRobot SmoothJoystick* gunnerJoy; Pneumatics* pnum; - Pneumatics* pnum_7wheel; + Pneumatics* pnum_7Wheel; DoubleSolenoid* solenoid_7Wheel; Shifter* shift;