blob: ebc2485bcc28bcba83ec71b04782dfb7ff7e6e96 [file] [log] [blame]
Niko Sohmers3860f8a2024-01-12 21:05:19 -08001#include <unistd.h>
2
3#include <cmath>
4#include <cstdio>
5#include <cstring>
6
7#include "aos/actions/actions.h"
8#include "aos/init.h"
9#include "aos/logging/logging.h"
10#include "aos/network/team_number.h"
11#include "aos/util/log_interval.h"
12#include "frc971/autonomous/base_autonomous_actor.h"
13#include "frc971/control_loops/drivetrain/localizer_generated.h"
14#include "frc971/control_loops/profiled_subsystem_generated.h"
15#include "frc971/input/action_joystick_input.h"
16#include "frc971/input/driver_station_data.h"
17#include "frc971/input/drivetrain_input.h"
18#include "frc971/input/joystick_input.h"
19#include "frc971/input/redundant_joystick_data.h"
20#include "frc971/zeroing/wrap.h"
21#include "y2024/control_loops/drivetrain/drivetrain_base.h"
22#include "y2024/control_loops/superstructure/superstructure_goal_generated.h"
23#include "y2024/control_loops/superstructure/superstructure_status_generated.h"
24using frc971::CreateProfileParameters;
25using frc971::control_loops::CreateStaticZeroingSingleDOFProfiledSubsystemGoal;
26using frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemGoal;
27using frc971::input::driver_station::ButtonLocation;
28using frc971::input::driver_station::ControlBit;
29using frc971::input::driver_station::JoystickAxis;
30using frc971::input::driver_station::POVLocation;
31using Side = frc971::control_loops::drivetrain::RobotSide;
32
33namespace y2024 {
34namespace input {
35namespace joysticks {
36
37class Reader : public ::frc971::input::ActionJoystickInput {
38 public:
39 Reader(::aos::EventLoop *event_loop)
40 : ::frc971::input::ActionJoystickInput(
41 event_loop,
42 ::y2024::control_loops::drivetrain::GetDrivetrainConfig(),
43 ::frc971::input::DrivetrainInputReader::InputType::kPistol,
44 {.use_redundant_joysticks = true}),
45 superstructure_goal_sender_(
46 event_loop->MakeSender<control_loops::superstructure::Goal>(
47 "/superstructure")),
48 superstructure_status_fetcher_(
49 event_loop->MakeFetcher<control_loops::superstructure::Status>(
50 "/superstructure")) {}
51
52 void AutoEnded() override { AOS_LOG(INFO, "Auto ended.\n"); }
53
54 void HandleTeleop(
55 const ::frc971::input::driver_station::Data &data) override {
56 (void)data;
57 superstructure_status_fetcher_.Fetch();
58 if (!superstructure_status_fetcher_.get()) {
59 AOS_LOG(ERROR, "Got no superstructure status message.\n");
60 return;
61 }
62 }
63
64 private:
65 ::aos::Sender<control_loops::superstructure::Goal>
66 superstructure_goal_sender_;
67 ::aos::Fetcher<control_loops::superstructure::Status>
68 superstructure_status_fetcher_;
69};
70
71} // namespace joysticks
72} // namespace input
73} // namespace y2024
74
75int main(int argc, char **argv) {
76 ::aos::InitGoogle(&argc, &argv);
77
78 aos::FlatbufferDetachedBuffer<aos::Configuration> config =
79 aos::configuration::ReadConfig("aos_config.json");
80
81 ::aos::ShmEventLoop event_loop(&config.message());
82 ::y2024::input::joysticks::Reader reader(&event_loop);
83
84 event_loop.Run();
85
86 return 0;
87}