blob: 249de702e636876d15e1fe6a33b033066b14ef32 [file] [log] [blame]
brians343bc112013-02-10 01:53:46 +00001#ifndef FRC971_CONTROL_LOOPS_DRIVETRAIN_H_
2#define FRC971_CONTROL_LOOPS_DRIVETRAIN_H_
3
Austin Schuh2054f5f2013-10-27 14:54:10 -07004#include "Eigen/Dense"
5
6#include "aos/controls/polytope.h"
brians343bc112013-02-10 01:53:46 +00007#include "aos/common/control_loop/ControlLoop.h"
Brian Silverman718b1d72013-10-28 16:22:45 -07008#include "aos/controls/polytope.h"
James Kuszmaulf254c1a2013-03-10 16:31:26 -07009#include "frc971/control_loops/drivetrain/drivetrain.q.h"
brians343bc112013-02-10 01:53:46 +000010
11namespace frc971 {
12namespace control_loops {
13
Austin Schuh2054f5f2013-10-27 14:54:10 -070014Eigen::Matrix<double, 2, 1> CoerceGoal(aos::controls::HPolytope<2> &region,
15 const Eigen::Matrix<double, 1, 2> &K,
16 double w,
17 const Eigen::Matrix<double, 2, 1> &R);
18
brians343bc112013-02-10 01:53:46 +000019class DrivetrainLoop
Brian Silverman10f997b2013-10-11 18:01:56 -070020 : public aos::control_loops::ControlLoop<control_loops::Drivetrain, true, false> {
brians343bc112013-02-10 01:53:46 +000021 public:
22 // Constructs a control loop which can take a Drivetrain or defaults to the
23 // drivetrain at frc971::control_loops::drivetrain
24 explicit DrivetrainLoop(
25 control_loops::Drivetrain *my_drivetrain = &control_loops::drivetrain)
Brian Silverman10f997b2013-10-11 18:01:56 -070026 : aos::control_loops::ControlLoop<control_loops::Drivetrain, true, false>(
Brian Silverman718b1d72013-10-28 16:22:45 -070027 my_drivetrain) {
28 ::aos::controls::HPolytope<0>::Init();
29 }
brians343bc112013-02-10 01:53:46 +000030
31 protected:
32 // Executes one cycle of the control loop.
33 virtual void RunIteration(
34 const control_loops::Drivetrain::Goal *goal,
35 const control_loops::Drivetrain::Position *position,
36 control_loops::Drivetrain::Output *output,
37 control_loops::Drivetrain::Status *status);
38};
39
40} // namespace control_loops
41} // namespace frc971
42
43#endif // FRC971_CONTROL_LOOPS_DRIVETRAIN_H_