Jump to ratings and reviews
Rate this book

Learn Robotics Programming: Build and control autonomous robots using Raspberry Pi 3 and Python

Rate this book
Build and program intelligent robots using Python and Raspberry Pi with this beginner-friendly guide packed with hands-on projects that introduce core concepts in robotics, automation, and AI

Key FeaturesGet up and running with robotics by building your first intelligent robot using Python and Raspberry PiLearn to integrate sensors, motors, and wireless controls to create interactive, autonomous behaviors powered by real-world inputDiscover beginner-friendly AI concepts like speech recognition and image processing, and control your robot remotely using Wi-Fi or mobile devicesBook DescriptionWe 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.

What you will learnConfigure a Raspberry Pi for use in a robotInterface motors and sensors with a Raspberry PiImplement code to make interesting and intelligent robot behaviorsUnderstand the first steps in AI behavior such as speech recognition visual processingControl AI robots using Wi-FiPlan the budget for requirements of robots while choosing partsWho this book is forThis book is ideal for beginner programmers, developers, and tech enthusiasts interested in robotics and developing a fully functional robot. Whether you're a self-learner or a maker with an interest in automation, this hands-on guide will help you build real working robots from scratch. No prior experience in robotics or electronics is required — just basic programming knowledge and a curiosity to learn.

Table of ContentsIntroduction To RoboticsExploring Robot Building Blocks - Code And ElectronicsIntroducing The Raspberry Pi - Starting With RaspbianPreparing A Raspberry Pi For A Robot - Headless By DefaultBacking Up The Code With Git And SD Card CopiesBuilding Robot Basics - Wheels, Power And WiringDrive And Turn - Moving Motors With PythonProgramming Line Following Sensors Using PythonProgramming RGB Strips In PythonUse Python To Control Servo MotorsProgramming Distance Sensors With PythonProgramming Encoders With PythonRobot Vision - Using A Pi Camera And OpenCVVoice Communication With A Robot Using MycroftProgramming A Gamepad On Raspberry Pi With PythonTaking Your Robot Programming Skills FurtherPlanning Your Next Robot Project - Putting It All TogetherAppendixAssessment

472 pages, Paperback

Published November 29, 2018

Loading...
Loading...

About the author

Danny Staple

7 books2 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
6 (85%)
4 stars
1 (14%)
3 stars
0 (0%)
2 stars
0 (0%)
1 star
0 (0%)
Displaying 1 - 3 of 3 reviews
Profile Image for Richard.
120 reviews
November 21, 2020
Introduction

Robotics is an interdisciplinary field that brings together programming, electronics, mechanical engineering, and artificial intelligence. For beginners, understanding how these components work together can be challenging, particularly when moving from writing software to building a physical machine. Danny Staple’s Learn Robotics Programming addresses this challenge by offering a practical, project-based introduction to robotics using the Raspberry Pi and Python.

Rather than concentrating exclusively on theoretical concepts, Staple guides readers through the process of designing, assembling, programming, and extending a mobile robot. The book introduces fundamental robotics concepts before progressing towards more advanced capabilities, including sensor integration, computer vision, autonomous navigation, and remote control. Its central strength lies in connecting software development with tangible engineering outcomes, making robotics more accessible to programmers, students, hobbyists, and technology enthusiasts.

Content and Structure

One of the book’s most notable strengths is its logical, progressive structure. Readers begin by learning about the basic components of a robot, configuring the Raspberry Pi operating system, and preparing a development environment. The introduction to headless operation and Git version control also establishes useful software development practices that extend beyond robotics.

The book then moves into the physical construction of a mobile robot. Readers learn how to assemble the chassis, connect power supplies, interface motors through appropriate motor drivers, and use Python to control movement. This stage is particularly valuable because it demonstrates that robotics programming is not simply about writing code; it also requires an understanding of electrical connections, hardware limitations, and the relationship between software instructions and physical behaviour.

Subsequent chapters expand the robot’s capabilities through sensors and additional hardware. Ultrasonic distance sensors introduce obstacle detection, while servo motors, RGB LEDs, wheel encoders, and inertial measurement units provide opportunities to explore actuation, feedback, motion measurement, and orientation. These examples demonstrate how individual components can be combined into a more sophisticated robotic system.

The progression towards computer vision is another important feature. By introducing a camera and OpenCV, the book shows how image processing can enable tasks such as line following and visual tracking. These applications help readers understand how a robot can respond to information from its surroundings rather than merely execute predetermined movement commands.

Finally, the book explores connectivity and intelligent interaction. Wi-Fi-based control and monitoring, web interfaces, and voice-related functionality illustrate how a robotic platform can be extended beyond basic autonomous movement. Together, these topics provide a broad introduction to the technologies that underpin contemporary hobbyist robotics and embedded intelligent systems.

Practical Approach and Technical Value

The book’s hands-on methodology is arguably its greatest strength. Hardware lists, wiring diagrams, and Python code examples help readers translate explanations into practical experiments. Instead of encountering electronics, programming, and mechanical construction as isolated subjects, readers see how they interact within a working system.

Python is a sensible choice for this learning journey. Its accessible syntax allows beginners to concentrate on programming logic and hardware interaction without being overwhelmed by language complexity. At the same time, Python’s wider ecosystem provides useful tools for sensor integration, computer vision, and network communication.

The Raspberry Pi offers a similarly effective learning platform. It provides a relatively compact and affordable computer capable of running a general-purpose operating system and supporting a wide range of peripherals. Using it as the robot’s controller allows readers to explore familiar computing concepts alongside physical input and output.

Another strength is the emphasis on building beyond the initial project. The process of selecting components, organising code, testing hardware, and integrating subsystems encourages an engineering mindset rather than simple imitation. Readers can use the completed robot as a foundation for experimentation, adapting its behaviour or adding new sensors and features.

The book therefore offers value beyond its immediate construction project. It introduces practical habits associated with robotics development, including incremental testing, debugging, system integration, and the management of code as a project evolves.

Critical Evaluation

Despite its many strengths, Learn Robotics Programming has some limitations that prospective readers should consider. First, although the book provides an accessible introduction to robotics, its broad technical scope means that readers may encounter difficulties if they have no previous programming experience. The publisher identifies basic Python knowledge as beneficial, suggesting that the book is better suited to readers who already understand programming fundamentals than to complete programming novices.

Second, the practical nature of the project introduces a financial and logistical consideration. Readers must obtain a Raspberry Pi, chassis, motors, sensors, power supplies, and other components before they can reproduce many of the exercises. Selecting compatible hardware and troubleshooting wiring problems may require additional research, patience, and independent experimentation. Although these challenges reflect the realities of robotics engineering, they can make the learning process more demanding than following a conventional programming tutorial.

A further consideration is the age of the software environment. The second edition was published in February 2021 and includes instructions and dependencies associated with Raspberry Pi OS based on Debian Buster, as well as software such as Mycroft. Consequently, readers using newer Raspberry Pi hardware or operating systems may need to adapt installation instructions, libraries, and example code. This does not diminish the book’s underlying educational value, but it means that some technical details may require updating.

Finally, the book’s emphasis on constructing and programming a practical robot means that it is not intended to be a comprehensive academic textbook on robotics. Readers seeking an in-depth treatment of advanced control theory, mathematical modelling, industrial robotics, or sophisticated machine-learning algorithms may need supplementary resources. Its strength is practical integration rather than exhaustive theoretical coverage.

These limitations are balanced by the book’s clear project-based direction. Readers are encouraged to troubleshoot, experiment, and modify their designs, which are essential skills for anyone wishing to progress beyond introductory robotics.

Intended Audience

The book is particularly suitable for software developers who want to expand their knowledge into electronics and embedded systems. Python programmers can discover how familiar programming concepts translate into motor control, sensor processing, and autonomous behaviour.

It is equally relevant to hobbyists, makers, engineering students, and educators seeking a practical project that combines several technical disciplines. Readers with some electronics knowledge may progress more quickly, while those with limited experience can benefit from working through the material gradually and consulting additional resources when necessary.

However, complete beginners should approach the book with realistic expectations. A basic understanding of Python, a willingness to learn electronics, and sufficient time for assembling and debugging hardware will make the experience considerably more rewarding.

Conclusion

Danny Staple’s Learn Robotics Programming is a valuable practical guide for anyone interested in discovering how autonomous robots are designed, built, and programmed. Its greatest achievement is the way it connects programming with physical engineering, gradually transforming a collection of electronic components into a mobile machine capable of sensing its environment and responding to it.

The combination of Raspberry Pi hardware, Python programming, sensor integration, computer vision, and network connectivity provides a broad foundation for further exploration. More importantly, the project encourages readers to develop transferable skills in problem-solving, debugging, system integration, and engineering design.

Although some hardware and software instructions may require adaptation, and readers without programming experience may find the learning curve challenging, these issues do not undermine the book’s fundamental contribution. Rather, they highlight the importance of treating robotics as an evolving, hands-on discipline.

Overall, Learn Robotics Programming is recommended for aspiring roboticists, Python programmers, and technology enthusiasts who want to move beyond theory and build a functioning autonomous robot. It offers a practical starting point for understanding the relationship between software, electronics, and intelligent behaviour, while providing a foundation for more ambitious robotics projects.
Profile Image for Dave Snowdon.
102 reviews1 follower
March 10, 2019
There is a lot involved in building your own robot: sourcing adequate parts, knowing how to assemble them and then how to get the robot to do things by writing software. Buying a robot kit glosses over these steps as the parts are provided together with assembly instructions and often a software library to make programming simple. Going from building such a kit to your own robot can be quite a shock for this reason.

This is why this book is valuable. It covers a lot of ground! The author, Danny Staple, guides us through the process of building a wheeled robot without relying on a kit. Instead, Danny describes the components required and provides some recommendations but allows for variation. Step by step we are shown how to set up a Raspberry Pi and control motors & servos, read inputs from distance sensors, line sensors, and use the Raspberry Pi camera. Everything, hardware and software, is explained from scratch without assuming any prior knowledge and in an easy to read style. Instead of relying on a library of code Danny shows us how to implement everything required a small feature at a time. He also explains the principles behind why he structures the code as he does; so we learn how to extend the software on our own without it becoming a hard-to-maintain mess.

The first couple of chapters describe what a robot is and give some examples of contemporary robots. The next two introduce the Raspberry Pi and how to set one up. The material here is very similar to anything else available on the internet but including here is helpful as it keeps all the information required in one place. Chapter 6 is where we really get started; covering choosing a chassis for your robot as well as a motor controller. Danny recommends beginning with a simple car-like chassis with two-wheel drive as a good choice for a first robot. This chapter also describes powering the robot and how to provide power for the Raspberry PI and the motors. We also see how to assemble the chassis with Raspberry Pi, motors and batteries.

Chapters 7 and 8 get us to the point where our robot can move and follow a line drawn with a marker. We also hear why it's good to separate the code talking to the motor controller from the code managing the robot's behaviour. The optical sensors used for line following are introduced. We find out how they work, how to attach them to the Raspberry Pi and how to read the values using python. By the end of the chapter, the robot can follow a circuit drawn using a black marker pen.

Chapter 9 shows us how to control LED strips from our robot which as well as providing eye-candy allows the robot to give some indication of its state and make debugging easier. We also do some soldering for the first time, and the book provides some basic advice on soldering and how to get a good joint. We use the Raspberry Pi's SPI interface to drive the LEDs and see python code for doing that. The line following behaviour gets updated to give us left and right "indicator" signals as the robot turns. This chapter also introduces the HSV (Hue, Saturation, Value) colour system to describe how we can program the LEDs to make rainbow effects.

In chapter 11 things really get interesting! We see how to mount ultrasonic distance sensors and connect them to the Raspberry Pi. We're not using i2c sensors, so we need to use raw I/O to time the response and work out the distance. The same code uses busy waits and may not be accurate as it doesn't compensate for multitasking. We first write a simple object avoiding behaviour for the robot and see that it works but has problems causing it to appear to be indecisive about some obstacles and occasionally ramming into things. We can do better than this, and so we then develop an algorithm that provides a finer adjustment of motor speeds based on distance from an obstacle.

Now we have several behaviours we see how to build a simple web application on the robot that lets us start and stop all the defined behaviours.

Chapter 12 provides us with a means for our robot to know how much each wheel has turned so we can automatically adjust for variance in motor speed.

Chapter 13 attaches a camera to the robot and allows it to chase objects of a particular colour. We also see how to use the pan & tilt mounting to track faces using OpenCV's built-in HAAR cascade classifier. The text describes how HAAR cascades work and provides some references which go into more detail. The book probably should have pointed out that HAAR cascades while efficient are not state-of-the-art and there are better, more modern, techniques out there.

Chapter 14 introduces voice control by installing MyCroft on a second Raspberry Pi which controls the robot by making HTTP requests to the simple web application we've been building on the robot.

Chapter 15 then shows us how to build a slightly more complex web UI that provides slider controls to drive the robot as well as a display of what the robot can see. The two sliders only control the wheel motors, but by this point, we have all the information we need to add controls for the pan & tilt camera platform.

The last two chapters provide links and guidance for what we can do next when contemplating designing and building our own robots.

As I said at the beginning of this review this book covers a lot of ground. If you follow all the chapters you'll have learnt how to write python, solder, build simple web applications using flask, python, HTML, CSS and javascript and, of course, made a quite capable little robot. I have no hesitation in recommending the book to anyone interested in building their first robot. You'll definitely learn more this way than by simply buying a kit.
Profile Image for Paul Fitz-George.
Author 8 books4 followers
January 10, 2019
If you've ever wanted to know literally what the 'nuts and bolts' of building a robot are, this is the book for you. It's not the 'Idiots guide' though, it's an intensive journey through building a functional robot from start to finish and yes, it will involve you using your brain and stretching your computer knowledge to, as you will need to have some basic idea about code writing and, 'have written some lines of code and be comfortable with looping, conditionals, and functions.'

That said, don't panic! There is a wealth of detailed information from the very knowledgeable Danny Staple and a myriad of illustrations to help you achieve your goal and build your first robot.

Rome wasn't built in a day and your robot will take a little time, patience and study to build. But the essential knowledge you'll pick up from Danny's book, will make you able to sit at any conversation in a coffee shop, at a dining table, or in an office meeting room anywhere and use the excellent background knowledge you've gained from your quest, to give an informed opinion should you wish (rather than a speculative guess), whenever the terms robot or robotics are slipped into the conversation.
Displaying 1 - 3 of 3 reviews