Chapter 11: Programming Encoders with Python
It is useful in robotics to sense the movements of motor shafts and wheels. We drove a robot along a path back in Chapter 7, Drive and Turn – Moving Motors with Python, but it's unlikely that it has stayed on course. Detecting this and traveling a specific distance is useful in creating behaviors. This chapter investigates the choice made by the sensor, as well as how to program the robot to move in a straight line and for a particular distance. We then look at how to make a specific turn. Please note that this chapter does contain math. But don't worry, you'll follow along easily.
In this chapter, you will learn about the following topics:
- Measuring the distance traveled with encoders
- Attaching encoders to the robot
- Detecting the distance traveled in Python
- Driving in a straight line
- Driving a specific distance
- Making a specific turn