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

Exploring advanced and impressive robots

Now that you have an overview of robots in general, I'll introduce some specific examples that represent the most remarkable robots around, and what they are capable of. Except for the Mars robots, human and animal forms have been favored by these robot makers for their adaptability, contrasting with robots designed for industrial use and intended for single repeated use.

Figure 1.3 shows the similarities between these robots and humans/animals:

Figure 1.3 – A selection of human and animal-like robots. [Image credits: Image 1: This image can be found at https://commons.wikimedia.org/wiki/File:Cog,_1993-2004,_view_2_-_MIT_Museum_-_DSC03737.JPG, and is in the public domain; Image 2: This image can be found at https://commons.wikimedia.org/wiki/File:Honda_ASIMO_(ver._2011)_2011_Tokyo_Motor_Show.jpg, by Morio, under CC BY-SA 3.0, at https://creativecommons.org/licenses/by-sa/3.0/deed.en; Image 3: This image can be found at https://commons.wikimedia.org/wiki/File:Nao_Robot_(Robocup_2016).jpg and is in the public domain; Image 4: This image can be found at https://commons.wikimedia.org/wiki/File:Atlas_from_boston_dynamics.jpg, by https://www.kansascity.com/news/business/technology/917xpi/picture62197987/ALTERNATES/FREE_640/atlas%20from%20boston%20dynamics, under CC BY-SA 4.0, at https://creativecommons.org/licenses/by-sa/4.0/deed.en; Image 5: This image can be found at https://commons.wikimedia.org/wiki/Commons:Licensing#Material_in_the_public_domain and is in the public domain

What these robots have in common is that they try to emulate humans and animals in the following ways:

  1. Robot 1 is Cog from the Massachusetts Institute of Technology. Cog was an attempt to be human-like in its movements and sensors.
  2. Robot 2 is the Honda ASIMO, which walks and talks a little like a human. ASIMO's two cameras perform object avoidance, as well as gestures and face recognition, and have a laser distance sensor to sense the floor. It follows marks on the floor with infrared sensors. ASIMO accepts voice commands in English and Japanese.
  3. Robot 3 is the Nao robot from Softbank Robotics. This cute 58 cm tall robot was designed as a learning and play robot for users to program. It has sensors to detect its motion, including if it is falling, and ultrasonic distance sensors to avoid bumps. Nao uses speakers and a microphone for voice processing. It has multiple cameras to perform similar feats to the ASIMO.
  4. Robot 4 is Atlas from Boston Dynamics. This robot is fast on two legs and has natural-looking movement. It has a laser radar (LIDAR) array, which it uses to sense what is around it so as to plan its movement and avoid collisions.
  5. Robot 5 is the Boston Dynamics BigDog, a four-legged robot, or quadruped. It can walk and run. It's one of the most stable four-legged robots, staying upright when being pushed, shoved, and walking in icy conditions.

You'll add some features like these in the robot you'll build. We'll use distance sensors to avoid obstacles, using ultrasonic sensors in the same way as Nao, and discussing laser distance sensors like ASIMO. We'll explore a camera for visual processing, line sensors to follow marks on the floor, and voice processing to work with spoken commands. We'll build a pan and tilt mechanism for a camera like the head of Cog.

The Mars rovers

The Mars rover robots are designed to work on a different planet, where there is no chance of human intervention if it breaks. They are robust by design. Updated software can only be sent to a Mars rover via a remote link as it is not practical to send up a person with a screen and keyboard. The Mars rover is headless by design:

Figure 1.4 – NASA's Curiosity rover at Glen Etive, Mars (Image Credit: NASA/JPL-Caltech/MSSS; https://mars.nasa.gov/resources/24670/curiosity-at-glen-etive/?site=msl)

Mars rovers depend on wheels instead of legs, since stabilizing a robot on wheels is far simpler than doing it for one that uses legs, and there is less that can go wrong. Each wheel on the Mars rovers has its own motor. The wheels are arranged to provide maximum grip and stability to tackle Mars's rocky terrain and lower gravity.

The Curiosity rover was deposited on Mars with its sensitive camera folded up. After landing, the camera was unfolded and positioned with servo motors. The camera is pointed using a pan and tilt mechanism. It needs to take in as much of the Mars landscape as it can, sending back footage and pictures to NASA for analysis.

Like the Mars robots, the robot you'll build in this book uses motor-driven wheels. Our robot is also designed to run without a keyboard and mouse, being headless by design. As we expand the capabilities of our robot, we'll also use servo motors to drive a pan and tilt mechanism.