blob: baac66f2537404cf02dec5745ff0f7c6daf706d4 [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"
James Kuszmaul2549e752024-01-20 17:42:51 -080013#include "frc971/constants/constants_sender_lib.h"
Niko Sohmers3860f8a2024-01-12 21:05:19 -080014#include "frc971/control_loops/drivetrain/localizer_generated.h"
15#include "frc971/control_loops/profiled_subsystem_generated.h"
16#include "frc971/input/action_joystick_input.h"
17#include "frc971/input/driver_station_data.h"
18#include "frc971/input/drivetrain_input.h"
19#include "frc971/input/joystick_input.h"
20#include "frc971/input/redundant_joystick_data.h"
21#include "frc971/zeroing/wrap.h"
James Kuszmaul2549e752024-01-20 17:42:51 -080022#include "y2024/constants/constants_generated.h"
Niko Sohmers3860f8a2024-01-12 21:05:19 -080023#include "y2024/control_loops/drivetrain/drivetrain_base.h"
24#include "y2024/control_loops/superstructure/superstructure_goal_generated.h"
25#include "y2024/control_loops/superstructure/superstructure_status_generated.h"
26using frc971::CreateProfileParameters;
27using frc971::control_loops::CreateStaticZeroingSingleDOFProfiledSubsystemGoal;
28using frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemGoal;
29using frc971::input::driver_station::ButtonLocation;
30using frc971::input::driver_station::ControlBit;
31using frc971::input::driver_station::JoystickAxis;
32using frc971::input::driver_station::POVLocation;
33using Side = frc971::control_loops::drivetrain::RobotSide;
34
Stephan Pleinesf63bde82024-01-13 15:59:33 -080035namespace y2024::input::joysticks {
Niko Sohmers3860f8a2024-01-12 21:05:19 -080036
37class Reader : public ::frc971::input::ActionJoystickInput {
38 public:
39 Reader(::aos::EventLoop *event_loop)
40 : ::frc971::input::ActionJoystickInput(
41 event_loop,
James Kuszmaul2549e752024-01-20 17:42:51 -080042 ::y2024::control_loops::drivetrain::GetDrivetrainConfig(event_loop),
Niko Sohmers3860f8a2024-01-12 21:05:19 -080043 ::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
Stephan Pleinesf63bde82024-01-13 15:59:33 -080071} // namespace y2024::input::joysticks
Niko Sohmers3860f8a2024-01-12 21:05:19 -080072
73int main(int argc, char **argv) {
74 ::aos::InitGoogle(&argc, &argv);
75
76 aos::FlatbufferDetachedBuffer<aos::Configuration> config =
77 aos::configuration::ReadConfig("aos_config.json");
James Kuszmaul2549e752024-01-20 17:42:51 -080078 frc971::constants::WaitForConstants<y2024::Constants>(&config.message());
Niko Sohmers3860f8a2024-01-12 21:05:19 -080079
80 ::aos::ShmEventLoop event_loop(&config.message());
81 ::y2024::input::joysticks::Reader reader(&event_loop);
82
83 event_loop.Run();
84
85 return 0;
86}