Add interpolation table to y2017 constants
The next patch will make use of this for determining the actual hood
and turret angles.
Change-Id: I9f956306b5795652148cdfbbe588c598d9c72a43
diff --git a/frc971/shooter_interpolation/interpolation.cc b/frc971/shooter_interpolation/interpolation.cc
index 71989ff..f558acd 100644
--- a/frc971/shooter_interpolation/interpolation.cc
+++ b/frc971/shooter_interpolation/interpolation.cc
@@ -21,9 +21,9 @@
} // namespace
InterpolationTable::InterpolationTable(
- ::std::vector<::std::pair<double, ShotParams>> interpolation_table) {
- interpolation_table_ = ::std::move(interpolation_table);
- ::std::sort(interpolation_table_.begin(), interpolation_table_.end(),
+ const ::std::vector<::std::pair<double, ShotParams>> &table)
+ : table_(table) {
+ ::std::sort(table_.begin(), table_.end(),
[](const ::std::pair<double, ShotParams> &a,
const ::std::pair<double, ShotParams> &b) {
return a.first < b.first;
@@ -33,14 +33,13 @@
ShotParams InterpolationTable::GetShooterData(double distance) {
// Points to to the smallest item such that it->first >= dist, or end() if no
// such item exists.
- auto it =
- std::lower_bound(interpolation_table_.begin(), interpolation_table_.end(),
- distance, [](const ::std::pair<double, ShotParams> &a,
- double dist) { return a.first < dist; });
- if (it == interpolation_table_.begin()) {
+ auto it = ::std::lower_bound(table_.begin(), table_.end(), distance,
+ [](const ::std::pair<double, ShotParams> &a,
+ double dist) { return a.first < dist; });
+ if (it == table_.begin()) {
return it->second;
- } else if (it == interpolation_table_.end()) {
- return interpolation_table_.back().second;
+ } else if (it == table_.end()) {
+ return table_.back().second;
} else {
auto x_a2 = it;
auto x_a1 = it - 1;