Allow constructing control loops from flatbuffers
The core changes here are to:
* Allow constructing StateFeedbackLoop's from flatbuffers using the
code in *state_feedback_loop_converters.*
* Add constructors to the single-dof subsystem class to make use of
this.
* Add code to control_loops.py to generate JSON files with the requisite
constants (these end up containing identical information to the
generated .cc files).
* Add interfaces to actually support the new JSON codegen to single-dof
subsystem classes.
* Convert all of the drivetrains over to generating these. This I mostly
do so that I can write a test where Iconfirm that the .cc files and
the JSON files generate exactly the same content.
Change-Id: Iceac48f25ecac96200b7bf992c8f34a15fe6800c
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/y2023_bot3/control_loops/python/drivetrain.py b/y2023_bot3/control_loops/python/drivetrain.py
index 26cb043..ac0da93 100644
--- a/y2023_bot3/control_loops/python/drivetrain.py
+++ b/y2023_bot3/control_loops/python/drivetrain.py
@@ -37,11 +37,11 @@
if FLAGS.plot:
drivetrain.PlotDrivetrainMotions(kDrivetrain)
- elif len(argv) != 5:
- print("Expected .h file name and .cc file name")
+ elif len(argv) != 7:
+ print("Expected .h, .cc, and .json filenames")
else:
# Write the generated constants out to a file.
- drivetrain.WriteDrivetrain(argv[1:3], argv[3:5], 'y2023_bot3',
+ drivetrain.WriteDrivetrain(argv[1:4], argv[4:7], 'y2023_bot3',
kDrivetrain)
diff --git a/y2023_bot3/control_loops/python/polydrivetrain.py b/y2023_bot3/control_loops/python/polydrivetrain.py
index 80e4f13..bd9dc89 100644
--- a/y2023_bot3/control_loops/python/polydrivetrain.py
+++ b/y2023_bot3/control_loops/python/polydrivetrain.py
@@ -20,10 +20,10 @@
def main(argv):
if FLAGS.plot:
polydrivetrain.PlotPolyDrivetrainMotions(drivetrain.kDrivetrain)
- elif len(argv) != 7:
- glog.fatal('Expected .h file name and .cc file name')
+ elif len(argv) != 10:
+ glog.fatal('Expected .h, .cc, and .json filenames')
else:
- polydrivetrain.WritePolyDrivetrain(argv[1:3], argv[3:5], argv[5:7],
+ polydrivetrain.WritePolyDrivetrain(argv[1:4], argv[4:7], argv[7:10],
'y2023_bot3',
drivetrain.kDrivetrain)