added support for different drivetrain gear ratios
We went down to 2 CIMs on the practice bot and reduce the pinion size,
so the code has to know how to deal with that.
diff --git a/frc971/input/gyro_board_reader.cc b/frc971/input/gyro_board_reader.cc
index de60cb1..817efa9 100644
--- a/frc971/input/gyro_board_reader.cc
+++ b/frc971/input/gyro_board_reader.cc
@@ -15,6 +15,8 @@
#include "frc971/input/gyro_board_data.h"
#include "gyro_board/src/libusb-driver/libusb_wrap.h"
#include "frc971/queues/GyroAngle.q.h"
+#include "frc971/constants.h"
+#include "aos/common/messages/RobotState.q.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
@@ -31,8 +33,17 @@
namespace {
inline double drivetrain_translate(int32_t in) {
+ int pinion_size;
+ if (::aos::robot_state.get() == NULL) {
+ if (!::aos::robot_state.FetchNext()) {
+ LOG(WARNING, "couldn't fetch robot state\n");
+ return 0;
+ }
+ }
+ if (!constants::drivetrain_gearbox_pinion(&pinion_size)) return 0;
return static_cast<double>(in) / (256.0 /*cpr*/ * 4.0 /*quad*/) *
- (19.0 / 50.0) /*output reduction*/ * (64.0 / 24.0) /*encoder gears*/ *
+ (pinion_size / 50.0) /*output reduction*/ *
+ (64.0 / 24.0) /*encoder gears*/ *
(3.5 /*wheel diameter*/ * 2.54 / 100.0 * M_PI);
}
diff --git a/frc971/input/input.gyp b/frc971/input/input.gyp
index 5e08a20..1758e95 100644
--- a/frc971/input/input.gyp
+++ b/frc971/input/input.gyp
@@ -61,6 +61,8 @@
'<(AOS)/build/aos.gyp:logging',
'<(AOS)/common/common.gyp:time',
'<(AOS)/common/common.gyp:timing',
+ '<(DEPTH)/frc971/frc971.gyp:common',
+ '<(AOS)/common/messages/messages.gyp:aos_queues',
],
},
{