blob: 88db2e22bff47c4713e352344b400b395f24c8ec [file] [log] [blame]
Niko Sohmers3860f8a2024-01-12 21:05:19 -08001#ifndef Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
2#define Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
3
4#include "aos/events/event_loop.h"
5#include "aos/json_to_flatbuffer.h"
6#include "frc971/constants/constants_sender_lib.h"
7#include "frc971/control_loops/control_loop.h"
8#include "frc971/control_loops/drivetrain/drivetrain_can_position_generated.h"
9#include "frc971/control_loops/drivetrain/drivetrain_status_generated.h"
10#include "frc971/zeroing/absolute_encoder.h"
11#include "frc971/zeroing/pot_and_absolute_encoder.h"
12#include "y2024/constants.h"
13#include "y2024/constants/constants_generated.h"
14#include "y2024/control_loops/superstructure/superstructure_goal_generated.h"
15#include "y2024/control_loops/superstructure/superstructure_output_generated.h"
16#include "y2024/control_loops/superstructure/superstructure_position_generated.h"
17#include "y2024/control_loops/superstructure/superstructure_status_generated.h"
18
Maxwell Henderson09a4b022024-01-19 21:39:51 -080019namespace y2024::control_loops::superstructure {
Niko Sohmers3860f8a2024-01-12 21:05:19 -080020
21class Superstructure
22 : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> {
23 public:
Niko Sohmersafc51fe2024-01-29 17:48:35 -080024 using PotAndAbsoluteEncoderSubsystem =
25 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
26 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator,
27 ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>;
28
Niko Sohmers3860f8a2024-01-12 21:05:19 -080029 explicit Superstructure(::aos::EventLoop *event_loop,
30 std::shared_ptr<const constants::Values> values,
31 const ::std::string &name = "/superstructure");
32
Niko Sohmersafc51fe2024-01-29 17:48:35 -080033 inline const PotAndAbsoluteEncoderSubsystem &intake_pivot() const {
34 return intake_pivot_;
35 }
36
Filip Kujawa6d717632024-02-01 11:40:55 -080037 inline const PotAndAbsoluteEncoderSubsystem &climber() const {
38 return climber_;
39 }
40
Niko Sohmers3860f8a2024-01-12 21:05:19 -080041 double robot_velocity() const;
42
43 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 frc971::constants::ConstantsFetcher<Constants> constants_fetcher_;
Niko Sohmersafc51fe2024-01-29 17:48:35 -080051 const Constants *robot_constants_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080052 aos::Fetcher<frc971::control_loops::drivetrain::Status>
53 drivetrain_status_fetcher_;
54 aos::Fetcher<aos::JoystickState> joystick_state_fetcher_;
55
56 aos::Alliance alliance_ = aos::Alliance::kInvalid;
57
Niko Sohmerse735fa82024-02-02 16:49:02 -080058 TransferRollerGoal transfer_goal_;
Niko Sohmersafc51fe2024-01-29 17:48:35 -080059 PotAndAbsoluteEncoderSubsystem intake_pivot_;
Filip Kujawa6d717632024-02-01 11:40:55 -080060 PotAndAbsoluteEncoderSubsystem climber_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080061 DISALLOW_COPY_AND_ASSIGN(Superstructure);
62};
63
Maxwell Henderson09a4b022024-01-19 21:39:51 -080064} // namespace y2024::control_loops::superstructure
Niko Sohmers3860f8a2024-01-12 21:05:19 -080065
66#endif // Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_