blob: b9514c3b3312c8f19d23f166ff0045ca371c0672 [file] [log] [blame]
Daniel Pettie7ed8ec2013-11-02 16:19:02 +00001#ifndef BOT3_CONTROL_LOOPS_SHOOTER_H_
2#define BOT3_CONTROL_LOOPS_SHOOTER_H_
James Kuszmaulf7f5ec12013-11-01 17:58:58 -07003
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
11namespace bot3 {
12namespace control_loops {
13
14class 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 Kuszmaulb74c8112013-11-03 16:13:45 -080031 control_loops::ShooterLoop::Output *output,
James Kuszmaulf7f5ec12013-11-01 17:58:58 -070032 control_loops::ShooterLoop::Status *status);
33
34 private:
35 // The state feedback control loop to talk to.
Daniel Petti6c3331b2013-11-03 19:18:10 +000036 ::std::unique_ptr<StateFeedbackLoop<1, 1, 1>> loop_;
James Kuszmaulf7f5ec12013-11-01 17:58:58 -070037
James Kuszmaulf7f5ec12013-11-01 17:58:58 -070038 double average_velocity_;
39
James Kuszmaulf7f5ec12013-11-01 17:58:58 -070040 // For making sure it keeps spinning if we're shooting.
41 double last_velocity_goal_;
42
James Kuszmaul8c0eed82013-11-05 20:28:05 -080043 Eigen::Matrix<double, 1, 1> U_add;
44
James Kuszmaulf7f5ec12013-11-01 17:58:58 -070045 DISALLOW_COPY_AND_ASSIGN(ShooterMotor);
46};
47
48} // namespace control_loops
49} // namespace bot3
50
Daniel Pettie7ed8ec2013-11-02 16:19:02 +000051#endif // BOT3_CONTROL_LOOPS_SHOOTER_H_