blob: baac66f2537404cf02dec5745ff0f7c6daf706d4 [file] [log] [blame]
#include <unistd.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include "aos/actions/actions.h"
#include "aos/init.h"
#include "aos/logging/logging.h"
#include "aos/network/team_number.h"
#include "aos/util/log_interval.h"
#include "frc971/autonomous/base_autonomous_actor.h"
#include "frc971/constants/constants_sender_lib.h"
#include "frc971/control_loops/drivetrain/localizer_generated.h"
#include "frc971/control_loops/profiled_subsystem_generated.h"
#include "frc971/input/action_joystick_input.h"
#include "frc971/input/driver_station_data.h"
#include "frc971/input/drivetrain_input.h"
#include "frc971/input/joystick_input.h"
#include "frc971/input/redundant_joystick_data.h"
#include "frc971/zeroing/wrap.h"
#include "y2024/constants/constants_generated.h"
#include "y2024/control_loops/drivetrain/drivetrain_base.h"
#include "y2024/control_loops/superstructure/superstructure_goal_generated.h"
#include "y2024/control_loops/superstructure/superstructure_status_generated.h"
using frc971::CreateProfileParameters;
using frc971::control_loops::CreateStaticZeroingSingleDOFProfiledSubsystemGoal;
using frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemGoal;
using frc971::input::driver_station::ButtonLocation;
using frc971::input::driver_station::ControlBit;
using frc971::input::driver_station::JoystickAxis;
using frc971::input::driver_station::POVLocation;
using Side = frc971::control_loops::drivetrain::RobotSide;
namespace y2024::input::joysticks {
class Reader : public ::frc971::input::ActionJoystickInput {
public:
Reader(::aos::EventLoop *event_loop)
: ::frc971::input::ActionJoystickInput(
event_loop,
::y2024::control_loops::drivetrain::GetDrivetrainConfig(event_loop),
::frc971::input::DrivetrainInputReader::InputType::kPistol,
{.use_redundant_joysticks = true}),
superstructure_goal_sender_(
event_loop->MakeSender<control_loops::superstructure::Goal>(
"/superstructure")),
superstructure_status_fetcher_(
event_loop->MakeFetcher<control_loops::superstructure::Status>(
"/superstructure")) {}
void AutoEnded() override { AOS_LOG(INFO, "Auto ended.\n"); }
void HandleTeleop(
const ::frc971::input::driver_station::Data &data) override {
(void)data;
superstructure_status_fetcher_.Fetch();
if (!superstructure_status_fetcher_.get()) {
AOS_LOG(ERROR, "Got no superstructure status message.\n");
return;
}
}
private:
::aos::Sender<control_loops::superstructure::Goal>
superstructure_goal_sender_;
::aos::Fetcher<control_loops::superstructure::Status>
superstructure_status_fetcher_;
};
} // namespace y2024::input::joysticks
int main(int argc, char **argv) {
::aos::InitGoogle(&argc, &argv);
aos::FlatbufferDetachedBuffer<aos::Configuration> config =
aos::configuration::ReadConfig("aos_config.json");
frc971::constants::WaitForConstants<y2024::Constants>(&config.message());
::aos::ShmEventLoop event_loop(&config.message());
::y2024::input::joysticks::Reader reader(&event_loop);
event_loop.Run();
return 0;
}