blob: 87a5395c6be3a01a5431eb3ba176016d8170eca8 [file] [log] [blame]
Maxwell Hendersonad312342023-01-10 12:07:47 -08001#ifndef Y2023_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
2#define Y2023_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"
7#include "y2023/constants.h"
milind-u738832d2023-02-24 19:55:54 -08008#include "y2023/control_loops/drivetrain/drivetrain_can_position_generated.h"
milind-u01bbcf22023-02-20 18:00:28 -08009#include "y2023/control_loops/superstructure/arm/arm.h"
Maxwell Henderson589cf272023-02-22 15:56:40 -080010#include "y2023/control_loops/superstructure/end_effector.h"
Maxwell Hendersonad312342023-01-10 12:07:47 -080011#include "y2023/control_loops/superstructure/superstructure_goal_generated.h"
12#include "y2023/control_loops/superstructure/superstructure_output_generated.h"
13#include "y2023/control_loops/superstructure/superstructure_position_generated.h"
14#include "y2023/control_loops/superstructure/superstructure_status_generated.h"
15
16namespace y2023 {
17namespace control_loops {
18namespace superstructure {
19
20class Superstructure
21 : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> {
22 public:
23 using RelativeEncoderSubsystem =
24 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
25 ::frc971::zeroing::RelativeEncoderZeroingEstimator,
26 ::frc971::control_loops::RelativeEncoderProfiledJointStatus>;
27
28 using PotAndAbsoluteEncoderSubsystem =
29 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
30 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator,
31 ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>;
32
Maxwell Henderson8ca44562023-02-23 13:11:51 -080033 using AbsoluteEncoderSubsystem =
34 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
35 ::frc971::zeroing::AbsoluteEncoderZeroingEstimator,
36 ::frc971::control_loops::AbsoluteEncoderProfiledJointStatus>;
37
Maxwell Hendersonad312342023-01-10 12:07:47 -080038 explicit Superstructure(::aos::EventLoop *event_loop,
39 std::shared_ptr<const constants::Values> values,
40 const ::std::string &name = "/superstructure");
41
42 double robot_velocity() const;
43
Maxwell Henderson8ca44562023-02-23 13:11:51 -080044 inline const arm::Arm &arm() const { return arm_; }
45 inline const EndEffector &end_effector() const { return end_effector_; }
46 inline const AbsoluteEncoderSubsystem &wrist() const { return wrist_; }
47
Maxwell Hendersonad312342023-01-10 12:07:47 -080048 protected:
49 virtual void RunIteration(const Goal *unsafe_goal, const Position *position,
50 aos::Sender<Output>::Builder *output,
51 aos::Sender<Status>::Builder *status) override;
52
53 private:
54 std::shared_ptr<const constants::Values> values_;
55
56 aos::Fetcher<frc971::control_loops::drivetrain::Status>
57 drivetrain_status_fetcher_;
58 aos::Fetcher<aos::JoystickState> joystick_state_fetcher_;
59
milind-u01bbcf22023-02-20 18:00:28 -080060 arm::Arm arm_;
Maxwell Henderson589cf272023-02-22 15:56:40 -080061 EndEffector end_effector_;
Maxwell Henderson8ca44562023-02-23 13:11:51 -080062 AbsoluteEncoderSubsystem wrist_;
milind-u01bbcf22023-02-20 18:00:28 -080063
Maxwell Hendersonad312342023-01-10 12:07:47 -080064 aos::Alliance alliance_ = aos::Alliance::kInvalid;
65
66 DISALLOW_COPY_AND_ASSIGN(Superstructure);
67};
68
69} // namespace superstructure
70} // namespace control_loops
71} // namespace y2023
72
73#endif // Y2023_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_