Add y2024 intake constants
Signed-off-by: Niko Sohmers <nikolai@sohmers.com>
Change-Id: I41914cb76b7d3f79b7d9a0f0f2bab1632fa583be
diff --git a/y2024/control_loops/python/BUILD b/y2024/control_loops/python/BUILD
index 4451fb9..f92b484 100644
--- a/y2024/control_loops/python/BUILD
+++ b/y2024/control_loops/python/BUILD
@@ -45,6 +45,22 @@
],
)
+py_binary(
+ name = "intake_pivot",
+ srcs = [
+ "intake_pivot.py",
+ ],
+ legacy_create_init = False,
+ target_compatible_with = ["@platforms//cpu:x86_64"],
+ deps = [
+ ":python_init",
+ "//frc971/control_loops/python:angular_system",
+ "//frc971/control_loops/python:controls",
+ "@pip//glog",
+ "@pip//python_gflags",
+ ],
+)
+
py_library(
name = "python_init",
srcs = ["__init__.py"],
diff --git a/y2024/control_loops/python/intake_pivot.py b/y2024/control_loops/python/intake_pivot.py
new file mode 100644
index 0000000..9e7543b
--- /dev/null
+++ b/y2024/control_loops/python/intake_pivot.py
@@ -0,0 +1,56 @@
+#!/usr/bin/python3
+
+from aos.util.trapezoid_profile import TrapezoidProfile
+from frc971.control_loops.python import control_loop
+from frc971.control_loops.python import angular_system
+from frc971.control_loops.python import controls
+import numpy
+import sys
+from matplotlib import pylab
+import gflags
+import glog
+
+FLAGS = gflags.FLAGS
+
+try:
+ gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
+except gflags.DuplicateFlagError:
+ pass
+
+kIntakePivot = angular_system.AngularSystemParams(
+ name='IntakePivot',
+ motor=control_loop.KrakenFOC(),
+ # TODO(Niko): Change gear ratios when we have all of them
+ G=0.02,
+ J=0.34,
+ q_pos=0.40,
+ q_vel=20.0,
+ kalman_q_pos=0.12,
+ kalman_q_vel=2.0,
+ kalman_q_voltage=4.0,
+ kalman_r_position=0.05,
+ radius=13 * 0.0254)
+
+
+def main(argv):
+ if FLAGS.plot:
+ R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
+ angular_system.PlotKick(kIntakePivot, R)
+ angular_system.PlotMotion(kIntakePivot, R)
+ return
+ if len(argv) != 7:
+ glog.fatal(
+ 'Expected .h file name and .cc file name for the intake pivot and integral intake pivot.'
+ )
+ else:
+ namespaces = [
+ 'y2024', 'control_loops', 'superstructure', 'intake_pivot'
+ ]
+ angular_system.WriteAngularSystem(kIntakePivot, argv[1:4], argv[4:7],
+ namespaces)
+
+
+if __name__ == '__main__':
+ argv = FLAGS(sys.argv)
+ glog.init()
+ sys.exit(main(argv))
\ No newline at end of file
diff --git a/y2024/control_loops/superstructure/intake_pivot/BUILD b/y2024/control_loops/superstructure/intake_pivot/BUILD
new file mode 100644
index 0000000..18c6963
--- /dev/null
+++ b/y2024/control_loops/superstructure/intake_pivot/BUILD
@@ -0,0 +1,42 @@
+package(default_visibility = ["//y2024:__subpackages__"])
+
+genrule(
+ name = "genrule_intake_pivot",
+ outs = [
+ "intake_pivot_plant.h",
+ "intake_pivot_plant.cc",
+ "intake_pivot_plant.json",
+ "integral_intake_pivot_plant.h",
+ "integral_intake_pivot_plant.cc",
+ "integral_intake_pivot_plant.json",
+ ],
+ cmd = "$(location //y2024/control_loops/python:intake_pivot) $(OUTS)",
+ target_compatible_with = ["@platforms//os:linux"],
+ tools = [
+ "//y2024/control_loops/python:intake_pivot",
+ ],
+)
+
+cc_library(
+ name = "intake_pivot_plants",
+ srcs = [
+ "intake_pivot_plant.cc",
+ "integral_intake_pivot_plant.cc",
+ ],
+ hdrs = [
+ "intake_pivot_plant.h",
+ "integral_intake_pivot_plant.h",
+ ],
+ target_compatible_with = ["@platforms//os:linux"],
+ visibility = ["//visibility:public"],
+ deps = [
+ "//frc971/control_loops:hybrid_state_feedback_loop",
+ "//frc971/control_loops:state_feedback_loop",
+ ],
+)
+
+filegroup(
+ name = "intake_pivot_json",
+ srcs = ["integral_intake_pivot_plant.json"],
+ visibility = ["//visibility:public"],
+)
diff --git a/y2024/control_loops/superstructure/superstructure_can_position.fbs b/y2024/control_loops/superstructure/superstructure_can_position.fbs
index 04daa2b..46f638c 100644
--- a/y2024/control_loops/superstructure/superstructure_can_position.fbs
+++ b/y2024/control_loops/superstructure/superstructure_can_position.fbs
@@ -3,8 +3,20 @@
namespace y2024.control_loops.superstructure;
table CANPosition {
+ // The timestamp of the measurement on the canivore clock in nanoseconds
+ // This will have less jitter than the
+ // timestamp of the message being sent out.
+ timestamp:int64 (id: 0);
+
+ // The ctre::phoenix::StatusCode of the measurement
+ // Should be OK = 0
+ status:int (id: 1);
+
// CAN Position of the roller falcon
- intake_roller:frc971.control_loops.CANTalonFX (id: 0);
+ intake_roller:frc971.control_loops.CANTalonFX (id: 2);
+
+ // CAN Position of the intake pivot falcon
+ intake_pivot:frc971.control_loops.CANTalonFX (id: 3);
}
root_type CANPosition;
\ No newline at end of file