This chapter will teach you how to move the robot in different directions using the Python code to control the power given to DC motors. The left and right wheels of the robot each have a dedicated motor attached to them. Controlling the motors makes a whole array of movements possible. Python functions will be generated for each of the main movement operations to create an easy-to-use and readable set of methods to control the robot’s movements. Once all these functions have been implemented, a number of refactoring techniques will be applied to simplify and consolidate the code base.
Robot chassis kits are a great way to build mobile robots. In the previous chapter, we saw how the Raspberry Pi provides computing power for the robot and how the CRICKIT HAT add-on controls connected motors. The chassis kit provides the body, motors, and wheels to get your robot moving around. There are many different robot chassis kits that can be used with the Raspberry Pi. The one recommended in this book is an inexpensive and flexible option that lets you build many different robot configurations. The kit comes with the following main parts: