blob: 212ced84cc615a748f36c5cd0c18015ff53ccc58 [file] [log] [blame]
Ariv Diggi0af59c02023-10-07 13:15:39 -07001#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 "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 "y2023_bot3/constants.h"
11#include "y2023_bot3/constants/constants_generated.h"
Ariv Diggic892e922023-10-21 15:52:06 -070012#include "y2023_bot3/control_loops/superstructure/end_effector.h"
Ariv Diggi0af59c02023-10-07 13:15:39 -070013#include "y2023_bot3/control_loops/superstructure/superstructure_goal_generated.h"
14#include "y2023_bot3/control_loops/superstructure/superstructure_output_generated.h"
15#include "y2023_bot3/control_loops/superstructure/superstructure_position_generated.h"
16#include "y2023_bot3/control_loops/superstructure/superstructure_status_generated.h"
17
18namespace y2023_bot3 {
19namespace control_loops {
20namespace superstructure {
21
22class Superstructure
23 : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> {
24 public:
Maxwell Henderson43684fa2023-11-06 11:08:06 -080025 using PotAndAbsoluteEncoderSubsystem =
26 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
27 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator,
28 ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>;
29
Ariv Diggi0af59c02023-10-07 13:15:39 -070030 explicit Superstructure(::aos::EventLoop *event_loop,
31 std::shared_ptr<const constants::Values> values,
32 const ::std::string &name = "/superstructure");
33
34 double robot_velocity() const;
35
Ariv Diggic892e922023-10-21 15:52:06 -070036 inline const EndEffector &end_effector() const { return end_effector_; }
37
Ariv Diggi0af59c02023-10-07 13:15:39 -070038 protected:
39 virtual void RunIteration(const Goal *unsafe_goal, const Position *position,
40 aos::Sender<Output>::Builder *output,
41 aos::Sender<Status>::Builder *status) override;
42
43 private:
44 // Returns the Y coordinate of a game piece given the time-of-flight reading.
45 std::optional<double> LateralOffsetForTimeOfFlight(double reading);
46
47 std::shared_ptr<const constants::Values> values_;
Ariv Diggic892e922023-10-21 15:52:06 -070048 EndEffector end_effector_;
49
Ariv Diggi0af59c02023-10-07 13:15:39 -070050 aos::Alliance alliance_ = aos::Alliance::kInvalid;
51
52 DISALLOW_COPY_AND_ASSIGN(Superstructure);
53};
54
55} // namespace superstructure
56} // namespace control_loops
57} // namespace y2023_bot3
58
59#endif // Y2023_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_