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)

Menu modes – choosing your robot's behavior

We now have a collection of robot behaviors, and we will be growing a few more of them, but beside the behaviors, we are going to create a simple menu system to select them. A convenient and phone friendly way to do this is to serve it to a browser, so we will also take that approach with our robot. Using HTTP and HTML also means that we could later let other systems make requests to our robot too. HTTP sends requests in a URL—first, the http:// protocol identifier, a server hostname, myrobot.local, a path, /mode/foo, and it may have additional parameters after that. We will be using the path of the URL to determine what our robot will do.

As we have done with other systems, we will create a few logical sections and blocks to handle different aspects of this:

  • We will have code to manage the robot's modes, and...