blob: d30e1f5863541406b0a0a8d33583bf56ccec3862 [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
Stephan Pleinesf63bde82024-01-13 15:59:33 -080033namespace y2024::input::joysticks {
Niko Sohmers3860f8a2024-01-12 21:05:19 -080034
35class Reader : public ::frc971::input::ActionJoystickInput {
36 public:
37 Reader(::aos::EventLoop *event_loop)
38 : ::frc971::input::ActionJoystickInput(
39 event_loop,
40 ::y2024::control_loops::drivetrain::GetDrivetrainConfig(),
41 ::frc971::input::DrivetrainInputReader::InputType::kPistol,
42 {.use_redundant_joysticks = true}),
43 superstructure_goal_sender_(
44 event_loop->MakeSender<control_loops::superstructure::Goal>(
45 "/superstructure")),
46 superstructure_status_fetcher_(
47 event_loop->MakeFetcher<control_loops::superstructure::Status>(
48 "/superstructure")) {}
49
50 void AutoEnded() override { AOS_LOG(INFO, "Auto ended.\n"); }
51
52 void HandleTeleop(
53 const ::frc971::input::driver_station::Data &data) override {
54 (void)data;
55 superstructure_status_fetcher_.Fetch();
56 if (!superstructure_status_fetcher_.get()) {
57 AOS_LOG(ERROR, "Got no superstructure status message.\n");
58 return;
59 }
60 }
61
62 private:
63 ::aos::Sender<control_loops::superstructure::Goal>
64 superstructure_goal_sender_;
65 ::aos::Fetcher<control_loops::superstructure::Status>
66 superstructure_status_fetcher_;
67};
68
Stephan Pleinesf63bde82024-01-13 15:59:33 -080069} // namespace y2024::input::joysticks
Niko Sohmers3860f8a2024-01-12 21:05:19 -080070
71int main(int argc, char **argv) {
72 ::aos::InitGoogle(&argc, &argv);
73
74 aos::FlatbufferDetachedBuffer<aos::Configuration> config =
75 aos::configuration::ReadConfig("aos_config.json");
76
77 ::aos::ShmEventLoop event_loop(&config.message());
78 ::y2024::input::joysticks::Reader reader(&event_loop);
79
80 event_loop.Run();
81
82 return 0;
83}