blob: aab8e7d03b5e00e25dd4f6ebdb5a6be1d5da2026 [file] [log] [blame]
Tyler Chatowe51334a2019-01-20 16:58:16 -08001#ifndef Y2019_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
2#define Y2019_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
3
4#include "aos/controls/control_loop.h"
Austin Schuhff973552019-05-19 16:49:28 -07005#include "aos/events/event-loop.h"
Austin Schuhbd0a40f2019-06-30 14:56:31 -07006#include "frc971/control_loops/drivetrain/drivetrain.q.h"
Theo Bafrali00e42272019-02-12 01:07:46 -08007#include "frc971/control_loops/static_zeroing_single_dof_profiled_subsystem.h"
8#include "y2019/constants.h"
9#include "y2019/control_loops/superstructure/collision_avoidance.h"
Tyler Chatowe51334a2019-01-20 16:58:16 -080010#include "y2019/control_loops/superstructure/superstructure.q.h"
Theo Bafrali3274a182019-02-17 20:01:38 -080011#include "y2019/control_loops/superstructure/vacuum.h"
Austin Schuhff973552019-05-19 16:49:28 -070012#include "y2019/status_light.q.h"
Tyler Chatowe51334a2019-01-20 16:58:16 -080013
14namespace y2019 {
15namespace control_loops {
16namespace superstructure {
17
18class Superstructure
19 : public ::aos::controls::ControlLoop<SuperstructureQueue> {
20 public:
21 explicit Superstructure(
Austin Schuh55a13dc2019-01-27 22:39:03 -080022 ::aos::EventLoop *event_loop,
23 const ::std::string &name =
24 ".y2019.control_loops.superstructure.superstructure_queue");
Tyler Chatowe51334a2019-01-20 16:58:16 -080025
Theo Bafrali00e42272019-02-12 01:07:46 -080026 using PotAndAbsoluteEncoderSubsystem =
27 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
28 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator,
29 ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>;
30 using AbsoluteEncoderSubsystem =
31 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
32 ::frc971::zeroing::AbsoluteEncoderZeroingEstimator,
33 ::frc971::control_loops::AbsoluteEncoderProfiledJointStatus>;
34
Theo Bafrali09517b92019-02-16 15:59:17 -080035 const PotAndAbsoluteEncoderSubsystem &elevator() const { return elevator_; }
36 const PotAndAbsoluteEncoderSubsystem &wrist() const { return wrist_; }
37 const AbsoluteEncoderSubsystem &intake() const { return intake_; }
38 const PotAndAbsoluteEncoderSubsystem &stilts() const { return stilts_; }
Theo Bafrali3274a182019-02-17 20:01:38 -080039 const Vacuum &vacuum() const { return vacuum_; }
Theo Bafrali00e42272019-02-12 01:07:46 -080040
Tyler Chatowe51334a2019-01-20 16:58:16 -080041 protected:
Theo Bafrali00e42272019-02-12 01:07:46 -080042 virtual void RunIteration(const SuperstructureQueue::Goal *unsafe_goal,
43 const SuperstructureQueue::Position *position,
44 SuperstructureQueue::Output *output,
45 SuperstructureQueue::Status *status) override;
Tyler Chatowe51334a2019-01-20 16:58:16 -080046
47 private:
Austin Schuhff973552019-05-19 16:49:28 -070048 void SendColors(float red, float green, float blue);
49
50 ::aos::Sender<::y2019::StatusLight> status_light_sender_;
Austin Schuhbd0a40f2019-06-30 14:56:31 -070051 ::aos::Fetcher<::frc971::control_loops::DrivetrainQueue::Status>
52 drivetrain_status_fetcher_;
Austin Schuhff973552019-05-19 16:49:28 -070053
Theo Bafrali00e42272019-02-12 01:07:46 -080054 PotAndAbsoluteEncoderSubsystem elevator_;
55 PotAndAbsoluteEncoderSubsystem wrist_;
56 AbsoluteEncoderSubsystem intake_;
57 PotAndAbsoluteEncoderSubsystem stilts_;
Theo Bafrali3274a182019-02-17 20:01:38 -080058 Vacuum vacuum_;
Theo Bafrali00e42272019-02-12 01:07:46 -080059
60 CollisionAvoidance collision_avoidance_;
Tyler Chatowe51334a2019-01-20 16:58:16 -080061
Austin Schuh194c43c2019-03-22 20:40:53 -070062 int line_blink_count_ = 0;
63
Theo Bafrali09517b92019-02-16 15:59:17 -080064 static constexpr double kMinIntakeAngleForRollers = -0.7;
65
Tyler Chatowe51334a2019-01-20 16:58:16 -080066 DISALLOW_COPY_AND_ASSIGN(Superstructure);
67};
68
69} // namespace superstructure
70} // namespace control_loops
71} // namespace y2019
72
Austin Schuh55a13dc2019-01-27 22:39:03 -080073#endif // Y2019_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_