blob: d97befc957b6ca58736e4f44dfb90658978c0760 [file] [log] [blame]
milind-u086d7262022-01-19 20:44:18 -08001#ifndef Y2022_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
2#define Y2022_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
3
milind-u086d7262022-01-19 20:44:18 -08004#include "aos/events/event_loop.h"
Siddhant Kanwar0e37f592022-02-21 19:26:50 -08005#include "frc971/control_loops/control_loop.h"
Henry Speiser55aa3ba2022-02-21 23:21:12 -08006#include "frc971/control_loops/drivetrain/drivetrain_status_generated.h"
milind-u086d7262022-01-19 20:44:18 -08007#include "y2022/constants.h"
8#include "y2022/control_loops/superstructure/superstructure_goal_generated.h"
9#include "y2022/control_loops/superstructure/superstructure_output_generated.h"
10#include "y2022/control_loops/superstructure/superstructure_position_generated.h"
11#include "y2022/control_loops/superstructure/superstructure_status_generated.h"
12
13namespace y2022 {
14namespace control_loops {
15namespace superstructure {
16
17class Superstructure
18 : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> {
19 public:
Siddhant Kanwar0e37f592022-02-21 19:26:50 -080020 using RelativeEncoderSubsystem =
21 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
22 ::frc971::zeroing::RelativeEncoderZeroingEstimator,
23 ::frc971::control_loops::RelativeEncoderProfiledJointStatus>;
24
Henry Speiser55aa3ba2022-02-21 23:21:12 -080025 using PotAndAbsoluteEncoderSubsystem =
26 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
27 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator,
28 ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>;
29
milind-u086d7262022-01-19 20:44:18 -080030 explicit Superstructure(::aos::EventLoop *event_loop,
Henry Speiser55aa3ba2022-02-21 23:21:12 -080031 std::shared_ptr<const constants::Values> values,
milind-u086d7262022-01-19 20:44:18 -080032 const ::std::string &name = "/superstructure");
33
Henry Speiser55aa3ba2022-02-21 23:21:12 -080034 inline const PotAndAbsoluteEncoderSubsystem &intake_front() const {
35 return intake_front_;
36 }
37 inline const PotAndAbsoluteEncoderSubsystem &intake_back() const {
38 return intake_back_;
39 }
40 inline const PotAndAbsoluteEncoderSubsystem &turret() const {
41 return turret_;
42 }
43 inline const RelativeEncoderSubsystem &climber() const { return climber_; }
44
45 double robot_velocity() const;
46
milind-u086d7262022-01-19 20:44:18 -080047 protected:
48 virtual void RunIteration(const Goal *unsafe_goal, const Position *position,
49 aos::Sender<Output>::Builder *output,
50 aos::Sender<Status>::Builder *status) override;
51
52 private:
Siddhant Kanwar0e37f592022-02-21 19:26:50 -080053 RelativeEncoderSubsystem climber_;
Henry Speiser55aa3ba2022-02-21 23:21:12 -080054 PotAndAbsoluteEncoderSubsystem intake_front_;
55 PotAndAbsoluteEncoderSubsystem intake_back_;
56 PotAndAbsoluteEncoderSubsystem turret_;
57
58 aos::Fetcher<frc971::control_loops::drivetrain::Status>
59 drivetrain_status_fetcher_;
Siddhant Kanwar0e37f592022-02-21 19:26:50 -080060
milind-u086d7262022-01-19 20:44:18 -080061 DISALLOW_COPY_AND_ASSIGN(Superstructure);
62};
63
64} // namespace superstructure
65} // namespace control_loops
66} // namespace y2022
67
68#endif // Y2022_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_