blob: d4023ca7a1e82b6f0cb434906aa1783c8eed57cc [file] [log] [blame]
Sabina Davis91b23602019-01-21 00:06:01 -08001#ifndef AOS_INPUT_ACTION_JOYSTICK_INPUT_H_
2#define AOS_INPUT_ACTION_JOYSTICK_INPUT_H_
3
4#include "aos/input/driver_station_data.h"
5#include "aos/input/drivetrain_input.h"
6#include "aos/input/joystick_input.h"
7#include "frc971/autonomous/auto.q.h"
8#include "frc971/autonomous/base_autonomous_actor.h"
9
10namespace aos {
11namespace input {
12
13// Class to abstract out managing actions, autonomous mode, and drivetrains.
14// Turns out we do the same thing every year, so let's stop copying it.
15class ActionJoystickInput : public ::aos::input::JoystickInput {
16 public:
17 ActionJoystickInput(
18 ::aos::EventLoop *event_loop,
19 const ::frc971::control_loops::drivetrain::DrivetrainConfig<double>
20 &dt_config)
21 : ::aos::input::JoystickInput(event_loop),
22 drivetrain_input_reader_(DrivetrainInputReader::Make(
23 DrivetrainInputReader::InputType::kPistol, dt_config)) {}
24
25 virtual ~ActionJoystickInput() {}
26
27 private:
28 // Handles any year specific superstructure code.
29 virtual void HandleTeleop(const ::aos::input::driver_station::Data &data) = 0;
30
31 void RunIteration(const ::aos::input::driver_station::Data &data) override;
32
33 void StartAuto();
34 void StopAuto();
35
36 // True if the internal state machine thinks auto is running right now.
37 bool auto_running_ = false;
38 // True if an action was running last cycle.
39 bool was_running_ = false;
40
41 ::std::unique_ptr<DrivetrainInputReader> drivetrain_input_reader_;
42 ::aos::common::actions::ActionQueue action_queue_;
43};
44
45} // namespace input
46} // namespace aos
47
48#endif // AOS_INPUT_ACTION_JOYSTICK_INPUT_H_