blob: a3bad806028c82d4859d14ff574968ba0c3561ab [file] [log] [blame]
Brian Silvermaned674fc2013-03-17 13:39:37 -07001#ifndef FRC971_CONTROL_LOOPS_WRIST_WRIST_H_
2#define FRC971_CONTROL_LOOPS_WRIST_WRIST_H_
Austin Schuhdc1c84a2013-02-23 16:33:10 -08003
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 Schuhc1f68892013-03-16 17:06:27 -070010#include "frc971/control_loops/wrist/unaugmented_wrist_motor_plant.h"
Austin Schuhdc1c84a2013-02-23 16:33:10 -080011
Austin Schuh844960d2013-03-09 17:07:51 -080012#include "frc971/control_loops/zeroed_joint.h"
13
Austin Schuhdc1c84a2013-02-23 16:33:10 -080014namespace frc971 {
15namespace control_loops {
Austin Schuhfa033692013-02-24 01:00:55 -080016namespace testing {
Austin Schuh06ee48e2013-03-02 01:47:54 -080017class WristTest_NoWindupPositive_Test;
18class WristTest_NoWindupNegative_Test;
Austin Schuhfa033692013-02-24 01:00:55 -080019};
20
Austin Schuhdc1c84a2013-02-23 16:33:10 -080021class 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 Schuhd11c3372013-03-09 14:33:31 -080027 // True if the goal was moved to avoid goal windup.
Austin Schuh844960d2013-03-09 17:07:51 -080028 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 Schuhe20e93c2013-03-09 19:54:16 -080033 // True if the wrist is zeroing.
34 bool is_moving_off() const { return zeroed_joint_.is_moving_off(); }
35
Austin Schuh844960d2013-03-09 17:07:51 -080036 // 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 Schuhd11c3372013-03-09 14:33:31 -080041
Austin Schuhdc1c84a2013-02-23 16:33:10 -080042 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 Schuhfa033692013-02-24 01:00:55 -080050 // Friend the test classes for acces to the internal state.
Austin Schuh06ee48e2013-03-02 01:47:54 -080051 friend class testing::WristTest_NoWindupPositive_Test;
52 friend class testing::WristTest_NoWindupNegative_Test;
Austin Schuhfa033692013-02-24 01:00:55 -080053
Austin Schuh844960d2013-03-09 17:07:51 -080054 // The zeroed joint to use.
55 ZeroedJoint<1> zeroed_joint_;
Austin Schuhd11c3372013-03-09 14:33:31 -080056
Austin Schuhfa033692013-02-24 01:00:55 -080057 DISALLOW_COPY_AND_ASSIGN(WristMotor);
Austin Schuhdc1c84a2013-02-23 16:33:10 -080058};
59
60} // namespace control_loops
61} // namespace frc971
62
Brian Silvermaned674fc2013-03-17 13:39:37 -070063#endif // FRC971_CONTROL_LOOPS_WRIST_WRIST_H_