Detecting the distance traveled in Python
Using encoder sensor devices requires us to count pulses. In this section, we will create code to turn on the motors and count pulses for a while. The code validates that the sensors are connected correctly. We then take this code and make it part of the robot class as a behavior.
Introducing logging
So far in our Python code, we have been using print to output information to see what our robot is doing. This works, but prints can become overwhelming if we print everything we might want to inspect. Logging allows us to still display information, but we can control how much. By importing the logging module, we can take advantage of this.
First, there are logging levels, with debug, info, warning, and error. While fixing problems or initially developing, debug is useful – it can show everything – while info is used to show a little less than that. The warning and error levels are reserved only for those kinds of problems...