Brian Silverman | ed674fc | 2013-03-17 13:39:37 -0700 | [diff] [blame] | 1 | #ifndef FRC971_CONTROL_LOOPS_WRIST_WRIST_H_ |
| 2 | #define FRC971_CONTROL_LOOPS_WRIST_WRIST_H_ |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 3 | |
| 4 | #include <memory> |
| 5 | |
| 6 | #include "aos/common/control_loop/ControlLoop.h" |
| 7 | #include "frc971/control_loops/state_feedback_loop.h" |
Austin Schuh | a40624b | 2013-03-03 14:02:40 -0800 | [diff] [blame] | 8 | #include "frc971/control_loops/wrist/wrist_motor.q.h" |
| 9 | #include "frc971/control_loops/wrist/wrist_motor_plant.h" |
Austin Schuh | c1f6889 | 2013-03-16 17:06:27 -0700 | [diff] [blame] | 10 | #include "frc971/control_loops/wrist/unaugmented_wrist_motor_plant.h" |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 11 | |
Austin Schuh | 844960d | 2013-03-09 17:07:51 -0800 | [diff] [blame] | 12 | #include "frc971/control_loops/zeroed_joint.h" |
| 13 | |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 14 | namespace frc971 { |
| 15 | namespace control_loops { |
Austin Schuh | fa03369 | 2013-02-24 01:00:55 -0800 | [diff] [blame] | 16 | namespace testing { |
Austin Schuh | 06ee48e | 2013-03-02 01:47:54 -0800 | [diff] [blame] | 17 | class WristTest_NoWindupPositive_Test; |
| 18 | class WristTest_NoWindupNegative_Test; |
Austin Schuh | fa03369 | 2013-02-24 01:00:55 -0800 | [diff] [blame] | 19 | }; |
| 20 | |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 21 | class WristMotor |
| 22 | : public aos::control_loops::ControlLoop<control_loops::WristLoop> { |
| 23 | public: |
| 24 | explicit WristMotor( |
| 25 | control_loops::WristLoop *my_wrist = &control_loops::wrist); |
| 26 | |
Austin Schuh | d11c337 | 2013-03-09 14:33:31 -0800 | [diff] [blame] | 27 | // True if the goal was moved to avoid goal windup. |
Austin Schuh | 844960d | 2013-03-09 17:07:51 -0800 | [diff] [blame] | 28 | bool capped_goal() const { return zeroed_joint_.capped_goal(); } |
| 29 | |
| 30 | // True if the wrist is zeroing. |
| 31 | bool is_zeroing() const { return zeroed_joint_.is_zeroing(); } |
| 32 | |
Austin Schuh | e20e93c | 2013-03-09 19:54:16 -0800 | [diff] [blame] | 33 | // True if the wrist is zeroing. |
| 34 | bool is_moving_off() const { return zeroed_joint_.is_moving_off(); } |
| 35 | |
Austin Schuh | 844960d | 2013-03-09 17:07:51 -0800 | [diff] [blame] | 36 | // True if the state machine is uninitialized. |
| 37 | bool is_uninitialized() const { return zeroed_joint_.is_uninitialized(); } |
| 38 | |
| 39 | // True if the state machine is ready. |
| 40 | bool is_ready() const { return zeroed_joint_.is_ready(); } |
Austin Schuh | d11c337 | 2013-03-09 14:33:31 -0800 | [diff] [blame] | 41 | |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 42 | protected: |
| 43 | virtual void RunIteration( |
| 44 | const ::aos::control_loops::Goal *goal, |
| 45 | const control_loops::WristLoop::Position *position, |
| 46 | ::aos::control_loops::Output *output, |
| 47 | ::aos::control_loops::Status *status); |
| 48 | |
| 49 | private: |
Austin Schuh | fa03369 | 2013-02-24 01:00:55 -0800 | [diff] [blame] | 50 | // Friend the test classes for acces to the internal state. |
Austin Schuh | 06ee48e | 2013-03-02 01:47:54 -0800 | [diff] [blame] | 51 | friend class testing::WristTest_NoWindupPositive_Test; |
| 52 | friend class testing::WristTest_NoWindupNegative_Test; |
Austin Schuh | fa03369 | 2013-02-24 01:00:55 -0800 | [diff] [blame] | 53 | |
Austin Schuh | 844960d | 2013-03-09 17:07:51 -0800 | [diff] [blame] | 54 | // The zeroed joint to use. |
| 55 | ZeroedJoint<1> zeroed_joint_; |
Austin Schuh | d11c337 | 2013-03-09 14:33:31 -0800 | [diff] [blame] | 56 | |
Austin Schuh | fa03369 | 2013-02-24 01:00:55 -0800 | [diff] [blame] | 57 | DISALLOW_COPY_AND_ASSIGN(WristMotor); |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | } // namespace control_loops |
| 61 | } // namespace frc971 |
| 62 | |
Brian Silverman | ed674fc | 2013-03-17 13:39:37 -0700 | [diff] [blame] | 63 | #endif // FRC971_CONTROL_LOOPS_WRIST_WRIST_H_ |