Book Image

Learn Robotics Programming - Second Edition

By : Danny Staple
Book Image

Learn Robotics Programming - Second Edition

By: Danny Staple

Overview of this book

We live in an age where the most complex or repetitive tasks are automated. Smart robots have the potential to revolutionize how we perform all kinds of tasks with high accuracy and efficiency. With this second edition of Learn Robotics Programming, you'll see how a combination of the Raspberry Pi and Python can be a great starting point for robot programming. The book starts by introducing you to the basic structure of a robot and shows you how to design, build, and program it. As you make your way through the book, you'll add different outputs and sensors, learn robot building skills, and write code to add autonomous behavior using sensors and a camera. You'll also be able to upgrade your robot with Wi-Fi connectivity to control it using a smartphone. Finally, you'll understand how you can apply the skills that you've learned to visualize, lay out, build, and code your future robot building projects. By the end of this book, you'll have built an interesting robot that can perform basic artificial intelligence operations and be well versed in programming robots and creating complex robotics projects using what you've learned.
Table of Contents (25 chapters)
1
Section 1: The Basics – Preparing for Robotics
7
Section 2: Building an Autonomous Robot – Connecting Sensors and Motors to a Raspberry Pi
15
Section 3: Hearing and Seeing – Giving a Robot Intelligent Sensors
21
Section 4: Taking Robotics Further

Competitive, educational, and hobby robots

The most fun robots are those created by amateur robot builders. This is an extremely innovative space.

Robotics always had a home in education, with academic builders using them for learning and experimentation platforms. Many commercial ventures have started in this setting. University robots are often group efforts, with access to hi-tech equipment to create them:

Figure 1.9 – Kismet [Jared C Benedict CC BY-SA 2.5 https://creativecommons.org/licenses/by-sa/2.5] and OhBot [AndroidFountain [CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0)]]

Kismet (Figure 1.9 picture 1) was created at MIT in the late 90s. Several hobbyist robots are derived from it. It was groundbreaking at the time, using motors to drive face movements mimicking human expressions. OhBot, a low-priced hobbyist kit using servo motors, is based on Kismet. OhBot (Figure 1.9 picture 2) links with a Raspberry Pi, using voice recognition and camera processing to make a convincing face.

Hobby robotics is strongly linked with the open source software/hardware community, making use of sites such as GitHub (https://github.com) for sharing designs, and code, leading to further ideas. Hobbyist robots can be created from kits available on the internet, with modifications and additions. The kits cover a wide range of complexity, from simple three-wheeled bases to drone kits and hexapods. They come with or without the electronics included. An investigation of kits will be covered in Chapter 6, Building Robot Basics – Wheels, Power, and Wiring. I used a hexapod kit to build SpiderBot (Figure 1.10) to explore the walking motion:

Figure 1.10 – Spiderbot, made by me, based on a kit. The controller is an esp8266 + Adafruit 16 Servo Controller

Skittlebot was my Pi Wars 2018 entry, built using toy hacking, repurposing a remote control excavator toy into a robot platform. Pi Wars is an autonomous robotics challenge for Raspberry Pi-based robots, with both manual and autonomous challenges. There were entries with decorative cases and resourceful engineering. Skittlebot (Figure 1.11) uses three distance sensors to avoid walls, and we will investigate this kind of sensor in Chapter 8, Programming Distance Sensors with Python. Skittlebot uses a camera to find colored objects, as we will see in Chapter 13, Robot Vision – Using a Pi Camera and OpenCV:

Figure 1.11 – Skittlebot – My PiWars 2018 Robot, based on a toy

Some hobbyist robots are built from scratch, using 3D printing, laser cutting, vacuum forming, woodwork, CNC, and other techniques to construct the chassis and parts:

Figure 1.12 – Building ArmBot

I built the robot in Figure 1.12 from scratch, for the London robotics group The Aurorans, in 2009. The robot was known as EeeBot in 2009 since it was intended to be driven by an Eee PC laptop. The Aurorans were a community that met to discuss robotics. The robot was later given a Raspberry Pi, and a robot arm kit (the uArm) seemed to fit, earning it the name ArmBot.

In the current market, there are many chassis kits, and a beginner will not need to measure and cut materials in this way to make a functioning robot. These are built to experiment on, and to inspire other robot builders and kids to code. Toward the end of the book, we will cover some of the communities where robots are being built and shared, along with starting points on using construction techniques to make them from scratch.

The television series Robot Wars is a well-known competitive robot event with impressive construction and engineering skills. There is no autonomous behavior in Robot Wars, though; they are manually driven like remote control cars. Washing machines, although less exciting, are smarter, so they could be more strictly considered robots.