blob: e057c3e1fada6ece19626ea4a58b02e4df760da4 [file] [log] [blame]
Austin Schuh3bb9a442014-02-02 16:01:45 -08001#ifndef FRC971_CONTROL_LOOPS_CLAW_CLAW_H_
2#define FRC971_CONTROL_LOOPS_CLAW_CLAW_H_
3
4#include <memory>
5
6#include "aos/common/control_loop/ControlLoop.h"
7#include "frc971/control_loops/state_feedback_loop.h"
8#include "frc971/control_loops/claw/claw.q.h"
9#include "frc971/control_loops/claw/top_claw_motor_plant.h"
10#include "frc971/control_loops/claw/bottom_claw_motor_plant.h"
11
12#include "frc971/control_loops/zeroed_joint.h"
13
14namespace frc971 {
15namespace control_loops {
16namespace testing {
17class ClawTest_NoWindupPositive_Test;
18class ClawTest_NoWindupNegative_Test;
19};
20
21class ClawMotor
22 : public aos::control_loops::ControlLoop<control_loops::ClawLoop> {
23 public:
24 explicit ClawMotor(
25 control_loops::ClawLoop *my_claw = &control_loops::claw);
26
27 // True if the goal was moved to avoid goal windup.
28 bool capped_goal() const { return zeroed_joint_.capped_goal(); }
29
30 // True if the claw is zeroing.
31 bool is_zeroing() const { return zeroed_joint_.is_zeroing(); }
32
33 // True if the claw is zeroing.
34 bool is_moving_off() const { return zeroed_joint_.is_moving_off(); }
35
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(); }
41
42 protected:
43 virtual void RunIteration(
44 const control_loops::ClawLoop::Goal *goal,
45 const control_loops::ClawLoop::Position *position,
46 control_loops::ClawLoop::Output *output,
47 ::aos::control_loops::Status *status);
48
49 private:
50 // Friend the test classes for acces to the internal state.
51 friend class testing::ClawTest_NoWindupPositive_Test;
52 friend class testing::ClawTest_NoWindupNegative_Test;
53
54 // The zeroed joint to use.
55 ZeroedJoint<1> zeroed_joint_;
56
57 DISALLOW_COPY_AND_ASSIGN(ClawMotor);
58};
59
60} // namespace control_loops
61} // namespace frc971
62
63#endif // FRC971_CONTROL_LOOPS_CLAW_CLAW_H_