Skip to content
ImagineWorld

Learn Robotics Programming

node_idnode-book_learn-robotics-programming
node_typenode-book
schema_profileworld.node_book.v1
statusactive
orthogonal_scopemanifold, entropy, authority, state
manifoldworld
entropymedium
authorityinforms
stateexternal
domainimagineworld.net
node_interiorrosetta_contract
unisonone evidence claim read five ways: seated in the robotics-embodiment field, the work teaches robotics programming — the software craft of making machines move — its framework, regime, and stance agreeing on what it is
governed_byWORLD-MANIFOLD
constitutional_citationCONSTITUTION
peer_node_books
book_titleLearn Robotics Programming
book_publisherPackt Publishing
total_chapters18
updated_at2026-10-14T05:49:55Z
local graph

node-book_learn-robotics-programming_chapter-01-introduction-to-robotics — Introduction to Robotics

node-book_learn-robotics-programming_chapter-02-exploring-robot-building-blocks-code-and-electronics — Exploring Robot Building Blocks – Code and Electronics

node-book_learn-robotics-programming_chapter-03-preparing-a-headless-raspberry-pi-for-a-robot — Preparing a Headless Raspberry Pi for a Robot

node-book_learn-robotics-programming_chapter-04-protecting-robot-code-with-git — Protecting Robot Code with Git

node-book_learn-robotics-programming_chapter-05-building-robot-basics-wheels-power-and-wiring — Building Robot Basics – Wheels, Power, and Wiring

node-book_learn-robotics-programming_chapter-06-drive-and-turn-moving-motors-with-mqtt-and-python — Drive and Turn – Moving Motors with MQTT and Python

node-book_learn-robotics-programming_chapter-07-driving-the-robot-with-a-phone-and-python — Driving the Robot with a Phone and Python

node-book_learn-robotics-programming_chapter-08-programming-distance-sensors-with-python — Programming Distance Sensors with Python

node-book_learn-robotics-programming_chapter-09-avoiding-obstacles-with-distance-sensors — Avoiding Obstacles with Distance Sensors

node-book_learn-robotics-programming_chapter-10-using-python-to-control-servo-motors — Using Python to Control Servo Motors

node-book_learn-robotics-programming_chapter-11-programming-encoders-with-python — Programming Encoders with Python

node-book_learn-robotics-programming_chapter-12-encoder-based-localisation-with-python — Encoder-Based Localisation with Python

node-book_learn-robotics-programming_chapter-13-imu-based-robot-navigation-with-python — IMU-Based Robot Navigation with Python

node-book_learn-robotics-programming_chapter-14-robot-vision-using-a-pi-camera-and-opencv — Robot Vision – Using a Pi Camera and OpenCV

node-book_learn-robotics-programming_chapter-15-line-following-with-a-camera-in-python — Line-Following with a Camera in Python

node-book_learn-robotics-programming_chapter-16-voice-control-ai-on-a-robot-with-python — Voice Control AI on a Robot with Python

node-book_learn-robotics-programming_chapter-17-robot-localisation-and-sensor-fusion-with-python — Robot Localisation and Sensor Fusion with Python

node-book_learn-robotics-programming_chapter-18-taking-your-robot-programming-skills-further — Taking Your Robot Programming Skills Further

Learn Robotics Programming is about building and programming a robot with smart behavior. It covers the skills required to build a gadget from parts, including how to choose them. These parts include sensors, motors, cameras, microphones, speakers, lights, and a Raspberry Pi.

This book continues with how to write code to make those parts do something interesting. The book uses Python, together with a little bit of HTML/CSS and JavaScript.

The technology used throughout the book is intended to include things that are available and affordable, and the code is shown to demonstrate concepts, so they can be used and combined to create even more interesting code and robots.

The topics combine aspects of being a programmer with aspects of being a robot maker, with a number of specialist topics such as computer vision and voice assistants thrown in.

This book is aimed at someone in software engineering who would like to explore more hardware, or a mechanical/electronics engineer who would like to get to know control software and a little AI. This book is useful for people who want to play and experiment with robotics outside of a work context: workshop hobbyists, parents with children, or in an education setting to get students familiar with building a challenging project. In other words, the broad group known as makers.

You will only need a little programming experience. You do not need to be an expert-level programmer, but you do have to have written some lines of code and be comfortable with looping, conditionals, and functions. Knowledge of object-oriented programming (classes and objects) isn’t necessary, but is introduced in the book. You will come away with hands-on Python knowledge, having applied AI in the real world, worked with MQTT, and explored robotics algorithms.

Similarly, you do not need to be an electronics whizz, and soldering is not required to build this robot. You will learn some skills around connecting and debugging electronic parts, including electronic buses, which are useful to embedded engineers.

There isn’t much mechanical engineering, as many parts are prefabricated, but you will learn to assemble them, modify them for our purposes with skills like measuring and cutting holes, and make computer-assisted sketches of where things need to fit. The book does not require a specialist workshop, but the tools needed will be introduced in the book.

You will need to bring a healthy interest in electronics, making things, learning, trying code, and solving challenges. Being keen to build a robot, get it to do stuff, and find out what to do with it next is the most important aspect of the book.

Chapter 1, Introduction to Robotics, introduces what robots are and provides examples in the home and industry, along with the kinds of robots beginners build.

Chapter 2, Exploring Robot Building Blocks – Code and Electronics, looks at the components of a robot. We will start making choices about the robot’s parts and see block diagrams for both systems and code, including the Raspberry Pi and its connections.

Chapter 3,Preparing a Headless Raspberry Pi for a Robot, shows you how to set up Raspberry Pi OS on an untethered Raspberry Pi and communicate with it wirelessly.

Chapter 4, Protecting Robot Code with Git, shows how code and configuration can be lost or broken, and ways to protect your work and keep a history of it.

Chapter 5, Building Robot Basics – Wheels, Power, and Wiring, introduces the trade-offs for buying and test-fitting a robot base, then assembling it.

Chapter 6, Drive and Turn – Moving Motors with MQTT and Python, shows you how to write robot movement code, build an MQTT communication system, and lay the foundations for the code in subsequent chapters.

Chapter 7, Driving the Robot with a Phone and Python, explores connecting to the MQTT bus from the phone and adding control pages for the robot, letting you take control and drive.

Chapter 8, Programming Distance Sensors with Python, adds a distance sensor array to your robot and makes it available over MQTT with a phone app to visualize its input.

Chapter 9, Avoiding Obstacles with Distance Sensors, teaches you proportional control while connecting avoidance algorithms to the MQTT distance sensors and motors, making a robot that autonomously avoids walls and obstacles.

Chapter 10, Using Python to Control Servo Motors, shows how to add servo motors to your robot and make them available to MQTT, then position a pan and tilt sensor head, and where they could be used in arms or legs on other robots.

Chapter 11, Programming Encoders with Python, demonstrates using encoders for odometry, letting your robot sense how far it’s driven and use this to drive in a straight line or make an accurate turn. This chapter also introduces the PI controller.

Chapter 12, Encoder -Based Localisation with Python, builds a robot position estimation system around the encoders using the Monte Carlo localisation algorithm.

Chapter 13, IMU-Based Robot Navigation with Python, introduces the Inertial Measurement Unit (IMU), a sensor package that can measure temperature, acceleration, turning speeds, and magnetic fields. You see how to show the robot orientation in 3D, and how to program the robot to autonomously face a cardinal direction.

Chapter 14, Robot Vision – Using a Pi Camera and OpenCV, shows how to get data from a camera and use computer vision to make movements based on what the robot sees. This chapter also streams processed video to a browser and uses an AI/ML model to track human faces.

Chapter 15, Line-Following with a Camera in Python, demonstrates how to make autonomous line-following behavior with the Raspberry Pi camera while building a PID controller.

Chapter 16, Voice Control AI on a Robot with Python, builds a voice control agent on your robot, letting you talk to control it and receive voice feedback.

Chapter 17, Robot Localisation and Sensor Fusion with Python, combines the distance sensors, encoder-based localisation, and IMU to build a more powerful robot positioning system.

Chapter 18, Taking Your Robot Programming Skills Further, looks at improving the security of your robot, getting in touch with the wider world of robot builds, then summarizes what you have seen in the book, while encouraging you to plan the construction of your next robot.

Before you begin with this book, you need to have programmed a little in a text programming language. I am assuming some familiarity with variables, conditional statements, looping, and functions.

You will need a computer running macOS, Linux, or Windows, an internet connection, a smartphone or tablet, and Wi-Fi.

In terms of manual skills, I assume that you can use a screwdriver, deal with occasional fiddly operations, and won’t be too scared off by the possibility of drilling holes.

Code examples have been tested on Python 3 with Raspberry Pi OS Trixie. The book will show you how to install these when needed. The book will show you how to choose and find robot parts when needed, too.

Software/hardware covered in the bookOS requirements
Python 3Windows/Linux/macOS/Raspberry Pi OS Trixie
PyInfraPython 3
Jupyter NotebookPython 3
OpenCVRaspberry Pi OS Trixie
VoskRaspberry Pi OS Trixie
Piper TTSPython 3, Raspberry Pi OS Trixie

Please read the appropriate chapters with trade-offs and recommendations before buying robot hardware.

If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (see the next section for access instructions). Doing so will help you avoid any potential errors related to the copying and pasting of code.

After reading the book, please come and join my robotics Discord community at https://discord.gg/4kcSNf4Npp for lots of robot discussion.

Note that the author acknowledges the use of cutting-edge AI, such as ChatGPT, with the sole aim of enhancing the language and clarity within the book, thereby ensuring a smooth reading experience for readers. It’s important to note that the content itself has been crafted by the author and edited by a professional publishing team.

This book includes a complete downloadable code bundle containing all the example projects and files used throughout the chapters. We recommend downloading the bundle so you can follow along smoothly and experiment with the examples.

Use the bundle as a practical starting point. Modify it, extend it, and apply what you learn by creating your own variations as you progress through the chapters.

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and X (formerly, Twitter) handles. For example: “This sets one LED at led_number to the specified color.”

A block of code is set as follows:

export const env = {
PI_HOSTNAME: "learnrob3.local",
MQTT_USERNAME: "robot",
MQTT_PASSWORD: "robot",
};

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<ul>
<li><a href="manual_drive.html">Manual drive</a></li>
<li><a href="behavior_path.html">Drive path</a></li>
<li><a href="power_off.html">Power off</a></li>
</ul>

Any command-line input or output is written as follows:

>>> r.leds.show()

Bold: Indicates a new term, an important word, or words that you see on the screen. For instance, words in menus or dialog boxes appear in the text like this. For example: “Select 4 for Other USB Microphone and try the sound test.”

Warnings or important notes appear like this.

Tips and tricks appear like this.