Sundry fixes to statespace controllers
1) Instead of taking a pointer to arguments, take a r value reference
and move them. Much more C++ like.
2) Some controllers don't want a fixed C, D, Q, and R. There is no harm
in allowing those to be passed in. Expose that intermediate form.
3) We had uninitialized state variables. Initialize them to something
sane.
Change-Id: I00f90af7bb53bfd3385e3ebfda1c3c31600b7001
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/frc971/control_loops/python/control_loop.py b/frc971/control_loops/python/control_loop.py
index 74141c1..cea1fdd 100644
--- a/frc971/control_loops/python/control_loop.py
+++ b/frc971/control_loops/python/control_loop.py
@@ -216,7 +216,7 @@
fd.write(' plants[%d] = ::std::unique_ptr<%s>(new %s(%s));\n'
% (index, self._PlantCoeffType(),
self._PlantCoeffType(), loop.PlantFunction()))
- fd.write(' return %s(&plants);\n' % self._PlantType())
+ fd.write(' return %s(std::move(plants));\n' % self._PlantType())
fd.write('}\n\n')
fd.write('%s Make%sController() {\n' % (self._ControllerType(),
@@ -229,7 +229,8 @@
' controllers[%d] = ::std::unique_ptr<%s>(new %s(%s));\n'
% (index, self._ControllerCoeffType(),
self._ControllerCoeffType(), loop.ControllerFunction()))
- fd.write(' return %s(&controllers);\n' % self._ControllerType())
+ fd.write(' return %s(std::move(controllers));\n' %
+ self._ControllerType())
fd.write('}\n\n')
fd.write('%s Make%sObserver() {\n' % (self._ObserverType(),
@@ -241,7 +242,8 @@
' observers[%d] = ::std::unique_ptr<%s>(new %s(%s));\n'
% (index, self._ObserverCoeffType(),
self._ObserverCoeffType(), loop.ObserverFunction()))
- fd.write(' return %s(&observers);\n' % self._ObserverType())
+ fd.write(
+ ' return %s(std::move(observers));\n' % self._ObserverType())
fd.write('}\n\n')
fd.write('%s Make%sLoop() {\n' % (self._LoopType(),