blob: 1dd9afd2b7922b5a708f640c8c65d9bea7d945bb [file] [log] [blame]
Austin Schuhdc1c84a2013-02-23 16:33:10 -08001#ifndef FRC971_CONTROL_LOOPS_WRIST_H_
2#define FRC971_CONTROL_LOOPS_WRIST_H_
3
4#include <memory>
5
6#include "aos/common/control_loop/ControlLoop.h"
7#include "frc971/control_loops/state_feedback_loop.h"
Austin Schuha40624b2013-03-03 14:02:40 -08008#include "frc971/control_loops/wrist/wrist_motor.q.h"
9#include "frc971/control_loops/wrist/wrist_motor_plant.h"
Austin Schuhdc1c84a2013-02-23 16:33:10 -080010
Austin Schuh844960d2013-03-09 17:07:51 -080011#include "frc971/control_loops/zeroed_joint.h"
12
Austin Schuhdc1c84a2013-02-23 16:33:10 -080013namespace frc971 {
14namespace control_loops {
Austin Schuhfa033692013-02-24 01:00:55 -080015namespace testing {
Austin Schuh06ee48e2013-03-02 01:47:54 -080016class WristTest_NoWindupPositive_Test;
17class WristTest_NoWindupNegative_Test;
Austin Schuhfa033692013-02-24 01:00:55 -080018};
19
Austin Schuhdc1c84a2013-02-23 16:33:10 -080020class WristMotor
21 : public aos::control_loops::ControlLoop<control_loops::WristLoop> {
22 public:
23 explicit WristMotor(
24 control_loops::WristLoop *my_wrist = &control_loops::wrist);
25
Austin Schuhd11c3372013-03-09 14:33:31 -080026 // True if the goal was moved to avoid goal windup.
Austin Schuh844960d2013-03-09 17:07:51 -080027 bool capped_goal() const { return zeroed_joint_.capped_goal(); }
28
29 // True if the wrist is zeroing.
30 bool is_zeroing() const { return zeroed_joint_.is_zeroing(); }
31
32 // True if the state machine is uninitialized.
33 bool is_uninitialized() const { return zeroed_joint_.is_uninitialized(); }
34
35 // True if the state machine is ready.
36 bool is_ready() const { return zeroed_joint_.is_ready(); }
Austin Schuhd11c3372013-03-09 14:33:31 -080037
Austin Schuhdc1c84a2013-02-23 16:33:10 -080038 protected:
39 virtual void RunIteration(
40 const ::aos::control_loops::Goal *goal,
41 const control_loops::WristLoop::Position *position,
42 ::aos::control_loops::Output *output,
43 ::aos::control_loops::Status *status);
44
45 private:
Austin Schuhfa033692013-02-24 01:00:55 -080046 // Friend the test classes for acces to the internal state.
Austin Schuh06ee48e2013-03-02 01:47:54 -080047 friend class testing::WristTest_NoWindupPositive_Test;
48 friend class testing::WristTest_NoWindupNegative_Test;
Austin Schuhfa033692013-02-24 01:00:55 -080049
50 // Fetches and locally caches the latest set of constants.
Austin Schuh844960d2013-03-09 17:07:51 -080051 bool FetchConstants(ZeroedJoint<1>::ConfigurationData *config_data);
Austin Schuhfa033692013-02-24 01:00:55 -080052
Austin Schuh844960d2013-03-09 17:07:51 -080053 // The zeroed joint to use.
54 ZeroedJoint<1> zeroed_joint_;
Austin Schuhd11c3372013-03-09 14:33:31 -080055
Austin Schuhfa033692013-02-24 01:00:55 -080056 DISALLOW_COPY_AND_ASSIGN(WristMotor);
Austin Schuhdc1c84a2013-02-23 16:33:10 -080057};
58
59} // namespace control_loops
60} // namespace frc971
61
62#endif // FRC971_CONTROL_LOOPS_WRIST_H_