Files
James Kuszmaul e017f93f16 Fixed examples to build/run with new WPILib versions.
Also added some references/smart pointers to a couple places
that seemed convenient to the user.

I haven't updated the constructors for RobotDrive() related
examples, pending the results of gerrit change https://usfirst.collab.net/gerrit/#/c/960/

A few things that we are noticing:
--It might be nice if ReturnPIDInput() didn't have to be const;
  when people try to override it, they have to remember to put
  the const in and if they don't, then the compiler error isn't the
  most obvious (especially since this is a change). This would also
  apply to PIDGet() in the PIDSource interface.
--SendableChooser still takes raw pointers. This could lead to an
  issue I had to debug briefly where you accidentally call
  GetSelected() on autoChooser and put the resulting raw pointer
  into a unique_ptr, which destroys the pointer when it goes out of
  scope. Specifically, I was testing the PacGoat example and
  I ended up with a situation where if auto mode was run once, it
  was fine, but if it was run twice, the selected command would
  have been destroyed by the unique_ptr. I believe that this
  just requires updating SendableChosser to take shared_ptr.
--When the samples are compiled with -pedantic, it points out that
  START_ROBOT_CLASS macro expansion results in a redundant semicolon.

Change-Id: Ib4c025a61263d0d2780d4253faa31713e15333a5
2015-08-13 11:26:28 -07:00

118 lines
2.6 KiB
C++

#ifndef Shooter_H
#define Shooter_H
#include "Commands/Subsystem.h"
#include "WPILib.h"
/**
* The Shooter subsystem handles shooting. The mechanism for shooting is
* slightly complicated because it has to pneumatic cylinders for shooting, and
* a third latch to allow the pressure to partially build up and reduce the
* effect of the airflow. For shorter shots, when full power isn't needed, only
* one cylinder fires.
*
* NOTE: Simulation currently approximates this as as single pneumatic cylinder
* and ignores the latch.
*/
class Shooter: public Subsystem
{
private:
// Devices
std::shared_ptr<DoubleSolenoid> piston1;
std::shared_ptr<DoubleSolenoid> piston2;
std::shared_ptr<Solenoid> latchPiston;
std::shared_ptr<DigitalInput> piston1ReedSwitchFront;
std::shared_ptr<DigitalInput> piston1ReedSwitchBack;
std::shared_ptr<DigitalInput> hotGoalSensor; // NOTE: Currently ignored in simulation
public:
Shooter();
void InitDefaultCommand();
/**
* Extend both solenoids to shoot.
*/
void ExtendBoth();
/**
* Retract both solenoids to prepare to shoot.
*/
void RetractBoth();
/**
* Extend solenoid 1 to shoot.
*/
void Extend1();
/**
* Retract solenoid 1 to prepare to shoot.
*/
void Retract1();
/**
* Extend solenoid 2 to shoot.
*/
void Extend2();
/**
* Retract solenoid 2 to prepare to shoot.
*/
void Retract2();
/**
* Turns off the piston1 double solenoid. This won't actuate anything
* because double solenoids preserve their state when turned off. This
* should be called in order to reduce the amount of time that the coils are
* powered.
*/
void Off1();
/**
* Turns off the piston1 double solenoid. This won't actuate anything
* because double solenoids preserve their state when turned off. This
* should be called in order to reduce the amount of time that the coils are
* powered.
*/
void Off2();
/**
* Release the latch so that we can shoot
*/
void Unlatch();
/**
* Latch so that pressure can build up and we aren't limited by air flow.
*/
void Latch();
/**
* Toggles the latch postions
*/
void ToggleLatchPosition();
/**
* @return Whether or not piston 1 is fully extended.
*/
bool Piston1IsExtended();
/**
* @return Whether or not piston 1 is fully retracted.
*/
bool Piston1IsRetracted();
/**
* Turns off all double solenoids. Double solenoids hold their position when
* they are turned off. We should turn them off whenever possible to extend
* the life of the coils
*/
void OffBoth();
/**
* @return Whether or not the goal is hot as read by the banner sensor
*/
bool GoalIsHot();
};
#endif