added support for both drivetrains with the same code
Previously, we were just switching back and forth manually, which
doesn't work very well. The python code for (both) drivetrain loops now
generates constants for both robots and frc971/constants knows which one
to give the actual drivetrain control loop code.
Various other cleanups to things that were so hard to read it made it
difficult to figure out how to do this too.
diff --git a/frc971/control_loops/state_feedback_loop.h b/frc971/control_loops/state_feedback_loop.h
index 4c35419..38ca89c 100644
--- a/frc971/control_loops/state_feedback_loop.h
+++ b/frc971/control_loops/state_feedback_loop.h
@@ -5,9 +5,6 @@
#include <vector>
-// Stupid vxworks system headers define it which blows up Eigen...
-#undef m_data
-
#include "Eigen/Dense"
template <int number_of_states, int number_of_inputs, int number_of_outputs>
@@ -223,15 +220,14 @@
Eigen::Matrix<double, number_of_outputs, 1> U_ff;
Eigen::Matrix<double, number_of_outputs, 1> Y;
- const StateFeedbackController<
- number_of_states, number_of_inputs, number_of_outputs>
- &controller() const {
+ const StateFeedbackController<number_of_states, number_of_inputs,
+ number_of_outputs> &controller() const {
return *controllers_[controller_index_];
}
- const StateFeedbackController<
- number_of_states, number_of_inputs, number_of_outputs>
- &controller(int index) const {
+ const StateFeedbackController<number_of_states, number_of_inputs,
+ number_of_outputs> &controller(
+ int index) const {
return *controllers_[index];
}
@@ -244,22 +240,17 @@
Y.setZero();
}
- StateFeedbackLoop(
- const StateFeedbackController<number_of_states, number_of_inputs,
- number_of_outputs> &controller)
+ StateFeedbackLoop(const StateFeedbackController<
+ number_of_states, number_of_inputs, number_of_outputs> &controller)
: controller_index_(0) {
- controllers_.push_back(
- new StateFeedbackController<number_of_states, number_of_inputs,
- number_of_outputs>(controller));
+ controllers_.push_back(new StateFeedbackController<
+ number_of_states, number_of_inputs, number_of_outputs>(controller));
Reset();
}
- StateFeedbackLoop(
- const ::std::vector<StateFeedbackController<
- number_of_states, number_of_inputs,
- number_of_outputs> *> &controllers)
- : controllers_(controllers),
- controller_index_(0) {
+ StateFeedbackLoop(const ::std::vector<StateFeedbackController<
+ number_of_states, number_of_inputs, number_of_outputs> *> &controllers)
+ : controllers_(controllers), controller_index_(0) {
Reset();
}