Add test comparing C++ and Python dynamics codegen
This also adds C++ enums defining the states for the physics (note that
it needs to use regular C enums to not require a static_cast to
convert to integers).
It only passes in trivial scenarios currently....
Change-Id: I97e051c896500715c1252b17723f049981f99f1d
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/frc971/control_loops/swerve/BUILD b/frc971/control_loops/swerve/BUILD
index 26828e4..2d06837 100644
--- a/frc971/control_loops/swerve/BUILD
+++ b/frc971/control_loops/swerve/BUILD
@@ -214,6 +214,7 @@
srcs = [
"physics_test.py",
],
+ data = [":cpp_dynamics.so"],
env = {
"JAX_PLATFORMS": "cpu",
},
@@ -234,6 +235,7 @@
srcs = [
"physics_test.py",
],
+ data = [":cpp_dynamics.so"],
env = {
"JAX_PLATFORMS": "cuda",
},
@@ -329,3 +331,18 @@
"@pip//pygobject",
],
)
+
+cc_binary(
+ name = "cpp_dynamics.so",
+ # Just use the python dynamics directly if you want them; this is just for testing.
+ testonly = True,
+ srcs = ["dynamics_python_bindings.cc"],
+ linkshared = True,
+ target_compatible_with = ["@platforms//os:linux"],
+ deps = [
+ ":eigen_dynamics",
+ "//third_party/python",
+ "@com_google_absl//absl/log",
+ "@com_google_absl//absl/log:check",
+ ],
+)