Daniel Petti | e7ed8ec | 2013-11-02 16:19:02 +0000 | [diff] [blame] | 1 | #ifndef BOT3_CONTROL_LOOPS_SHOOTER_H_ |
| 2 | #define BOT3_CONTROL_LOOPS_SHOOTER_H_ |
James Kuszmaul | f7f5ec1 | 2013-11-01 17:58:58 -0700 | [diff] [blame] | 3 | |
| 4 | #include <memory> |
| 5 | |
| 6 | #include "aos/common/control_loop/ControlLoop.h" |
| 7 | #include "frc971/control_loops/state_feedback_loop.h" |
| 8 | #include "bot3/control_loops/shooter/shooter_motor.q.h" |
| 9 | #include "bot3/control_loops/shooter/shooter_motor_plant.h" |
| 10 | |
| 11 | namespace bot3 { |
| 12 | namespace control_loops { |
| 13 | |
| 14 | class ShooterMotor |
| 15 | : public aos::control_loops::ControlLoop<control_loops::ShooterLoop> { |
| 16 | public: |
| 17 | explicit ShooterMotor( |
| 18 | control_loops::ShooterLoop *my_shooter = &control_loops::shooter); |
| 19 | |
| 20 | // Control loop time step. |
| 21 | static const double dt; |
| 22 | |
| 23 | // Maximum speed of the shooter wheel which the encoder is rated for in |
| 24 | // rad/sec. |
| 25 | static const double kMaxSpeed; |
| 26 | |
| 27 | protected: |
| 28 | virtual void RunIteration( |
| 29 | const control_loops::ShooterLoop::Goal *goal, |
| 30 | const control_loops::ShooterLoop::Position *position, |
James Kuszmaul | b74c811 | 2013-11-03 16:13:45 -0800 | [diff] [blame] | 31 | control_loops::ShooterLoop::Output *output, |
James Kuszmaul | f7f5ec1 | 2013-11-01 17:58:58 -0700 | [diff] [blame] | 32 | control_loops::ShooterLoop::Status *status); |
| 33 | |
| 34 | private: |
| 35 | // The state feedback control loop to talk to. |
Daniel Petti | 6c3331b | 2013-11-03 19:18:10 +0000 | [diff] [blame] | 36 | ::std::unique_ptr<StateFeedbackLoop<1, 1, 1>> loop_; |
James Kuszmaul | f7f5ec1 | 2013-11-01 17:58:58 -0700 | [diff] [blame] | 37 | |
James Kuszmaul | f7f5ec1 | 2013-11-01 17:58:58 -0700 | [diff] [blame] | 38 | double average_velocity_; |
| 39 | |
James Kuszmaul | f7f5ec1 | 2013-11-01 17:58:58 -0700 | [diff] [blame] | 40 | // For making sure it keeps spinning if we're shooting. |
| 41 | double last_velocity_goal_; |
| 42 | |
James Kuszmaul | 8c0eed8 | 2013-11-05 20:28:05 -0800 | [diff] [blame] | 43 | Eigen::Matrix<double, 1, 1> U_add; |
| 44 | |
James Kuszmaul | f7f5ec1 | 2013-11-01 17:58:58 -0700 | [diff] [blame] | 45 | DISALLOW_COPY_AND_ASSIGN(ShooterMotor); |
| 46 | }; |
| 47 | |
| 48 | } // namespace control_loops |
| 49 | } // namespace bot3 |
| 50 | |
Daniel Petti | e7ed8ec | 2013-11-02 16:19:02 +0000 | [diff] [blame] | 51 | #endif // BOT3_CONTROL_LOOPS_SHOOTER_H_ |