Coordinate delays before sensor readings so readings are all clean
Preface
IR sensor readings are averaged in a round-robin, so if the robot is moving, some of the data in the round robin will have been from previous locations/positions/orientations/etc and so the average would not accurately reflect the current readings. Some functions, like align, delay before taking readings, while others, like cell detection, don't.
Solution
-
Keep track of whenever the robot moves / otherwise does something that would "dirty" the sensor readings(no such thing🙃 ) -
Functions needing clean values call a helper which does a delay if the state is still dirty
Issues/Questions
Would align affect readings enough to consider state "dirty"?
- could assign various states of "dirtiness" and request helper is called with accuracy level required (corresponding to "dirty" levels)
- would also allow optimization by waiting less time if less accuracy is required
tl;dr
function to coordinate waiting for sensor values