Added comment to make vision distance averaging more readable.
Change-Id: I8e542f50f27d6e259361aef28caf57c548ef6d80
diff --git a/y2017/control_loops/superstructure/vision_distance_average.h b/y2017/control_loops/superstructure/vision_distance_average.h
index 7cd1ee1..ed0664e 100644
--- a/y2017/control_loops/superstructure/vision_distance_average.h
+++ b/y2017/control_loops/superstructure/vision_distance_average.h
@@ -12,13 +12,17 @@
namespace control_loops {
namespace superstructure {
+namespace chrono = ::std::chrono;
+
// Averages out the distance from the vision system by a factor of 25.
class VisionDistanceAverage {
public:
// Call on every tick of the control loop to update the state.
void Tick(::aos::monotonic_clock::time_point monotonic_now,
const vision::VisionStatus *vision_status) {
- auto cull_time = monotonic_now - std::chrono::seconds(2);
+ constexpr chrono::seconds kCullTimeDelta = chrono::seconds(2);
+ auto cull_time = monotonic_now - kCullTimeDelta;
+ // Delete data that is older than kCullTimeDelta seconds ago.
while (data_.size() > 0 && data_[0].time < cull_time) {
data_.Shift();
cached_value_ = ComputeValue();