numerous drive changes because of reasons, plus the starts of a counter object that will probably have to be nixed. Not our brightest moment.

This commit is contained in:
Aidan Ferguson 2016-02-10 13:39:48 -05:00
parent fc1e9f3803
commit 2e196a8fab
2 changed files with 41 additions and 5 deletions

View File

@ -19,16 +19,18 @@ class Robot: public IterativeRobot
RobotDrive drive; RobotDrive drive;
Shooter shooter; Shooter shooter;
Joystick driver_stick, operator_stick; Joystick driver_stick, operator_stick;
Counter ramp_height;
public: public:
Robot(): Robot():
left_drive(1), // Left DriveTrain Talons plug into PWM channel 1 with a Y-spliter left_drive(0), // Left DriveTrain Talons plug into PWM channel 1 with a Y-spliter
right_drive(2), // Right DriveTrain Talons plug // left wheel 2 right_drive(1), // Right DriveTrain Talons plug // left wheel 2
shooter1(10), // shooter drive 1 shooter1(10), // shooter drive 1
shooter2(11), // shooter drive 2 shooter2(11), // shooter drive 2
ramp(12), ramp(12),
drive(&left_drive, &right_drive), drive(&left_drive, &right_drive),
ramp_height(),
shooter( // initialize Shooter object. shooter( // initialize Shooter object.
&shooter1, &shooter2, &ramp), &shooter1, &shooter2, &ramp, &ramp_height),
driver_stick(0), // right stick (operator) driver_stick(0), // right stick (operator)
operator_stick(1) // left stick (driver) operator_stick(1) // left stick (driver)
{ {
@ -38,6 +40,7 @@ public:
private: private:
// instance variables // instance variables
bool pickupRunning; // don't want to spam the Talon with set messages. Toggle the pickup when a button is pressed or released. bool pickupRunning; // don't want to spam the Talon with set messages. Toggle the pickup when a button is pressed or released.
bool inverting;
LiveWindow *lw = LiveWindow::GetInstance(); LiveWindow *lw = LiveWindow::GetInstance();
SendableChooser *chooser; SendableChooser *chooser;
@ -51,6 +54,14 @@ private:
chooser->AddDefault(autoNameDefault, (void*)&autoNameDefault); chooser->AddDefault(autoNameDefault, (void*)&autoNameDefault);
chooser->AddObject(autoNameCustom, (void*)&autoNameCustom); chooser->AddObject(autoNameCustom, (void*)&autoNameCustom);
SmartDashboard::PutData("Auto Modes", chooser); SmartDashboard::PutData("Auto Modes", chooser);
ramp_height.SetUpSource(1);
ramp.Enable();
shooter1.Enable();
shooter2.Enable();
left_drive.SetInverted(true);
right_drive.SetInverted(true);
inverting = false;
} }
@ -96,7 +107,7 @@ private:
void TeleopPeriodic() void TeleopPeriodic()
{ {
drive.ArcadeDrive(&driver_stick); drive.ArcadeDrive(&driver_stick, true);
// This is shit code for testing. Replace it with real code. // This is shit code for testing. Replace it with real code.
if(operator_stick.GetRawButton(RAMP_RAISE)) if(operator_stick.GetRawButton(RAMP_RAISE))
@ -123,6 +134,16 @@ private:
pickupRunning = false; pickupRunning = false;
} }
if(driver_stick.GetRawButton(THUMB) && !inverting)
{
left_drive.SetInverted(!left_drive.GetInverted());
right_drive.SetInverted(!right_drive.GetInverted());
inverting = true;
}
else if(!driver_stick.GetRawButton(THUMB))
{
inverting = false;
}
float power = (1.0 - operator_stick.GetThrottle()) / 2.0; float power = (1.0 - operator_stick.GetThrottle()) / 2.0;
shooter.SetPower(power); shooter.SetPower(power);

View File

@ -34,11 +34,12 @@ public:
* s2 is also for the pickup-mechanism and can be controlled independently. * s2 is also for the pickup-mechanism and can be controlled independently.
* *
*/ */
Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r) { Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r, Counter *h) {
shooterDrive = new RobotDrive(s1, s2); shooterDrive = new RobotDrive(s1, s2);
pickup = s2; pickup = s2;
ramp = r; ramp = r;
rampState = Uncalibrated; rampState = Uncalibrated;
rampHeight = h;
} }
/** /**
@ -57,6 +58,7 @@ public:
delete shooterDrive; delete shooterDrive;
delete pickup; delete pickup;
delete ramp; delete ramp;
delete rampHeight;
} }
void PickUp(bool state = true) { void PickUp(bool state = true) {
@ -66,6 +68,18 @@ public:
void SetRamp(RampState state) { void SetRamp(RampState state) {
// TODO: // TODO:
// Move the Ramp to the set position. // Move the Ramp to the set position.
switch (state)
{
case Shoot:
if (ramp->GetForwardLimitOK())
{
ramp->Set(1);
} else
{
ramp->Set(0);
rampHeight->Reset();
}
}
} }
/** /**
@ -84,6 +98,7 @@ private:
RobotDrive *shooterDrive; RobotDrive *shooterDrive;
CANTalon *pickup; CANTalon *pickup;
CANTalon *ramp; CANTalon *ramp;
Counter *rampHeight;
RampState rampState; RampState rampState;
RampState targetState; RampState targetState;