Add flatbuffers for swerve output and position
Signed-off-by: Maxwell Henderson <maxwell.henderson@mailbox.org>
Change-Id: I3d6f325cbe91a7acd13027f56e29a2b5a80f99d0
diff --git a/frc971/control_loops/drivetrain/swerve/BUILD b/frc971/control_loops/drivetrain/swerve/BUILD
new file mode 100644
index 0000000..06ba36a
--- /dev/null
+++ b/frc971/control_loops/drivetrain/swerve/BUILD
@@ -0,0 +1,15 @@
+load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
+
+package(default_visibility = ["//visibility:public"])
+
+flatbuffer_cc_library(
+ name = "swerve_drivetrain_output_fbs",
+ srcs = ["swerve_drivetrain_output.fbs"],
+ gen_reflections = 1,
+)
+
+flatbuffer_cc_library(
+ name = "swerve_drivetrain_position_fbs",
+ srcs = ["swerve_drivetrain_position.fbs"],
+ gen_reflections = 1,
+)
diff --git a/frc971/control_loops/drivetrain/swerve/swerve_drivetrain_output.fbs b/frc971/control_loops/drivetrain/swerve/swerve_drivetrain_output.fbs
new file mode 100644
index 0000000..43ba0ed
--- /dev/null
+++ b/frc971/control_loops/drivetrain/swerve/swerve_drivetrain_output.fbs
@@ -0,0 +1,16 @@
+namespace frc971.control_loops.drivetrain.swerve;
+
+table SwerveModuleOutput {
+ // Current in Amps.
+ rotation_current:double (id: 0);
+ translation_current:double (id: 1);
+}
+
+table Output {
+ front_left_output:SwerveModuleOutput (id: 0);
+ front_right_output:SwerveModuleOutput (id: 1);
+ back_left_output:SwerveModuleOutput (id: 2);
+ back_right_output:SwerveModuleOutput (id: 3);
+}
+
+root_type Output;
diff --git a/frc971/control_loops/drivetrain/swerve/swerve_drivetrain_position.fbs b/frc971/control_loops/drivetrain/swerve/swerve_drivetrain_position.fbs
new file mode 100644
index 0000000..e0f5571
--- /dev/null
+++ b/frc971/control_loops/drivetrain/swerve/swerve_drivetrain_position.fbs
@@ -0,0 +1,22 @@
+namespace frc971.control_loops.drivetrain.swerve;
+
+table SwerveModulePosition {
+ // Rotation in radians
+ rotation_encoder:double (id: 0);
+ // Translation in meters
+ translation_encoder:double (id: 1);
+
+ // Speed in radians/s
+ rotation_speed:double (id: 2);
+ // Speed in m/s
+ translation_speed:double (id: 3);
+}
+
+table Position {
+ front_left_position:SwerveModulePosition (id: 0);
+ front_right_position:SwerveModulePosition (id: 1);
+ back_left_position:SwerveModulePosition (id: 2);
+ back_right_position:SwerveModulePosition (id: 3);
+}
+
+root_type Position;