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)

Robots in the home

Many robots have already infiltrated our homes. They are overlooked as robots because on first glance they appear commonplace and mundane. However, they are more sophisticated than they seem.

The washing machine

Let's start with the washing machine. This is used every day in some homes, with a constant stream of clothes to wash, spin, and dry. But how is this a robot? Let us understand this by referring to the following diagram:

The humble washing machine as a robot

The preceding diagram represents a washing machine as a block diagram. There is a central controller connected to the display, and with controls to select a program. The lines going out of the controller are outputs, and the lines going into the controller are data coming in from sensors. The dashed lines from outputs to the sensors show a closed loop of output actions in the real world causing sensor changes; this is feedback, an essential concept in robotics.

The washing machine uses the display and buttons to let the user choose the settings and see the status. After the start button is pressed, the machine will check the door sensor and sensibly refuse to start if the door is open. Once the door is closed and the start button is pressed, it will output to lock the door. After this, it uses heaters, valves, and pumps to fill the drum with heated water, using sensor feedback to regulate the water level and temperature.

Each process could be represented by a set of statements like these, which simultaneously fill the drum and keep it heated:

start water pump
turn on water heater
while water is not filled and water is not at the right temperature:
if water filled then
stop water pump
if water is at the right temperature then
turn off heater
else
turn on water heater

Note the else there, which is in case the water temperature drops below the right temperature a bit. The washing machine then starts the drum spinning sequence: slow turns, fast spins, sensing the speed to meet the criteria. It will drain the drum, spin the clothes dry, release the door lock, and stop.

This washing machine is in every respect a robot. A washing machine has sensors and outputs to affect its environment. Processing allows it to follow a program and use sensors with feedback to reach and maintain conditions. A washing machine repair person may be more of a roboticist than I.

Other household robots

A gas central heating boiler has sensors, pumps, and valves and uses feedback mechanisms to maintain the temperature of the house, water flow through heating, gas flow, and ensure that the pilot light stays lit.

Smart fans use sensors to detect room temperature, humidity, and air quality, then output through the fan speed and heating elements.

A computer printer is also a robot, with moving part outputs and sensors to detect all those pesky paper jams.

Perhaps the most obvious home robot is the robot vacuum cleaner. Refer to the following diagram:

A robotic vacuum cleaner (PicaBot By Handitec)

This wheeled mobile robot is like the one we will build here, but prettier. They are packed with sensors to detect walls, bag levels, and barrier zones, and avoid collisions. They most represent the type of robot we are looking at.

As we build our robot, we will explore how to use its sensors to detect things and react to them, forming the same feedback loops we saw in the washing machine.