Deleted all of 2012 due to dismanteled robot
Signed-off-by: Yash Chainani <yashchainani28@gmail.com>
Change-Id: Ie352d953ec56af909da5669967e4e009f4fb8816
diff --git a/y2012/BUILD b/y2012/BUILD
deleted file mode 100644
index ddcdb43..0000000
--- a/y2012/BUILD
+++ /dev/null
@@ -1,77 +0,0 @@
-load("//frc971:downloader.bzl", "robot_downloader")
-
-cc_binary(
- name = "joystick_reader",
- srcs = [
- "joystick_reader.cc",
- ],
- target_compatible_with = ["@platforms//os:linux"],
- deps = [
- "//aos:init",
- "//aos/actions:action_lib",
- "//aos/logging",
- "//aos/time",
- "//aos/util:log_interval",
- "//frc971/autonomous:auto_fbs",
- "//frc971/control_loops:control_loops_fbs",
- "//frc971/control_loops/drivetrain:drivetrain_goal_fbs",
- "//frc971/control_loops/drivetrain:spline_goal_fbs",
- "//frc971/input:joystick_input",
- "//y2012/control_loops/accessories:accessories_fbs",
- ],
-)
-
-robot_downloader(
- start_binaries = [
- ":joystick_reader",
- ":wpilib_interface",
- "//y2012/control_loops/drivetrain",
- "//y2012/control_loops/accessories",
- ],
- target_compatible_with = ["@platforms//os:linux"],
-)
-
-cc_binary(
- name = "wpilib_interface",
- srcs = [
- "wpilib_interface.cc",
- ],
- target_compatible_with = ["//tools/platforms/hardware:roborio"],
- deps = [
- "//aos:init",
- "//aos/events:shm_event_loop",
- "//aos/logging",
- "//aos/stl_mutex",
- "//aos/time",
- "//aos/util:log_interval",
- "//aos/util:phased_loop",
- "//aos/util:wrapping_counter",
- "//frc971/control_loops:control_loop",
- "//frc971/control_loops:control_loops_fbs",
- "//frc971/control_loops/drivetrain:drivetrain_output_fbs",
- "//frc971/control_loops/drivetrain:drivetrain_position_fbs",
- "//frc971/input:robot_state_fbs",
- "//frc971/wpilib:buffered_pcm",
- "//frc971/wpilib:dma",
- "//frc971/wpilib:dma_edge_counting",
- "//frc971/wpilib:drivetrain_writer",
- "//frc971/wpilib:encoder_and_potentiometer",
- "//frc971/wpilib:interrupt_edge_counting",
- "//frc971/wpilib:joystick_sender",
- "//frc971/wpilib:logging_fbs",
- "//frc971/wpilib:loop_output_handler",
- "//frc971/wpilib:sensor_reader",
- "//frc971/wpilib:wpilib_interface",
- "//frc971/wpilib:wpilib_robot_base",
- "//third_party:wpilib",
- "//y2012/control_loops:control_loop_fbs",
- "//y2012/control_loops/accessories:accessories_fbs",
- ],
-)
-
-py_library(
- name = "python_init",
- srcs = ["__init__.py"],
- target_compatible_with = ["@platforms//os:linux"],
- visibility = ["//visibility:public"],
-)
diff --git a/y2012/__init__.py b/y2012/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/y2012/__init__.py
+++ /dev/null
diff --git a/y2012/control_loops/BUILD b/y2012/control_loops/BUILD
deleted file mode 100644
index ef4e03f..0000000
--- a/y2012/control_loops/BUILD
+++ /dev/null
@@ -1,18 +0,0 @@
-load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
-
-py_library(
- name = "python_init",
- srcs = ["__init__.py"],
- target_compatible_with = ["@platforms//os:linux"],
- visibility = ["//visibility:public"],
- deps = ["//y2012:python_init"],
-)
-
-flatbuffer_cc_library(
- name = "control_loop_fbs",
- srcs = [
- "control_loops.fbs",
- ],
- target_compatible_with = ["@platforms//os:linux"],
- visibility = ["//y2012:__subpackages__"],
-)
diff --git a/y2012/control_loops/__init__.py b/y2012/control_loops/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/y2012/control_loops/__init__.py
+++ /dev/null
diff --git a/y2012/control_loops/accessories/BUILD b/y2012/control_loops/accessories/BUILD
deleted file mode 100644
index ee61511..0000000
--- a/y2012/control_loops/accessories/BUILD
+++ /dev/null
@@ -1,25 +0,0 @@
-package(default_visibility = ["//visibility:public"])
-
-load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
-
-cc_binary(
- name = "accessories",
- srcs = [
- "accessories.cc",
- ],
- target_compatible_with = ["@platforms//os:linux"],
- deps = [
- ":accessories_fbs",
- "//aos:init",
- "//frc971/control_loops:control_loop",
- "//y2012/control_loops:control_loop_fbs",
- ],
-)
-
-flatbuffer_cc_library(
- name = "accessories_fbs",
- srcs = [
- "accessories.fbs",
- ],
- target_compatible_with = ["@platforms//os:linux"],
-)
diff --git a/y2012/control_loops/accessories/accessories.cc b/y2012/control_loops/accessories/accessories.cc
deleted file mode 100644
index c71146e..0000000
--- a/y2012/control_loops/accessories/accessories.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "aos/events/shm_event_loop.h"
-#include "aos/init.h"
-#include "frc971/control_loops/control_loop.h"
-#include "y2012/control_loops/accessories/accessories_generated.h"
-#include "y2012/control_loops/control_loops_generated.h"
-
-namespace y2012 {
-namespace control_loops {
-namespace accessories {
-
-class AccessoriesLoop : public ::frc971::controls::ControlLoop<
- Message, ::aos::control_loops::Position,
- ::aos::control_loops::Status, Message> {
- public:
- explicit AccessoriesLoop(
- ::aos::EventLoop *event_loop,
- const ::std::string &name = ".y2012.control_loops.accessories_queue")
- : ::frc971::controls::ControlLoop<Message, ::aos::control_loops::Position,
- ::aos::control_loops::Status, Message>(
- event_loop, name) {}
-
- void RunIteration(const Message *goal,
- const ::aos::control_loops::Position * /*position*/,
- ::aos::Sender<Message>::Builder *output,
- ::aos::Sender<::aos::control_loops::Status>::Builder
- * /*status*/) override {
- if (output) {
- //*output = *goal;
- Message::Builder output_builder = output->MakeBuilder<Message>();
- flatbuffers::Offset<flatbuffers::Vector<uint8_t>> solenoid_offset =
- output->fbb()->template CreateVector<uint8_t>(
- goal->solenoids()->data(), 3);
- output_builder.add_solenoids(solenoid_offset);
- flatbuffers::Offset<flatbuffers::Vector<double>> stick_offset =
- output->fbb()->template CreateVector<double>(goal->sticks()->data(),
- 2);
- output_builder.add_sticks(stick_offset);
-
- output_builder.Finish();
- }
- }
-};
-
-} // namespace accessories
-} // namespace control_loops
-} // namespace y2012
-
-int main(int argc, char **argv) {
- ::aos::InitGoogle(&argc, &argv);
-
- aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig("config.json");
-
- ::aos::ShmEventLoop event_loop(&config.message());
- ::y2012::control_loops::accessories::AccessoriesLoop accessories(&event_loop);
-
- event_loop.Run();
-
- return 0;
-}
diff --git a/y2012/control_loops/accessories/accessories.fbs b/y2012/control_loops/accessories/accessories.fbs
deleted file mode 100644
index 0840da4..0000000
--- a/y2012/control_loops/accessories/accessories.fbs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace y2012.control_loops.accessories;
-
-table Message {
- solenoids:[bool] (id: 0); // Exactly 3 values
- sticks:[double] (id: 1); // Exactly 2 values
-}
-
-root_type Message;
diff --git a/y2012/control_loops/control_loops.fbs b/y2012/control_loops/control_loops.fbs
deleted file mode 100644
index be5b7db..0000000
--- a/y2012/control_loops/control_loops.fbs
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace aos.control_loops;
-// This file defines basic messages for a Single Input Single Output (SISO)
-// control loop.
-
-table Goal {
- goal:double (id: 0);
-}
-
-table Position {
- position:double (id: 0);
-}
-
-table Output {
- voltage:double (id: 0);
-}
-
-table Status {
- done:bool (id: 0);
-}
-
-root_type Goal;
-root_type Position;
-root_type Output;
-root_type Status;
diff --git a/y2012/control_loops/drivetrain/BUILD b/y2012/control_loops/drivetrain/BUILD
deleted file mode 100644
index cd575ea..0000000
--- a/y2012/control_loops/drivetrain/BUILD
+++ /dev/null
@@ -1,87 +0,0 @@
-package(default_visibility = ["//visibility:public"])
-
-genrule(
- name = "genrule_drivetrain",
- outs = [
- "drivetrain_dog_motor_plant.h",
- "drivetrain_dog_motor_plant.cc",
- "kalman_drivetrain_motor_plant.h",
- "kalman_drivetrain_motor_plant.cc",
- ],
- cmd = "$(location //y2012/control_loops/python:drivetrain) $(OUTS)",
- target_compatible_with = ["@platforms//os:linux"],
- tools = [
- "//y2012/control_loops/python:drivetrain",
- ],
- visibility = ["//visibility:private"],
-)
-
-genrule(
- name = "genrule_polydrivetrain",
- outs = [
- "polydrivetrain_dog_motor_plant.h",
- "polydrivetrain_dog_motor_plant.cc",
- "polydrivetrain_cim_plant.h",
- "polydrivetrain_cim_plant.cc",
- "hybrid_velocity_drivetrain.h",
- "hybrid_velocity_drivetrain.cc",
- ],
- cmd = "$(location //y2012/control_loops/python:polydrivetrain) $(OUTS)",
- target_compatible_with = ["@platforms//os:linux"],
- tools = [
- "//y2012/control_loops/python:polydrivetrain",
- ],
- visibility = ["//visibility:private"],
-)
-
-cc_library(
- name = "polydrivetrain_plants",
- srcs = [
- "drivetrain_dog_motor_plant.cc",
- "hybrid_velocity_drivetrain.cc",
- "kalman_drivetrain_motor_plant.cc",
- "polydrivetrain_dog_motor_plant.cc",
- ],
- hdrs = [
- "drivetrain_dog_motor_plant.h",
- "hybrid_velocity_drivetrain.h",
- "kalman_drivetrain_motor_plant.h",
- "polydrivetrain_dog_motor_plant.h",
- ],
- target_compatible_with = ["@platforms//os:linux"],
- deps = [
- "//frc971/control_loops:hybrid_state_feedback_loop",
- "//frc971/control_loops:state_feedback_loop",
- ],
-)
-
-cc_library(
- name = "drivetrain_base",
- srcs = [
- "drivetrain_base.cc",
- ],
- hdrs = [
- "drivetrain_base.h",
- ],
- target_compatible_with = ["@platforms//os:linux"],
- deps = [
- ":polydrivetrain_plants",
- "//frc971:shifter_hall_effect",
- "//frc971/control_loops/drivetrain:drivetrain_config",
- "//y2016:constants",
- ],
-)
-
-cc_binary(
- name = "drivetrain",
- srcs = [
- "drivetrain_main.cc",
- ],
- target_compatible_with = ["@platforms//os:linux"],
- deps = [
- ":drivetrain_base",
- "//aos:init",
- "//aos/events:shm_event_loop",
- "//frc971/control_loops/drivetrain:drivetrain_lib",
- ],
-)
diff --git a/y2012/control_loops/drivetrain/drivetrain_base.cc b/y2012/control_loops/drivetrain/drivetrain_base.cc
deleted file mode 100644
index 40f4d24..0000000
--- a/y2012/control_loops/drivetrain/drivetrain_base.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "y2012/control_loops/drivetrain/drivetrain_base.h"
-
-#include <chrono>
-
-#include "frc971/control_loops/drivetrain/drivetrain_config.h"
-#include "frc971/control_loops/state_feedback_loop.h"
-#include "y2012/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
-#include "y2012/control_loops/drivetrain/kalman_drivetrain_motor_plant.h"
-#include "y2012/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h"
-#include "y2012/control_loops/drivetrain/hybrid_velocity_drivetrain.h"
-
-using ::frc971::control_loops::drivetrain::DrivetrainConfig;
-
-namespace chrono = ::std::chrono;
-
-namespace y2012 {
-namespace control_loops {
-namespace drivetrain {
-
-using ::frc971::constants::ShifterHallEffect;
-
-const ShifterHallEffect kThreeStateDriveShifter{0.0, 0.0, 0.25, 0.75};
-
-const DrivetrainConfig<double> &GetDrivetrainConfig() {
- static DrivetrainConfig<double> kDrivetrainConfig{
- ::frc971::control_loops::drivetrain::ShifterType::NO_SHIFTER,
- ::frc971::control_loops::drivetrain::LoopType::CLOSED_LOOP,
- ::frc971::control_loops::drivetrain::GyroType::SPARTAN_GYRO,
- ::frc971::control_loops::drivetrain::IMUType::IMU_X,
-
- drivetrain::MakeDrivetrainLoop,
- drivetrain::MakeVelocityDrivetrainLoop,
- drivetrain::MakeKFDrivetrainLoop,
- drivetrain::MakeHybridVelocityDrivetrainLoop,
-
- chrono::duration_cast<chrono::nanoseconds>(
- chrono::duration<double>(drivetrain::kDt)),
- drivetrain::kRobotRadius,
- drivetrain::kWheelRadius,
- drivetrain::kV,
-
- drivetrain::kHighGearRatio,
- drivetrain::kLowGearRatio,
- drivetrain::kJ,
- drivetrain::kMass,
- kThreeStateDriveShifter,
- kThreeStateDriveShifter,
- true /* default_high_gear */,
- 0.0,
- 0.4 /* wheel_non_linearity */,
- 1.0 /* quickturn_wheel_multiplier */,
- 1.0 /* wheel_multiplier */};
-
- return kDrivetrainConfig;
-};
-
-} // namespace drivetrain
-} // namespace control_loops
-} // namespace y2012
diff --git a/y2012/control_loops/drivetrain/drivetrain_base.h b/y2012/control_loops/drivetrain/drivetrain_base.h
deleted file mode 100644
index f5675a8..0000000
--- a/y2012/control_loops/drivetrain/drivetrain_base.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef Y2012_CONTROL_LOOPS_DRIVETRAIN_DRIVETRAIN_BASE_H_
-#define Y2012_CONTROL_LOOPS_DRIVETRAIN_DRIVETRAIN_BASE_H_
-
-#include "frc971/control_loops/drivetrain/drivetrain_config.h"
-
-namespace y2012 {
-namespace control_loops {
-namespace drivetrain {
-
-const ::frc971::control_loops::drivetrain::DrivetrainConfig<double>
- &GetDrivetrainConfig();
-
-} // namespace drivetrain
-} // namespace control_loops
-} // namespace y2012
-
-#endif // Y2012_CONTROL_LOOPS_DRIVETRAIN_DRIVETRAIN_BASE_H_
diff --git a/y2012/control_loops/drivetrain/drivetrain_main.cc b/y2012/control_loops/drivetrain/drivetrain_main.cc
deleted file mode 100644
index 8665e91..0000000
--- a/y2012/control_loops/drivetrain/drivetrain_main.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <memory>
-
-#include "aos/events/shm_event_loop.h"
-#include "aos/init.h"
-#include "frc971/control_loops/drivetrain/drivetrain.h"
-#include "y2012/control_loops/drivetrain/drivetrain_base.h"
-
-using ::frc971::control_loops::drivetrain::DrivetrainLoop;
-
-int main(int argc, char **argv) {
- ::aos::InitGoogle(&argc, &argv);
-
- aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig("config.json");
-
- ::aos::ShmEventLoop event_loop(&config.message());
- ::frc971::control_loops::drivetrain::DeadReckonEkf localizer(
- &event_loop, ::y2012::control_loops::drivetrain::GetDrivetrainConfig());
- std::unique_ptr<DrivetrainLoop> drivetrain = std::make_unique<DrivetrainLoop>(
- ::y2012::control_loops::drivetrain::GetDrivetrainConfig(), &event_loop,
- &localizer);
-
- event_loop.Run();
-
- return 0;
-}
diff --git a/y2012/control_loops/python/BUILD b/y2012/control_loops/python/BUILD
deleted file mode 100644
index 1bceece..0000000
--- a/y2012/control_loops/python/BUILD
+++ /dev/null
@@ -1,54 +0,0 @@
-package(default_visibility = ["//y2012:__subpackages__"])
-
-py_binary(
- name = "drivetrain",
- srcs = [
- "drivetrain.py",
- ],
- legacy_create_init = False,
- target_compatible_with = ["@platforms//cpu:x86_64"],
- deps = [
- ":python_init",
- "//external:python-gflags",
- "//external:python-glog",
- "//frc971/control_loops/python:drivetrain",
- ],
-)
-
-py_binary(
- name = "polydrivetrain",
- srcs = [
- "drivetrain.py",
- "polydrivetrain.py",
- ],
- legacy_create_init = False,
- target_compatible_with = ["@platforms//cpu:x86_64"],
- deps = [
- ":python_init",
- "//external:python-gflags",
- "//external:python-glog",
- "//frc971/control_loops/python:polydrivetrain",
- ],
-)
-
-py_library(
- name = "polydrivetrain_lib",
- srcs = [
- "drivetrain.py",
- "polydrivetrain.py",
- ],
- target_compatible_with = ["@platforms//cpu:x86_64"],
- deps = [
- "//external:python-gflags",
- "//external:python-glog",
- "//frc971/control_loops/python:controls",
- ],
-)
-
-py_library(
- name = "python_init",
- srcs = ["__init__.py"],
- target_compatible_with = ["@platforms//os:linux"],
- visibility = ["//visibility:public"],
- deps = ["//y2012/control_loops:python_init"],
-)
diff --git a/y2012/control_loops/python/__init__.py b/y2012/control_loops/python/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/y2012/control_loops/python/__init__.py
+++ /dev/null
diff --git a/y2012/control_loops/python/drivetrain.py b/y2012/control_loops/python/drivetrain.py
deleted file mode 100755
index 5449503..0000000
--- a/y2012/control_loops/python/drivetrain.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/python3
-
-from __future__ import print_function
-from frc971.control_loops.python import drivetrain
-import sys
-
-import gflags
-import glog
-
-FLAGS = gflags.FLAGS
-
-gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
-
-kDrivetrain = drivetrain.DrivetrainParams(J = 1.5,
- mass = 30,
- robot_radius = 0.647998644 / 2.0,
- wheel_radius = .04445,
- G_high = 30.0 / 45.0 * 15.0 / 50.0,
- G_low = 15.0 / 60.0 * 15.0 / 50.0,
- q_pos_low = 0.12,
- q_pos_high = 0.14,
- q_vel_low = 1.0,
- q_vel_high = 0.95,
- has_imu = False,
- dt = 0.005,
- controller_poles = [0.8, 0.8])
-
-def main(argv):
- argv = FLAGS(argv)
- glog.init()
-
- if FLAGS.plot:
- drivetrain.PlotDrivetrainMotions(kDrivetrain)
- elif len(argv) != 5:
- print("Expected .h file name and .cc file name")
- else:
- # Write the generated constants out to a file.
- drivetrain.WriteDrivetrain(argv[1:3], argv[3:5], 'y2012', kDrivetrain)
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/y2012/control_loops/python/polydrivetrain.py b/y2012/control_loops/python/polydrivetrain.py
deleted file mode 100755
index ae26dbe..0000000
--- a/y2012/control_loops/python/polydrivetrain.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/python3
-
-import sys
-from y2012.control_loops.python import drivetrain
-from frc971.control_loops.python import polydrivetrain
-
-import gflags
-import glog
-
-__author__ = 'Austin Schuh (austin.linux@gmail.com)'
-
-FLAGS = gflags.FLAGS
-
-try:
- gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
-except gflags.DuplicateFlagError:
- pass
-
-def main(argv):
- if FLAGS.plot:
- polydrivetrain.PlotPolyDrivetrainMotions(drivetrain.kDrivetrain)
- elif len(argv) != 7:
- glog.fatal('Expected .h file name and .cc file name')
- else:
- polydrivetrain.WritePolyDrivetrain(argv[1:3], argv[3:5], argv[5:7], 'y2012',
- drivetrain.kDrivetrain)
-
-if __name__ == '__main__':
- argv = FLAGS(sys.argv)
- glog.init()
- sys.exit(main(argv))
diff --git a/y2012/joystick_reader.cc b/y2012/joystick_reader.cc
deleted file mode 100644
index 7a8868f..0000000
--- a/y2012/joystick_reader.cc
+++ /dev/null
@@ -1,170 +0,0 @@
-#include <unistd.h>
-
-#include <cmath>
-#include <cstdio>
-#include <cstring>
-
-#include "aos/actions/actions.h"
-#include "aos/events/shm_event_loop.h"
-#include "aos/init.h"
-#include "aos/logging/logging.h"
-#include "aos/time/time.h"
-#include "frc971/control_loops/drivetrain/drivetrain_goal_generated.h"
-#include "frc971/input/driver_station_data.h"
-#include "frc971/input/joystick_input.h"
-#include "y2012/control_loops/accessories/accessories_generated.h"
-
-using ::frc971::input::driver_station::ButtonLocation;
-using ::frc971::input::driver_station::ControlBit;
-using ::frc971::input::driver_station::JoystickAxis;
-
-#define OLD_DS 0
-
-namespace y2012 {
-namespace input {
-namespace joysticks {
-
-const JoystickAxis kSteeringWheel(1, 1), kDriveThrottle(2, 2);
-const ButtonLocation kShiftHigh(2, 3), kShiftLow(2, 1);
-const ButtonLocation kQuickTurn(1, 5);
-
-const ButtonLocation kCatch(3, 10);
-
-#if OLD_DS
-const ButtonLocation kFire(3, 11);
-const ButtonLocation kUnload(1, 4);
-const ButtonLocation kReload(1, 2);
-
-const ButtonLocation kRollersOut(3, 12);
-const ButtonLocation kRollersIn(3, 7);
-
-const ButtonLocation kTuck(3, 9);
-const ButtonLocation kIntakePosition(3, 8);
-const ButtonLocation kIntakeOpenPosition(3, 10);
-const ButtonLocation kVerticalTuck(3, 1);
-const JoystickAxis kFlipRobot(3, 3);
-
-const ButtonLocation kLongShot(3, 5);
-const ButtonLocation kCloseShot(3, 2);
-const ButtonLocation kFenderShot(3, 3);
-const ButtonLocation kTrussShot(2, 11);
-const ButtonLocation kHumanPlayerShot(3, 2);
-#else
-const ButtonLocation kFire(3, 9);
-const ButtonLocation kUnload(1, 4);
-const ButtonLocation kReload(1, 2);
-
-const ButtonLocation kRollersOut(3, 8);
-const ButtonLocation kRollersIn(3, 3);
-
-const ButtonLocation kTuck(3, 4);
-const ButtonLocation kIntakePosition(3, 5);
-const ButtonLocation kIntakeOpenPosition(3, 11);
-const ButtonLocation kVerticalTuck(2, 6);
-const JoystickAxis kFlipRobot(3, 3);
-
-const ButtonLocation kLongShot(3, 7);
-const ButtonLocation kCloseShot(3, 6);
-const ButtonLocation kFenderShot(3, 2);
-const ButtonLocation kTrussShot(2, 11);
-const ButtonLocation kHumanPlayerShot(3, 1);
-#endif
-
-const ButtonLocation kUserLeft(2, 7);
-const ButtonLocation kUserRight(2, 10);
-
-const JoystickAxis kAdjustClawGoal(3, 2);
-const JoystickAxis kAdjustClawSeparation(3, 1);
-
-class Reader : public ::frc971::input::JoystickInput {
- public:
- Reader(::aos::EventLoop *event_loop)
- : ::frc971::input::JoystickInput(event_loop),
- drivetrain_goal_sender_(
- event_loop->MakeSender<::frc971::control_loops::drivetrain::Goal>(
- "/drivetrain")),
- accessories_goal_sender_(
- event_loop
- ->MakeSender<::y2012::control_loops::accessories::Message>(
- "/accessories")),
- is_high_gear_(false) {}
-
- void RunIteration(
- const ::frc971::input::driver_station::Data &data) override {
- if (!data.GetControlBit(ControlBit::kAutonomous)) {
- HandleDrivetrain(data);
- HandleTeleop(data);
- }
- }
-
- void HandleDrivetrain(const ::frc971::input::driver_station::Data &data) {
- const double wheel = -data.GetAxis(kSteeringWheel);
- const double throttle = -data.GetAxis(kDriveThrottle);
- if (data.PosEdge(kShiftLow)) {
- is_high_gear_ = false;
- }
- if (data.PosEdge(kShiftHigh)) {
- is_high_gear_ = true;
- }
- auto builder = drivetrain_goal_sender_.MakeBuilder();
- frc971::control_loops::drivetrain::Goal::Builder goal_builder =
- builder.MakeBuilder<frc971::control_loops::drivetrain::Goal>();
- goal_builder.add_wheel(wheel);
- goal_builder.add_throttle(throttle);
- goal_builder.add_highgear(is_high_gear_);
- goal_builder.add_quickturn(data.IsPressed(kQuickTurn));
-
- if (builder.Send(goal_builder.Finish()) !=
- aos::RawSender::Error::kOk) {
- AOS_LOG(WARNING, "sending stick values failed\n");
- }
- }
-
- void HandleTeleop(const ::frc971::input::driver_station::Data &data) {
- auto builder = accessories_goal_sender_.MakeBuilder();
- flatbuffers::Offset<flatbuffers::Vector<uint8_t>> solenoids_offset =
- builder.fbb()->CreateVector<uint8_t>({data.IsPressed(kLongShot),
- data.IsPressed(kCloseShot),
- data.IsPressed(kFenderShot)});
-
- flatbuffers::Offset<flatbuffers::Vector<double>> sticks_offset =
- builder.fbb()->CreateVector<double>(
- {data.GetAxis(kAdjustClawGoal),
- data.GetAxis(kAdjustClawSeparation)});
-
- y2012::control_loops::accessories::Message::Builder message_builder =
- builder.MakeBuilder<y2012::control_loops::accessories::Message>();
- message_builder.add_solenoids(solenoids_offset);
- message_builder.add_sticks(sticks_offset);
- if (builder.Send(message_builder.Finish()) !=
- aos::RawSender::Error::kOk) {
- AOS_LOG(WARNING, "sending accessories goal failed\n");
- }
- }
-
- private:
- ::aos::Sender<::frc971::control_loops::drivetrain::Goal>
- drivetrain_goal_sender_;
- ::aos::Sender<::y2012::control_loops::accessories::Message>
- accessories_goal_sender_;
-
- bool is_high_gear_;
-};
-
-} // namespace joysticks
-} // namespace input
-} // namespace y2012
-
-int main(int argc, char **argv) {
- ::aos::InitGoogle(&argc, &argv);
-
- aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig("config.json");
-
- ::aos::ShmEventLoop event_loop(&config.message());
- ::y2012::input::joysticks::Reader reader(&event_loop);
-
- event_loop.Run();
-
- return 0;
-}
diff --git a/y2012/wpilib_interface.cc b/y2012/wpilib_interface.cc
deleted file mode 100644
index e3234de..0000000
--- a/y2012/wpilib_interface.cc
+++ /dev/null
@@ -1,291 +0,0 @@
-#include <unistd.h>
-
-#include <chrono>
-#include <cinttypes>
-#include <cstdio>
-#include <cstring>
-#include <functional>
-#include <memory>
-#include <mutex>
-#include <thread>
-
-#include "frc971/wpilib/ahal/AnalogInput.h"
-#include "frc971/wpilib/ahal/Compressor.h"
-#include "frc971/wpilib/ahal/DigitalGlitchFilter.h"
-#include "frc971/wpilib/ahal/DriverStation.h"
-#include "frc971/wpilib/ahal/Encoder.h"
-#include "frc971/wpilib/ahal/PowerDistributionPanel.h"
-#include "frc971/wpilib/ahal/Relay.h"
-#include "frc971/wpilib/ahal/Talon.h"
-#include "frc971/wpilib/wpilib_robot_base.h"
-#undef ERROR
-
-#include "aos/events/shm_event_loop.h"
-#include "aos/init.h"
-#include "aos/logging/logging.h"
-#include "aos/stl_mutex/stl_mutex.h"
-#include "aos/time/time.h"
-#include "aos/util/log_interval.h"
-#include "aos/util/phased_loop.h"
-#include "aos/util/wrapping_counter.h"
-#include "frc971/control_loops/drivetrain/drivetrain_output_generated.h"
-#include "frc971/control_loops/drivetrain/drivetrain_position_generated.h"
-#include "frc971/input/robot_state_generated.h"
-#include "frc971/wpilib/buffered_pcm.h"
-#include "frc971/wpilib/buffered_solenoid.h"
-#include "frc971/wpilib/dma.h"
-#include "frc971/wpilib/dma_edge_counting.h"
-#include "frc971/wpilib/drivetrain_writer.h"
-#include "frc971/wpilib/encoder_and_potentiometer.h"
-#include "frc971/wpilib/interrupt_edge_counting.h"
-#include "frc971/wpilib/joystick_sender.h"
-#include "frc971/wpilib/logging_generated.h"
-#include "frc971/wpilib/loop_output_handler.h"
-#include "frc971/wpilib/sensor_reader.h"
-#include "y2012/control_loops/accessories/accessories_generated.h"
-#include "y2012/control_loops/control_loops_generated.h"
-
-namespace accessories = ::y2012::control_loops::accessories;
-using namespace frc;
-using std::make_unique;
-
-namespace y2012 {
-namespace wpilib {
-
-double drivetrain_translate(int32_t in) {
- return -static_cast<double>(in) / (256.0 /*cpr*/ * 4.0 /*4x*/) * 1 *
- (3.5 /*wheel diameter*/ * 2.54 / 100.0 * M_PI) * 2.0 / 2.0;
-}
-
-double drivetrain_velocity_translate(double in) {
- return (1.0 / in) / 256.0 /*cpr*/ * 1 *
- (3.5 /*wheel diameter*/ * 2.54 / 100.0 * M_PI) * 2.0 / 2.0;
-}
-
-class SensorReader : public ::frc971::wpilib::SensorReader {
- public:
- SensorReader(::aos::ShmEventLoop *event_loop)
- : ::frc971::wpilib::SensorReader(event_loop),
- accessories_position_sender_(
- event_loop->MakeSender<::aos::control_loops::Position>(
- "/accessories")),
- drivetrain_position_sender_(
- event_loop
- ->MakeSender<::frc971::control_loops::drivetrain::Position>(
- "/drivetrain")) {}
-
- void RunIteration() {
- {
- auto builder = drivetrain_position_sender_.MakeBuilder();
-
- frc971::control_loops::drivetrain::Position::Builder position_builder =
- builder.MakeBuilder<frc971::control_loops::drivetrain::Position>();
- position_builder.add_right_encoder(
- drivetrain_translate(drivetrain_right_encoder_->GetRaw()));
- position_builder.add_left_encoder(
- -drivetrain_translate(drivetrain_left_encoder_->GetRaw()));
- position_builder.add_left_speed(
- drivetrain_velocity_translate(drivetrain_left_encoder_->GetPeriod()));
- position_builder.add_right_speed(drivetrain_velocity_translate(
- drivetrain_right_encoder_->GetPeriod()));
-
- builder.CheckOk(builder.Send(position_builder.Finish()));
- }
-
- {
- auto builder = accessories_position_sender_.MakeBuilder();
- builder.CheckOk(builder.Send(
- builder.MakeBuilder<::aos::control_loops::Position>().Finish()));
- }
- }
-
- private:
- ::aos::Sender<::aos::control_loops::Position> accessories_position_sender_;
- ::aos::Sender<::frc971::control_loops::drivetrain::Position>
- drivetrain_position_sender_;
-};
-
-class SolenoidWriter {
- public:
- SolenoidWriter(::aos::ShmEventLoop *event_loop,
- const ::std::unique_ptr<::frc971::wpilib::BufferedPcm> &pcm)
- : event_loop_(event_loop),
- pcm_(pcm),
- drivetrain_fetcher_(
- event_loop_
- ->MakeFetcher<::frc971::control_loops::drivetrain::Output>(
- "/drivetrain")),
- accessories_fetcher_(
- event_loop_
- ->MakeFetcher<::y2012::control_loops::accessories::Message>(
- "/accessories")),
- pneumatics_to_log_sender_(
- event_loop->MakeSender<::frc971::wpilib::PneumaticsToLog>("/aos")) {
- event_loop->set_name("Solenoids");
- event_loop_->SetRuntimeRealtimePriority(27);
-
- event_loop_->AddPhasedLoop([this](int iterations) { Loop(iterations); },
- ::std::chrono::milliseconds(20),
- ::std::chrono::milliseconds(1));
- }
-
- void set_drivetrain_high(
- ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
- drivetrain_high_ = ::std::move(s);
- }
-
- void set_drivetrain_low(
- ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
- drivetrain_low_ = ::std::move(s);
- }
-
- void set_s1(::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
- s1_ = ::std::move(s);
- }
-
- void set_s2(::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
- s2_ = ::std::move(s);
- }
-
- void set_s3(::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
- s3_ = ::std::move(s);
- }
-
- void Loop(const int iterations) {
- if (iterations != 1) {
- AOS_LOG(DEBUG, "Solenoids skipped %d iterations\n", iterations - 1);
- }
-
- {
- accessories_fetcher_.Fetch();
- if (accessories_fetcher_.get()) {
- s1_->Set(accessories_fetcher_->solenoids()->Get(0));
- s2_->Set(accessories_fetcher_->solenoids()->Get(1));
- s3_->Set(accessories_fetcher_->solenoids()->Get(2));
- }
- }
-
- {
- drivetrain_fetcher_.Fetch();
- if (drivetrain_fetcher_.get()) {
- const bool high = drivetrain_fetcher_->left_high() ||
- drivetrain_fetcher_->right_high();
- drivetrain_high_->Set(high);
- drivetrain_low_->Set(!high);
- }
- }
-
- {
- auto builder = pneumatics_to_log_sender_.MakeBuilder();
-
- ::frc971::wpilib::PneumaticsToLog::Builder to_log_builder =
- builder.MakeBuilder<frc971::wpilib::PneumaticsToLog>();
- pcm_->Flush();
- to_log_builder.add_read_solenoids(pcm_->GetAll());
- builder.CheckOk(builder.Send(to_log_builder.Finish()));
- }
- }
-
- private:
- ::aos::EventLoop *event_loop_;
-
- const ::std::unique_ptr<::frc971::wpilib::BufferedPcm> &pcm_;
-
- ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> drivetrain_high_;
- ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> drivetrain_low_;
- ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s1_, s2_, s3_;
-
- ::std::unique_ptr<Compressor> compressor_;
-
- ::aos::Fetcher<::frc971::control_loops::drivetrain::Output>
- drivetrain_fetcher_;
- ::aos::Fetcher<::y2012::control_loops::accessories::Message>
- accessories_fetcher_;
-
- aos::Sender<::frc971::wpilib::PneumaticsToLog> pneumatics_to_log_sender_;
-};
-
-class AccessoriesWriter : public ::frc971::wpilib::LoopOutputHandler<
- control_loops::accessories::Message> {
- public:
- AccessoriesWriter(::aos::EventLoop *event_loop)
- : ::frc971::wpilib::LoopOutputHandler<
- control_loops::accessories::Message>(event_loop, "/accessories") {}
-
- void set_talon1(::std::unique_ptr<Talon> t) { talon1_ = ::std::move(t); }
-
- void set_talon2(::std::unique_ptr<Talon> t) { talon2_ = ::std::move(t); }
-
- private:
- virtual void Write(
- const control_loops::accessories::Message &output) override {
- talon1_->SetSpeed(output.sticks()->Get(0));
- talon2_->SetSpeed(output.sticks()->Get(1));
- }
-
- virtual void Stop() override {
- AOS_LOG(WARNING, "shooter output too old\n");
- talon1_->SetDisabled();
- talon2_->SetDisabled();
- }
-
- ::std::unique_ptr<Talon> talon1_, talon2_;
-};
-
-class WPILibRobot : public ::frc971::wpilib::WPILibRobotBase {
- public:
- ::std::unique_ptr<Encoder> make_encoder(int index) {
- return make_unique<Encoder>(10 + index * 2, 11 + index * 2, false,
- Encoder::k4X);
- }
-
- void Run() override {
- aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig("config.json");
-
- // Thread 1.
- ::aos::ShmEventLoop joystick_sender_event_loop(&config.message());
- ::frc971::wpilib::JoystickSender joystick_sender(
- &joystick_sender_event_loop);
- AddLoop(&joystick_sender_event_loop);
-
- // Thread 2.
- ::aos::ShmEventLoop sensor_reader_event_loop(&config.message());
- SensorReader sensor_reader(&sensor_reader_event_loop);
- sensor_reader.set_drivetrain_left_encoder(make_encoder(0));
- sensor_reader.set_drivetrain_right_encoder(make_encoder(1));
- AddLoop(&sensor_reader_event_loop);
-
- // Thread 3.
- ::aos::ShmEventLoop output_event_loop(&config.message());
- ::frc971::wpilib::DrivetrainWriter drivetrain_writer(&output_event_loop);
- drivetrain_writer.set_left_controller0(
- ::std::unique_ptr<Talon>(new Talon(3)), true);
- drivetrain_writer.set_right_controller0(
- ::std::unique_ptr<Talon>(new Talon(4)), false);
-
- ::y2012::wpilib::AccessoriesWriter accessories_writer(&output_event_loop);
- accessories_writer.set_talon1(::std::unique_ptr<Talon>(new Talon(5)));
- accessories_writer.set_talon2(::std::unique_ptr<Talon>(new Talon(6)));
- AddLoop(&output_event_loop);
-
- // Thread 4.
- ::aos::ShmEventLoop solenoid_writer_event_loop(&config.message());
- ::std::unique_ptr<::frc971::wpilib::BufferedPcm> pcm(
- new ::frc971::wpilib::BufferedPcm());
- SolenoidWriter solenoid_writer(&solenoid_writer_event_loop, pcm);
- solenoid_writer.set_drivetrain_high(pcm->MakeSolenoid(0));
- solenoid_writer.set_drivetrain_low(pcm->MakeSolenoid(2));
- solenoid_writer.set_s1(pcm->MakeSolenoid(1));
- solenoid_writer.set_s2(pcm->MakeSolenoid(3));
- solenoid_writer.set_s3(pcm->MakeSolenoid(4));
- AddLoop(&solenoid_writer_event_loop);
-
- RunLoops();
- }
-};
-
-} // namespace wpilib
-} // namespace y2012
-
-AOS_ROBOT_CLASS(::y2012::wpilib::WPILibRobot);