blob: 4522dfdac4ccc558f69b5fa3b610a13b459d5718 [file] [log] [blame]
Henry Speiser354d2782022-07-22 13:56:48 -07001#ifndef Y2022_BOT3_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
2#define Y2022_BOT3_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
3
4#include "aos/events/event_loop.h"
5#include "frc971/control_loops/control_loop.h"
6#include "frc971/control_loops/drivetrain/drivetrain_status_generated.h"
James Kuszmaulec635d22023-08-12 18:39:24 -07007#include "frc971/zeroing/pot_and_absolute_encoder.h"
Henry Speiser354d2782022-07-22 13:56:48 -07008#include "y2022_bot3/constants.h"
9#include "y2022_bot3/control_loops/superstructure/superstructure_goal_generated.h"
10#include "y2022_bot3/control_loops/superstructure/superstructure_output_generated.h"
11#include "y2022_bot3/control_loops/superstructure/superstructure_position_generated.h"
12#include "y2022_bot3/control_loops/superstructure/superstructure_status_generated.h"
13
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080014namespace y2022_bot3::control_loops::superstructure {
Henry Speiser354d2782022-07-22 13:56:48 -070015
16class Superstructure
17 : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> {
18 public:
19 using RelativeEncoderSubsystem =
20 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
21 ::frc971::zeroing::RelativeEncoderZeroingEstimator,
22 ::frc971::control_loops::RelativeEncoderProfiledJointStatus>;
23
24 using PotAndAbsoluteEncoderSubsystem =
25 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
26 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator,
27 ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>;
28
29 explicit Superstructure(::aos::EventLoop *event_loop,
30 std::shared_ptr<const constants::Values> values,
31 const ::std::string &name = "/superstructure");
32
Niko Sohmers74c5b592022-09-10 13:41:46 -070033 inline const PotAndAbsoluteEncoderSubsystem &intake() const {
34 return intake_;
35 }
36 inline const PotAndAbsoluteEncoderSubsystem &climber_left() const {
37 return climber_left_;
38 }
39 inline const PotAndAbsoluteEncoderSubsystem &climber_right() const {
40 return climber_right_;
41 }
42
Henry Speiser354d2782022-07-22 13:56:48 -070043 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:
49 std::shared_ptr<const constants::Values> values_;
50
Niko Sohmers74c5b592022-09-10 13:41:46 -070051 PotAndAbsoluteEncoderSubsystem climber_left_;
52 PotAndAbsoluteEncoderSubsystem climber_right_;
53 PotAndAbsoluteEncoderSubsystem intake_;
54
Henry Speiser354d2782022-07-22 13:56:48 -070055 aos::Fetcher<frc971::control_loops::drivetrain::Status>
56 drivetrain_status_fetcher_;
57 aos::Fetcher<aos::JoystickState> joystick_state_fetcher_;
58
59 aos::Alliance alliance_ = aos::Alliance::kInvalid;
60
61 DISALLOW_COPY_AND_ASSIGN(Superstructure);
62};
63
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080064} // namespace y2022_bot3::control_loops::superstructure
Henry Speiser354d2782022-07-22 13:56:48 -070065
66#endif // Y2022_BOT3_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_