joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 1 | #ifndef FRC971_CONTROL_LOOPS_shooter_shooter_H_ |
| 2 | #define FRC971_CONTROL_LOOPS_shooter_shooter_H_ |
| 3 | |
| 4 | #include <memory> |
| 5 | |
| 6 | #include "aos/common/control_loop/ControlLoop.h" |
| 7 | #include "frc971/control_loops/state_feedback_loop.h" |
| 8 | |
| 9 | #include "frc971/control_loops/shooter/shooter_motor_plant.h" |
| 10 | #include "frc971/control_loops/shooter/shooter.q.h" |
| 11 | |
| 12 | #include "frc971/control_loops/zeroed_joint.h" |
| 13 | |
| 14 | namespace frc971 { |
| 15 | namespace control_loops { |
| 16 | namespace testing { |
| 17 | class ShooterTest_NoWindupPositive_Test; |
| 18 | class ShooterTest_NoWindupNegative_Test; |
| 19 | }; |
| 20 | |
| 21 | class ShooterMotor |
| 22 | : public aos::control_loops::ControlLoop<control_loops::ShooterLoop> { |
| 23 | public: |
| 24 | explicit ShooterMotor( |
joe | 3779d0c | 2014-02-15 19:41:22 -0800 | [diff] [blame^] | 25 | control_loops::ShooterLoop *my_shooter = &control_loops::shooter_queue_group); |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 26 | |
| 27 | // True if the goal was moved to avoid goal windup. |
| 28 | bool capped_goal() const { return zeroed_joint_.capped_goal(); } |
| 29 | |
| 30 | // True if the shooter is zeroing. |
| 31 | bool is_zeroing() const { return zeroed_joint_.is_zeroing(); } |
| 32 | |
| 33 | // True if the shooter is zeroing. |
| 34 | bool is_moving_off() const { return zeroed_joint_.is_moving_off(); } |
| 35 | |
| 36 | // True if the state machine is uninitialized. |
| 37 | bool is_uninitialized() const { return zeroed_joint_.is_uninitialized(); } |
| 38 | |
| 39 | // True if the state machine is ready. |
| 40 | bool is_ready() const { return zeroed_joint_.is_ready(); } |
| 41 | |
| 42 | protected: |
| 43 | virtual void RunIteration( |
| 44 | const ShooterLoop::Goal *goal, |
| 45 | const control_loops::ShooterLoop::Position *position, |
| 46 | ShooterLoop::Output *output, |
| 47 | ShooterLoop::Status *status); |
| 48 | |
| 49 | private: |
| 50 | // Friend the test classes for acces to the internal state. |
| 51 | friend class testing::ShooterTest_NoWindupPositive_Test; |
| 52 | friend class testing::ShooterTest_NoWindupNegative_Test; |
| 53 | |
| 54 | // The zeroed joint to use. |
| 55 | ZeroedJoint<1> zeroed_joint_; |
| 56 | |
| 57 | DISALLOW_COPY_AND_ASSIGN(ShooterMotor); |
| 58 | }; |
| 59 | |
| 60 | } // namespace control_loops |
| 61 | } // namespace frc971 |
| 62 | |
| 63 | #endif // FRC971_CONTROL_LOOPS_shooter_shooter_H_ |