The Pi-Bug code for walking

The code for the Pi-Bug robot has been designed to provide the same interface as the Rover-Pi robot so that they can be interchanged easily. You should notice that each class consists of the same four functions (__init__(), off(), drive(), and cmd()). The __init__() function defines the set of pins we will control, the steptime value of the walking action (this time, the gap between movements), and the previously defined servo module.

Once again, we have an off() function that provides a function that can be called to set the servos in their middle positions (which is very useful for when you need to fit the legs in position, as described previously in the home position). The off() function uses the drive() function ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.