blob: 0e38a13d5631a5f37f3dc8ba670f269a62382719 [file] [log] [blame]
Austin Schuh6d1ee0c2015-11-21 14:36:04 -08001#ifndef Y2015_BOT3_CONTROL_LOOPS_DRIVETRAIN_H_
2#define Y2015_BOT3_CONTROL_LOOPS_DRIVETRAIN_H_
Comran Morshed0d6cf9b2015-06-17 19:29:57 +00003
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 "aos/common/util/log_interval.h"
10
11#include "frc971/shifter_hall_effect.h"
Austin Schuh6d1ee0c2015-11-21 14:36:04 -080012#include "y2015_bot3/control_loops/drivetrain/drivetrain.q.h"
Comran Morshed0d6cf9b2015-06-17 19:29:57 +000013
Austin Schuh6d1ee0c2015-11-21 14:36:04 -080014namespace y2015_bot3 {
Comran Morshed0d6cf9b2015-06-17 19:29:57 +000015namespace control_loops {
16
17// Constants
18// TODO(comran): Get actual constants.
Austin Schuhfd24e892015-09-12 16:12:43 -070019constexpr double kDrivetrainTurnWidth = 0.63;
Austin Schuhfd24e892015-09-12 16:12:43 -070020constexpr double kDrivetrainEncoderRatio = 18.0 / 44.0;
Comran Morshed0d6cf9b2015-06-17 19:29:57 +000021constexpr double kDrivetrainHighGearRatio =
Austin Schuhfd24e892015-09-12 16:12:43 -070022 kDrivetrainEncoderRatio * 18.0 / 60.0;
Comran Morshed0d6cf9b2015-06-17 19:29:57 +000023constexpr double kDrivetrainLowGearRatio = kDrivetrainHighGearRatio;
24const bool kDrivetrainClutchTransmission = false;
25const ::frc971::constants::ShifterHallEffect kDrivetrainRightShifter{
26 555, 657, 660, 560, 0.2, 0.7};
27const ::frc971::constants::ShifterHallEffect kDrivetrainLeftShifter{
28 555, 660, 644, 552, 0.2, 0.7};
29// End constants
30
31class DrivetrainLoop
32 : public aos::controls::ControlLoop<control_loops::DrivetrainQueue> {
33 public:
34 // Constructs a control loop which can take a Drivetrain or defaults to the
Austin Schuh6d1ee0c2015-11-21 14:36:04 -080035 // drivetrain at y2015_bot3::control_loops::drivetrain
Comran Morshed0d6cf9b2015-06-17 19:29:57 +000036 explicit DrivetrainLoop(control_loops::DrivetrainQueue *my_drivetrain =
37 &control_loops::drivetrain_queue)
38 : aos::controls::ControlLoop<control_loops::DrivetrainQueue>(
39 my_drivetrain) {
40 ::aos::controls::HPolytope<0>::Init();
41 }
42
43 protected:
44 // Executes one cycle of the control loop.
45 virtual void RunIteration(
46 const control_loops::DrivetrainQueue::Goal *goal,
47 const control_loops::DrivetrainQueue::Position *position,
48 control_loops::DrivetrainQueue::Output *output,
49 control_loops::DrivetrainQueue::Status *status);
50
51 typedef ::aos::util::SimpleLogInterval SimpleLogInterval;
52 SimpleLogInterval no_position_ = SimpleLogInterval(
53 ::aos::time::Time::InSeconds(0.25), WARNING, "no position");
54};
55
56} // namespace control_loops
Austin Schuh6d1ee0c2015-11-21 14:36:04 -080057} // namespace y2015_bot3
Comran Morshed0d6cf9b2015-06-17 19:29:57 +000058
Austin Schuh6d1ee0c2015-11-21 14:36:04 -080059#endif // Y2015_BOT3_CONTROL_LOOPS_DRIVETRAIN_H_