Book Image

Robotics at Home with Raspberry Pi Pico

By : Danny Staple
Book Image

Robotics at Home with Raspberry Pi Pico

By: Danny Staple

Overview of this book

The field of robotics is expanding, and this is the perfect time to learn how to create robots at home for different purposes. This book will help you take your first steps in planning, building, and programming a robot with Raspberry Pi Pico, an impressive controller bursting with I/O capabilities. After a quick tour of Pico, you’ll begin designing a robot chassis in 3D CAD. With easy-to-follow instructions, shopping lists, and plans, you’ll start building the robot. Further, you’ll add simple sensors and outputs to extend the robot, reinforce your design skills, and build your knowledge in programming with CircuitPython. You’ll also learn about interactions with electronics, standard robotics algorithms, and the discipline and process for building robots. Moving forward, you’ll learn how to add more complicated sensors and robotic behaviors, with increasing complexity levels, giving you hands-on experience. You’ll learn about Raspberry Pi Pico’s excellent features, such as PIO, adding capabilities such as avoiding walls, detecting movement, and compass headings. You’ll combine these with Bluetooth BLE for seeing sensor data and remotely controlling your robot with a smartphone. Finally, you’ll program the robot to find its location in an arena. By the end of this book, you’ll have built a robot at home, and be well equipped to build more with different levels of complexity.
Table of Contents (20 chapters)
1
Part 1: The Basics – Preparing for Robotics with Raspberry Pi Pico
7
Part 2: Interfacing Raspberry Pi Pico with Simple Sensors and Outputs
12
Part 3: Adding More Robotic Behaviors to Raspberry Pi Pico

What this book covers

Chapter 1, Planning a Robot with Raspberry Pi Pico, introduces Raspberry Pi Pico in relation to other robotics main controllers. It shows the advantages of the CircuitPython programming environment and takes you through making an overview plan for a robot build built around Pico. The chapter provides a robot hardware shopping list for the first half of the book, discussing the parts and trade-offs in choosing them.

Chapter 2, Preparing Raspberry Pi Pico, takes you through getting CircuitPython onto Pico, then taking your first steps in writing code with it. It will also cover soldering headers onto Raspberry Pi Pico so it can connect to robot parts.

Chapter 3, Designing a Robot Chassis in FreeCAD, introduces FreeCAD while turning the overview plan into 3D CAD designs. It shows you how to make drawings from the design for building the robot parts.

Chapter 4, Building a Robot around Pico, shows how you can use CAD drawings with hand tools to craft robot parts by cutting and drilling sheet plastic. It guides you in assembling the parts then wiring and connecting the electronics. This chapter is where the robot is first powered on!

Chapter 5, Driving Motors with Raspberry Pi Pico, introduces you to controlling motors with CircuitPython and Raspberry Pi Pico, showing how motors can be used to make line motions and turns and how speed can be controlled. The chapter then shows you how to pull these together into programmed motion sequences.

Chapter 6, Measuring Movement with Encoders on Raspberry Pi Pico, introduces the first robotic sensor in the book with wheel encoders, showing you how to detect wheel movement in code. The chapter covers the Raspberry Pi Pico PIO peripheral as a powerful way to manage these sensors.

Chapter 7, Planning and Shopping for More Devices, prepares you for the next section of the book with distance sensors, Bluetooth LE, and an inertial measurement unit (IMU), with further advice on choosing the devices and how they will be attached. The chapter provides a shopping list for the latter part of the book. You will revisit FreeCAD part design to make sensor mounts, and then use tools to cut them.

Chapter 8, Sensing Distances to Detect Objects with Pico, takes you through attaching and wiring two distance sensors into the robot. The chapter provides information on I2C communication and then shows you how to program the robot to communicate with the sensors. You will then build code for the robot to autonomously avoid walls.

Chapter 9, Teleoperating Raspberry Pi Pico Robot with Bluetooth LE, makes a comparison of wireless connection options, showing why Bluetooth LE was a suitable design choice. You will connect a Bluetooth LE module to the robot, then extend existing code to output sensor data through this connection, and display the output on a smartphone. You will also see how to drive the robot from a smartphone.

Chapter 10, Using the PID Algorithm to Follow Walls, provides an introduction to the PID algorithm, a fundamental building block for sensor/output control behaviors in robotics. We build a wall-following demonstration using a distance sensor, then show you how to tune the PID with smartphone plots via Bluetooth LE.

Chapter 11, Controlling Motion with Encoders on Raspberry Pi Pico, revisits encoders, showing you how to convert their output into units understandable by humans. You will learn how to combine these sensors with the PID algorithm to control motor speeds and drive in a straight line. You will then program the robot to drive a specified distance in a straight line at a specified speed.

Chapter 12, Detecting Orientation with an IMU on Raspberry Pi Pico, introduces the IMU, a sensor that lets you determine the orientation of the robot. The chapter provides a guide on connecting the sensor and calibrating it. You will use the IMU with the PID algorithm for a behavior that makes a robot always face north. Finally, the chapter shows you how to program the robot to make a specified turn using the IMU.

Chapter 13, Determining Location with Monte Carlo, will show you how to program a robot to determine where it is likely to be in an arena. You’ll use plans in the chapter to build a foam board arena and model this arena in code. You are shown how to visualize this space on a computer using Bluetooth LE with Matplotlib. You will then learn about moving robot poses based on sensor input. The chapter shows how multiple robot behaviors can cooperate in the same application. You will be introduced to using probability algorithms in robot motion, making predictions, and refining them.

Chapter 14, Continuing Your Journey – Your Next Robot, provides a summary of the topics learned in the book, with information on digging deeper into each of them. The chapter provides ideas and research areas for you to extend all the aspects of the robot, and then further suggestions to build more ambitious robots and grow your skills. The chapter also recommends robotics communities you could participate in.