Book Image

Learn Robotics Programming

By : Danny Staple
Book Image

Learn Robotics Programming

By: Danny Staple

Overview of this book

We live in an age where the most difficult human tasks are now automated. Smart and intelligent robots, which will perform different tasks precisely and efficiently, are the requirement of the hour. A combination of Raspberry Pi and Python works perfectly when making these kinds of robots. Learn Robotics Programming starts by introducing you to the basic structure of a robot, along with how to plan, build, and program it. As you make your way through the book, you will gradually progress to adding different outputs and sensors, learning new building skills, and writing code for interesting behaviors with sensors. You’ll also be able to update your robot, and set up web, phone, and Wi-Fi connectivity in order to control it. By the end of the book, you will have built a clever robot that can perform basic artificial intelligence (AI) operations.
Table of Contents (21 chapters)

What this book covers

Chapter 1, Introduction to Robotics, introduces what a robot is, together with examples.

Chapter 2, Exploring Robot Building Blocks – Code and Electronics, starts looking at the components of a robot. This is where we will start making choices about the robot's parts and it also introduces the block diagrams for both systems and code.

Chapter 3, Introducing the Raspberry Pi - Starting with Raspbian, introduces the Raspberry Pi and its connections, the Raspbian Linux operating system we'll use on it, and also covers the preparation of an SD card for use in a robot.

Chapter 4, Preparing a Raspberry Pi for a Robot - Headless by Default, looks at what a "headless" Raspberry Pi means and getting the Pi ready to run without a keyboard or screen.

Chapter 5, Backing Up the Code with Git and SD Card Copies, outlines how to restore things when they go wrong. This establishes habits to prevent you from losing your work.

Chapter 6, Building Robot Basics - Wheels, Power, and Wiring, introduces the choices and trade-offs for building the robot base, finding out what to buy, and taking your first steps in assembling it.

Chapter 7, Drive and Turn - Moving Motors with Python, covers how to connect our robot to the Raspberry Pi and write code to make the robot move, laying down the foundations for the code in subsequent chapters.

Chapter 8, Programming Line-Following Sensors Using Python, adds line sensors to the robot, explains how to fit them, and explains then how to use them to make line-following code.

Chapter 9, Programming RGB Strips in Python, demonstrates how to add an LED strip to the robot and write code to drive it, which the reader can then use to extend behaviors with colorful lights, for aesthetics, debugging, and information. This chapter also introduces soldering.

Chapter 10, Using Python to Control Servo Motors, gives our robot a set of servo motors, for the purpose of moving a "head" around, and shows the principles by which servo motors can be programmed.

Chapter 11, Programming Distance Sensors with Python, introduces distance sensors. Through the addition of a pair of variable inputs, we can make our robot avoid walls and obstacles autonomously.

Chapter 12, Programming Encoders with Python, demonstrates the concepts of odometry, measuring how far the robot has traveled according to wheel rotations, and uses it to compensate for motor variations and make accurate turns using a proportional-integral controller.

Chapter 13, Robot Vision - Using a Pi Camera and OpenCV, connects our robot to a camera mounted on the servo driven pan and tilt head. We program the robot to follow colored objects, or track faces in the camera, while allowing us to view its activity on a computer or phone.

Chapter 14, Voice Communication with a Robot Using Mycroft, introduces a voice assistant running on a second Pi, Mycroft, which we can program in Python to communicate with our robot and ask it to do things.

Chapter 15, Programming a Gamepad on Raspberry Pi with Python, is where we use HTML/CSS and JS to turn a phone into a smart game-like controller for our robot so that we can manually drive it, and launch autonomous behaviors at a touch, while seeing through the robot's camera.

Chapter 16, Taking Your Robot Programming Skills Further, looks at the wider world of robotics, what communities there are, how to get in touch with other robot builders and makers, potential development areas, and where to compete with a robot.

Chapter 17, Planning Your Next Robot Project - Putting It All Together, is the final chapter, where we summarize what you have seen in the book, while encouraging you to plan the construction of your next robot.

Chapter 18, Appendix, will cover extra information to help build your robot.