blob: d5f4235daa4747c638a62a9e67b484fed6da8718 [file] [log] [blame]
Stephan Massaltd021f972020-01-05 20:41:23 -08001#ifndef y2020_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
2#define y2020_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
3
4#include "aos/controls/control_loop.h"
5#include "aos/events/event_loop.h"
6#include "y2020/constants.h"
Sabina Davis0f31d3f2020-02-20 20:41:00 -08007#include "y2020/control_loops/superstructure/shooter/shooter.h"
Stephan Massaltd021f972020-01-05 20:41:23 -08008#include "y2020/control_loops/superstructure/superstructure_goal_generated.h"
9#include "y2020/control_loops/superstructure/superstructure_output_generated.h"
10#include "y2020/control_loops/superstructure/superstructure_position_generated.h"
11#include "y2020/control_loops/superstructure/superstructure_status_generated.h"
John Park0a245a02020-02-02 14:10:15 -080012#include "y2020/control_loops/superstructure/climber.h"
Stephan Massaltd021f972020-01-05 20:41:23 -080013
14namespace y2020 {
15namespace control_loops {
16namespace superstructure {
17
18class Superstructure
19 : public ::aos::controls::ControlLoop<Goal, Position, Status, Output> {
20 public:
21 explicit Superstructure(::aos::EventLoop *event_loop,
22 const ::std::string &name = "/superstructure");
23
Austin Schuh2fb23642020-02-29 15:10:51 -080024 // Terms to control the velocity gain for the friction compensation, and the
25 // voltage cap.
26 static constexpr double kTurretFrictionGain = 10.0;
27 static constexpr double kTurretFrictionVoltageLimit = 1.5;
28
Kai Tinkessfb460372020-02-08 14:05:48 -080029 using PotAndAbsoluteEncoderSubsystem =
30 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
31 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator,
32 ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>;
Sabina Daviscf08b152020-01-31 22:12:09 -080033 using AbsoluteEncoderSubsystem =
34 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
35 ::frc971::zeroing::AbsoluteEncoderZeroingEstimator,
36 ::frc971::control_loops::AbsoluteEncoderProfiledJointStatus>;
37
38 const AbsoluteEncoderSubsystem &hood() const { return hood_; }
Sabina Davis0f2d38c2020-02-08 17:01:21 -080039 const AbsoluteEncoderSubsystem &intake_joint() const { return intake_joint_; }
Kai Tinkessfb460372020-02-08 14:05:48 -080040 const PotAndAbsoluteEncoderSubsystem &turret() const { return turret_; }
Sabina Davis0f31d3f2020-02-20 20:41:00 -080041 const shooter::Shooter &shooter() const { return shooter_; }
Sabina Daviscf08b152020-01-31 22:12:09 -080042
Stephan Massaltd021f972020-01-05 20:41:23 -080043 protected:
44 virtual void RunIteration(const Goal *unsafe_goal, const Position *position,
45 aos::Sender<Output>::Builder *output,
46 aos::Sender<Status>::Builder *status) override;
47
48 private:
Sabina Daviscf08b152020-01-31 22:12:09 -080049 AbsoluteEncoderSubsystem hood_;
Sabina Davis0f2d38c2020-02-08 17:01:21 -080050 AbsoluteEncoderSubsystem intake_joint_;
Kai Tinkessfb460372020-02-08 14:05:48 -080051 PotAndAbsoluteEncoderSubsystem turret_;
Sabina Davis0f31d3f2020-02-20 20:41:00 -080052 shooter::Shooter shooter_;
Sabina Daviscf08b152020-01-31 22:12:09 -080053
John Park0a245a02020-02-02 14:10:15 -080054 Climber climber_;
Stephan Massaltd021f972020-01-05 20:41:23 -080055 DISALLOW_COPY_AND_ASSIGN(Superstructure);
56};
57
58} // namespace superstructure
59} // namespace control_loops
60} // namespace y2020
61
62#endif // y2020_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_