diff --git a/Shooter.cpp b/Shooter.cpp index e1e702b..6690b83 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* 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; + pnum_7Wheel = pnum7Wheel; + solenoid_7Wheel = solenoid7Wheel; 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,47 @@ void Shooter::clampUp() clamp = up; } -void Shooter::wormPull() +void Shooter::auto7Wheel() { - if(wormDone()) - { - return; + /*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); + }*/ + if(sevenWheel == up) + { + sevenWheelDown(); } - if(!wormIsPulling) + else { - robot -> pnum -> setVectorValues(PUNCH_TIME, puncher, DoubleSolenoid::kForward); + sevenWheelUp(); } - wormIsPulling = true; +} +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() @@ -218,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) { diff --git a/Shooter.h b/Shooter.h index 8627971..a1f50c4 100644 --- a/Shooter.h +++ b/Shooter.h @@ -23,10 +23,19 @@ 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, 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 auto7Wheel(); + void sevenWheelUp(); + void sevenWheelDown(); void pitchUp(); void pitchDown(); void pitchStop(); @@ -63,6 +72,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..d9ecfb8 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..03b7638 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