blob: a53f603ad1fb15bbdf570aaa3b5ae5d460b6d1bf [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
Austin Schuhe20e93c2013-03-09 19:54:16 -080032 // True if the wrist is zeroing.
33 bool is_moving_off() const { return zeroed_joint_.is_moving_off(); }
34
Austin Schuh844960d2013-03-09 17:07:51 -080035 // True if the state machine is uninitialized.
36 bool is_uninitialized() const { return zeroed_joint_.is_uninitialized(); }
37
38 // True if the state machine is ready.
39 bool is_ready() const { return zeroed_joint_.is_ready(); }
Austin Schuhd11c3372013-03-09 14:33:31 -080040
Austin Schuhdc1c84a2013-02-23 16:33:10 -080041 protected:
42 virtual void RunIteration(
43 const ::aos::control_loops::Goal *goal,
44 const control_loops::WristLoop::Position *position,
45 ::aos::control_loops::Output *output,
46 ::aos::control_loops::Status *status);
47
48 private:
Austin Schuhfa033692013-02-24 01:00:55 -080049 // Friend the test classes for acces to the internal state.
Austin Schuh06ee48e2013-03-02 01:47:54 -080050 friend class testing::WristTest_NoWindupPositive_Test;
51 friend class testing::WristTest_NoWindupNegative_Test;
Austin Schuhfa033692013-02-24 01:00:55 -080052
53 // Fetches and locally caches the latest set of constants.
Austin Schuh844960d2013-03-09 17:07:51 -080054 bool FetchConstants(ZeroedJoint<1>::ConfigurationData *config_data);
Austin Schuhfa033692013-02-24 01:00:55 -080055
Austin Schuh844960d2013-03-09 17:07:51 -080056 // The zeroed joint to use.
57 ZeroedJoint<1> zeroed_joint_;
Austin Schuhd11c3372013-03-09 14:33:31 -080058
Austin Schuhfa033692013-02-24 01:00:55 -080059 DISALLOW_COPY_AND_ASSIGN(WristMotor);
Austin Schuhdc1c84a2013-02-23 16:33:10 -080060};
61
62} // namespace control_loops
63} // namespace frc971
64
65#endif // FRC971_CONTROL_LOOPS_WRIST_H_