Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 1 | #ifndef Y2014_CONTROL_LOOPS_DRIVETRAIN_H_ |
| 2 | #define Y2014_CONTROL_LOOPS_DRIVETRAIN_H_ |
| 3 | |
| 4 | #include "Eigen/Dense" |
| 5 | |
| 6 | #include "aos/common/controls/polytope.h" |
| 7 | #include "aos/common/controls/control_loop.h" |
| 8 | #include "aos/common/controls/polytope.h" |
| 9 | #include "y2014/control_loops/drivetrain/drivetrain.q.h" |
Austin Schuh | 64ebab2 | 2015-11-26 13:28:30 -0800 | [diff] [blame] | 10 | #include "y2014/control_loops/drivetrain/polydrivetrain.h" |
| 11 | #include "y2014/control_loops/drivetrain/ssdrivetrain.h" |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 12 | #include "aos/common/util/log_interval.h" |
| 13 | |
Austin Schuh | 6197a18 | 2015-11-28 16:04:40 -0800 | [diff] [blame] | 14 | namespace y2014 { |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 15 | namespace control_loops { |
Austin Schuh | 6197a18 | 2015-11-28 16:04:40 -0800 | [diff] [blame] | 16 | namespace drivetrain { |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 17 | |
| 18 | class DrivetrainLoop |
Austin Schuh | 6197a18 | 2015-11-28 16:04:40 -0800 | [diff] [blame] | 19 | : public aos::controls::ControlLoop<::frc971::control_loops::DrivetrainQueue> { |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 20 | public: |
| 21 | // Constructs a control loop which can take a Drivetrain or defaults to the |
| 22 | // drivetrain at frc971::control_loops::drivetrain |
Austin Schuh | 6197a18 | 2015-11-28 16:04:40 -0800 | [diff] [blame] | 23 | explicit DrivetrainLoop( |
| 24 | ::frc971::control_loops::DrivetrainQueue *my_drivetrain = |
| 25 | &::frc971::control_loops::drivetrain_queue) |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 26 | : aos::controls::ControlLoop<control_loops::DrivetrainQueue>( |
| 27 | my_drivetrain) { |
| 28 | ::aos::controls::HPolytope<0>::Init(); |
| 29 | } |
| 30 | |
| 31 | protected: |
| 32 | // Executes one cycle of the control loop. |
| 33 | virtual void RunIteration( |
Austin Schuh | 6197a18 | 2015-11-28 16:04:40 -0800 | [diff] [blame] | 34 | const ::frc971::control_loops::DrivetrainQueue::Goal *goal, |
| 35 | const ::frc971::control_loops::DrivetrainQueue::Position *position, |
| 36 | ::frc971::control_loops::DrivetrainQueue::Output *output, |
| 37 | ::frc971::control_loops::DrivetrainQueue::Status *status); |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 38 | |
| 39 | typedef ::aos::util::SimpleLogInterval SimpleLogInterval; |
| 40 | SimpleLogInterval no_position_ = SimpleLogInterval( |
| 41 | ::aos::time::Time::InSeconds(0.25), WARNING, "no position"); |
Austin Schuh | 64ebab2 | 2015-11-26 13:28:30 -0800 | [diff] [blame] | 42 | |
| 43 | PolyDrivetrain dt_openloop_; |
| 44 | DrivetrainMotorsSS dt_closedloop_; |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
Austin Schuh | 6197a18 | 2015-11-28 16:04:40 -0800 | [diff] [blame] | 47 | } // namespace drivetrain |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 48 | } // namespace control_loops |
Austin Schuh | 6197a18 | 2015-11-28 16:04:40 -0800 | [diff] [blame] | 49 | } // namespace y2014 |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 50 | |
| 51 | #endif // Y2014_CONTROL_LOOPS_DRIVETRAIN_H_ |