Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learn Robotics Programming
Learn Robotics Programming

Learn Robotics Programming: Build and control cutting-edge AI robots with Raspberry Pi and Python , Third Edition

Arrow left icon
Profile Icon Danny Staple
Arrow right icon
Early Access Early Access Publishing in Sep 2025
Free Trial
Paperback Sep 2025 566 pages 3rd Edition
Subscription
Free Trial
Arrow left icon
Profile Icon Danny Staple
Arrow right icon
Early Access Early Access Publishing in Sep 2025
Free Trial
Paperback Sep 2025 566 pages 3rd Edition
Subscription
Free Trial
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Learn Robotics Programming

Share your feedback on Discord!

https://packt.link/2dEZN

Have you ever wanted to build a robot? Have you seen amazing robots other people make and want to know where to start? This book will get you started on what a robot is, how to make and program a robot that appears to be intelligent. We’ll write code which uses sensors to observe the robot's surroundings and build real-world examples for advanced topics, including vision, speech recognition, and talking.You’ll see how combining simple build techniques with some code results in a machine that feels like a pet. You will also learn how to debug it when things go wrong, which they will. You'll find out how the robot can indicate problems back to you, along with selecting the behavior you would like to demonstrate. We’ll connect a smartphone to it, add voice control, and finally show you how to plan further robot builds.So, before we start building a robot, it's worth spending a little time on what a robot is. We can explore some types of robots, along with principles that distinguish robots from other machines. You'll think a little about where the line between robot and non-robot machines is located, and then perhaps muddy that line a little bit with the somewhat fuzzy truth. We will then look at a few robots built in the hobbyist and amateur robotics scenes and the parts that go into making them.In this chapter, we will be covering the following topics:

  • What does the word robot mean?
  • Exploring real world robots
  • Looking at what's inside a robot
  • Exploring different types of robot components

What does the word robot mean?

This word robot comes from science fiction and is derived from the Czech word for slave. Robot was first used in the 1921 Karel Capek play, Rossum's Universal Robots. The science fiction author Isaac Asimov coined the word robotics as he explored intelligent robot behavior.In modern terms, a robot is a machine that makes autonomous decisions based on input from sensors. A software agent is a program that automatically processes input and produces output. A system is autonomous when it doesn’t need to be guided or driven by a human to perform a task.Perhaps a robot is best described as an autonomous software agent with sensors and moving outputs, or it could be described as an electromechanical platform with software running on it. Either way, a robot requires electronics, mechanical parts, and code. Let’s have a look at some robots:

Figure 1.1 - Science fiction and real-world robots

The preceding picture shows science fiction and real-world robots. Images used are my own or from the public domain OpenClipArt library.The word robot conjures up images of fantastic sci-fi creations like those on the left of Figure 1.1, devices with great strength and intelligence. These often follow the human body plan, making them an android, a human-like robot. They're often given a personality and behave a little like a person or a pet.The right of Figure 1.1 shows real robots, in our homes and industries. Most do not stand on two legs, or indeed have any legs at all. Some are on wheels, and some are not mobile but still have moving parts and sensors.Robots such as modern washing machines, autonomous vacuum cleaners, and air sampling fans have infiltrated our homes and are part of everyday life. They aren’t threatening and have become just another machine around us. The 3D printer, robot arm, and learning toys are a bit more exciting, though.A robot can be simplified and deconstructed, as shown in the following diagram:

Figure 1.2 A simplified robot

At their core, robots can all be simplified down to:

  • inputs to sense with such as a distance sensor.
  • a controller to think, running code and making decisions.
  • outputs to act on the environment such as a motor.

When outputs change the environment, this will form a feedback loop, going around to the sense stage again reflecting the consequences of the act stage.Now, you’ve got an idea of the basic parts of a robot. Let’s use this as a way to look at the real robots in the next upcoming section.

Exploring real world robots

Now that you have an overview of robots in general, let’s see example robots from different fields, how they are remarkable, and what they are capable of.The following figure shows amazing robots favoring human and animal forms:

Figure 1.3 – Human and animal form robots

These robots shown in figure 1.3 use sensors and outputs to try to emulate humans and animals in the following ways:

You'll add some features like these to the robot you'll build. We'll use distance sensors to avoid obstacles and plan movement. We'll explore a camera for visual processing and following lines, and voice processing to work with spoken commands.

The Mars Rover

By contrast, the Mars rover robots use wheels instead of legs, since stabilizing a wheeled robot is far simpler, and there is less that can go wrong:

Figure 1.4 - NASA's Perseverance Rover alongside the Ingenuity Helicopter Selfie on Mars (Image Credit: NASA/JPL-Caltech/MSSS; https://mars.nasa.gov/resources/25790/perseverances-selfie-with-ingenuity/)

The front and rear wheels on the Mars rover shown in Figure 1.4 each have a motor to steer them. All wheels have a motor to drive them. The wheels are arranged to provide maximum grip and stability, in order to tackle Mars's rocky terrain and lower gravity. For more information about this rocker bogie system see https://mars.nasa.gov/mars2020/spacecraft/rover/wheels/. A design predominantly being a platform on wheels like this is known as a rover.Mars rovers are designed to work on a different planet, where there is no chance of human intervention if it breaks down. They must be robust. 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.The Perseverance rover is deployed with its 23 cameras folded up. After landing, some cameras get unfolded. The head like cluster of cameras can positioned with motors, in a pan and tilt mechanism, which is used to send back the pictures of Mars.Beside Perseverance is a helicopter, Ingenuity. This has links back to the hobby robotics scene, which we’ll see more of later in this chapter.Like the Mars robots, the robot you'll build in this book uses motor-driven wheels. Our robot has also been 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 with a camera to send back pictures of our test space.

Robots in industry

Another place robots are commonly seen is in industry. The first useful robots have been used in factories and have been there for a long time, with designs from 1956!

Robot arms

Robot arms range from tiny delicate robots for turning eggs, to colossal monsters moving shipping containers. Robot arms tend to use stepper or servo motors at their joints. Most industrial robot arms (for example, ABB welding robots) follow a predetermined pattern of moves. However, for a more sensor-based smart system, take a look at this robot named Yumi from ABB:

Figure 1.5 – Yumi Dual Arm Cobot from ABB

Robot arms can be unsafe to work around, requiring cages or warning markings around them. This robot Yumi is a collaborative robot or cobot , designed to be easy to train and work safely alongside people. Arm sensors and soft joints also allow Yumi to sense and react to collisions. Image credit: At the Science Museum (12) by Anthony O'Neil, CC BY-SA 2.0, via Wikimedia Commons.Yumi has a training and repeat mechanism for workers to adapt to tasks, using arm joint position sensors when being trained or playing back motions. Our robot will use encoder sensors to precisely control wheel movements.

Warehouse robots

Another common type of robot used in industry is those that move items around a factory floor or warehouse.There are giant robotic crane systems capable of shifting pallets in storage complexes. They receive instructions on where goods need to be moved from and to within shelving systems.Warehouses also have fleets of smaller mobile robots as shown in the next figure:

Figure 1.6 – The Ocado robot fleet

The preceding figure shows the Ocado fleet of warehouse robots, working together to store and retrieve grocery items in a vast warehouse. They sense when they are aligned with storage boxes, and as well as driving can act by lifting or lowering items.Figure 1.6 image credit: Techwords, CC BY-SA 4.0 <https://creativecommons.org/licenses/by-sa/4.0>, via Wikimedia Commons.Humans tend to interact with them through a central system, so each robot is headless, as our robot will be.We’ve seen robots in space and in industry, what about those closer to home?

Robots in the home

Many robots have already infiltrated our homes but are often overlooked as robots. However, they are more sophisticated than they appear.

A washing machine might be considered a robot with sensors (like temperature and water level, water transparency), outputs (like motors, heaters, pumps, door locks, and displays) and processes to control the wash time, temperature and water level. Some washing machines use sophisticated algorithms to automatically detect the stop conditions.

Smart fans use sensors to detect room temperature, humidity, and air quality, and then output through the fan speed and heating elements. Other machines in the home, like a microwave, for example, may have only timer-based operation, they do not make decisions and are too simple to be regarded as robots.

The robot vacuum cleaner

Perhaps the most obvious home robot is a robot vacuum cleaner:

Figure 1.7 – An OKP robotics vacuum cleaner

The wheeled mobile robot in Figure 1.7, is like the one we will build here, but prettier. Robot vacuum cleaners are packed with sensors to detect walls and dust levels, and as this one is doing, navigate back to their charging station. This robot is autonomous and mobile.Let’s take a closer look at its systems:

Figure 1.8 – The robot vacuum cleaner systems

Figure 1.8 shows a robot vacuum cleaner as a block diagram. The robot’s controller connects to many sensors, inputs, and outputs.Some are for user interaction, like a remote connection to a smartphone, indicator light, beeper, and user button. Some ensure things are working normally like the cover sensor, battery charge sensor and dust collector sensor. It has outputs for brush motors and the vacuum suction motor.The motors have encoders, so the vacuum knows how far it has moved or turned. It has floor sensors, so it won’t drive off edges, distance sensors to avoid walls, and IR sensors to locate its charging sensor. When it is driving, feedback loops are formed between some of these sensors and wheel motors.As we build our robot, we will explore how to use its camera to navigate to and track objects like this robot finds its charging station, we’ll use encoders to measure wheel movement, and distance sensors to avoid walls.Now we’ve examined robots we use our homes, what about the robots people build in their homes?

Discovering 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.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. For example, searching Github for topic: robotics org: orionrobots would show you my robotics work.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 2, Exploring Robot Building Blocks – Code And Electronics, Choosing a chassis kit.The following robot was built using a kit:

Figure 1.9 – Spiderbot – a servomotor-based hexapod

I used a hexapod kit to build SpiderBot (Figure 1.9) to explore the walking motion with 6 legs. It uses an esp8266 controller and an Adafruit 16 Servo driver for the motors.Another way that hobby robots are built is via toy hacking, taking a moving toy, for example a remote-control (RC) vehicle, or a device like a hoverboard, and converting it into a robot. This can be fun, but also needs some confidence in electronics problems. An example is the robot pictured in Figure 1.10:

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

Skittlebot, pictured in Figure 1.10 was built using toy hacking, repurposing a remote-control excavator toy into a robot platform. It was made for the 2018 PiWars competition. It uses the motors, tracks, and base of the RC toy with a Raspberry Pi controller similar to what we will use in this book.

Pi Wars is an autonomous robotics challenge for Raspberry Pi-based hobby robots, with both manual and autonomous challenges. It welcomes entries with decorative cases and resourceful engineering.

Skittlebot uses three distance sensors to avoid walls. We will investigate this kind of sensor in Chapter 8, Programming Distance Sensors with Python. Skittlebot also uses a camera to find colored objects, as we will see in Chapter 13, Robot Vision – Using a Pi Camera and OpenCV, in the section Colors, masking, and filtering – chasing colored objects.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, like this robot, Apex:

Figure 1.11 – Apex robot by Rowan Hansard

Apex, the robot shown in Figure 1.11, was built by Rowan Hansard of Onydus Robotics in 2023, with the design inspired by the Mars Rover’s rocker bogie, a camera on a mast, and a camera beneath to detect and align itself over screws. It has been built using a junction box, and some plywood, with a Raspberry Pi 3b+. Apex was made to apply sealant to screws. This robot uses principles from previous editions of this book, including vision with the camera, headless via a remote-control web app and build around a Raspberry Pi.Some robots combine techniques, like scratch building and kits:

Figure 1.12 – ArmBot - A larger Raspberry Pi robot with Arm

I built the robot “ArmBot” shown in Figure 1.12, combining materials I had cut and shaped with a robot arm kit, for a London robotics group in 2009. It was based on a small laptop but now uses a Raspberry Pi.In this book, we will use a chassis kit to get started and experiment on. 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.Having seen a few robots, let’s see what the parts inside them are!

Looking at what's inside a robot

We can start by looking at a robot as a physical system. In Figure 1.13, we can see a hobby robot:

Figure 1.13 – An assembled hobby robot

This robot was created based on a previous edition of this book, by Rob Bricheno, with extensions of his own like 3D printed mounts for N20 motors, a soldered breakout, and the rear shelf.Some hobbyist robots have been inspired by NASA rovers. However, this has gone full cycle, as the NASA rover Perseverance comes with a tiny helicopter drone named Ingeniuity, with Open-Source code on GitHub and using parts that came from the hobbyist store SparkFun. We will be using SparkFun parts in our design too.Now you’ve seen a few of these robots, what goes into making them?

Hobbyist robot parts

Figure 1.14 shows a hobbyist rover robot in its disassembled form:

Figure 1.14 – A hobby robot's components laid out

The component groups in Figure 1.14 include ten types of components:

  1. The chassis or body forms the main structure of the robot; other parts are attached here.
  2. A castor wheel, ball or skid balances a 2 wheeled robot.
  3. Two drive wheels. Other robots may use more wheels or legs here.
  4. The drive motors are essential for the robot to move.
  5. The main breakout bridges between a controller and connected components. These often include motor drivers.
  6. A controller, here a Raspberry Pi, runs instructions, takes information from the sensors, and processes this information to drive outputs, such as motors, through the main breakout.
  7. All robots must have power, usually one or more sets of batteries.
  8. Sensors provide information about the robot's environment or the state of its physical systems.
  9. User interaction devices let the robot communicate with the user, or the user control the robot.
  10. Many robots have some articulated parts. These can be robot arms, pan and tilt mechanisms or grabbers.

We will examine these components in more detail in this chapter.We can visualize a robot as a block diagram (Figure 1.15) of connected parts. Block diagrams use simple shapes to show a rough idea of how things may be connected:

Figure 1.15 – A robot block diagram

The block diagram in Figure 1.15 does not use a formal notation, but has a sensible key to identify sensors, outputs, and controllers. It could be as simple as a sketch on some scrap paper. The critical factor is that you can see blocks of functionality in the hardware, with the high-level flow of data between them.It is from this diagram that you can develop more detailed plans, plans containing details in terms of electrical connections, power requirements, the hardware, and how much space is needed. Sketching a block diagram about a robot you'd like to create, is the first step towards making it.

A block diagram is not a schematic, nor a scale drawing of a finished robot. It doesn't try to show the actual electronic connections. The picture ignores details, such as how to signal an ultrasonic distance sensor. The connection lines give a general idea of the data flow. This block diagram considers the type and number of motors and sensors, along with additional controllers they may need.

This brief overview of robot components shows a robot like the one you’ll build disassembled into parts and a simple robot block diagram. In the next section, we will take a closer look at each of the robot's components, starting with motors.

Exploring different types of robot components

Let’s take a closer look at the variations of these components.We will look at actuators and motors to act on the world.We will look at sensors, and as there are more sensor types than a single book can list, we'll keep to the commonly available and fun-to-use ones.Displays and indicators are debug output devices, for giving feedback on the robot's operation to a human user/programmer. A few of these will be covered in this section.Now, let's look at them in detail.

Types of actuators

Actuators are the parts of a robot that act on the world. Actuator power can be modulated with signals to control movement. Our primary actuators are motors, output devices that rotate when power is applied. Other examples of actuators are solenoids, valves, and pneumatic rams.Linear actuators, like those shown in Figure 1.16, are devices that convert electrical signals into motion along a single axis. These can be a stepper motor driving a screw in a fixed enclosure, or use arrays of coils and magnets:

Figure 1.16 – Linear actuators: By Rollon91, Image credit: https://commons.wikimedia.org/wiki/File:Uniline.jpg?uselang=fr CC BY-SA 3.0

A solenoid is a simple linear actuator using an electromagnetic coil with a metal core that is pulled or pushed away when powered. A common use of this type is in hydraulic or pneumatic valves. Hydraulic and pneumatic systems generate powerful motions like those seen in excavators. A smaller solenoid-based actuator is that used in a doorbell, pulled to hit one tuneful bar and released to hit another.Another type are rotary actuators. The output of these rotates, with speed or power depending on the input power. While there are hydraulic and pneumatic types, the most common are electronic motors, since we will be using those in our robots, let’s take a closer look at them.

Types of motors

There are a number of different kinds of motors that robots commonly use. Let's take a look at what each one of them does and how we might use them for different types of motion:

Figure 1.17 – Different motor types

To identify what each of these motors do, let's look at them in detail:

  1. DC motor Figure 1.17 (A): This is the simplest motor in robotics and is the basis of gear motors. It uses Direct Current (DC), which means it can be driven by a continuous voltage, with the direction and speed controlled by the direction and magnitude of that voltage. The motor speed is proportional to the voltage versus the torque required to move. A motor like this can spin too fast to be useful. It will not have much torque and stall easily.

    Torque is a rotating/twisting force, for example, the force a motor will need in order to turn a wheel. If the torque increases, a motor will require more power (as current) and will slow down while trying to cope. A motor has a limit, the stall torque, at which point it will stop moving.

  2. DC gear motor Figure 1.17 (B): This is a DC motor fitted with a gearbox. This gearbox provides a speed reduction and increases the torque it can handle. This mechanical advantage increases the motor's ability to move a load. We will use gear motors such as this on our robot in Chapter 6, Building Robot Basics – Wheels, Power, and Wiring, and Chapter 7, Drive and Turn – Moving Motors with Python.
  3. Servo motor (or servomechanism) Figure 1.17 (C): This type of motor combines a gear motor with a position sensor and a built-in controller as shown in Figure 1.18:
Figure 1.18 – Pictorial diagram of a servo motor mechanism

The motor is coupled through a gearbox to the sensor in a feedback loop. The controller compares the intended position with the actual position feedback, outputting the power needed for the motor to reach the intended position. Servo motors are used in pan and tilt mechanisms, robot arms and limbs. We will connect and program servo motors in Chapter 10, Using Python to Control Servo Motors. Some servo motors provide feedback as an analog signal from the position sensor. There are also smart servo motors that use a data signal, over which can provide more feedback to a controller.

  1. Stepper motor Figure 1.17 (D): These have coils powered in a sequence to let the motor step a certain number of degrees. Where exact motions are needed, engineers use steppers. Stepper motors tend to be slower and generate a lot of heat compared with DC motors or servo motors. They are used in fine-control applications, such as 3D printers and high-end robot arms. They are heavier and more expensive than other motors.
  2. Brushless motor: These can be more precisely controlled than DC motors, operating like fast stepper motors. They can be capable of ranges of very low to very high speeds, and high torque but require Electronic Speed Controllers (ESCs). They run quieter and are popular in drones and hoverboards. They may require a gearbox to reduce speed depending on the motors magnet arrangement.

IMPORTANT NOTE

All but servo motors require hardware for a controller such as the Raspberry Pi to drive them. This hardware allows the Pi to control power-hungry devices without destroying them. Never connect DC motors, stepper motors, or solenoids directly to a Raspberry Pi!

Let's look at some other types of actuators next.

Status indicators – displays, lights, and sounds

Another helpful output device is a display. A single LED (a small electronic light) can indicate the status of some part of the robot. An array of LEDs could show more information and add color. A graphical display can show some text or pictures, like those found on a mobile phone.Speakers and beepers can be used for a robot to communicate with humans by making sounds. The sound output from these can range from simple noises through to speech or playing music.Many robots don't have any displays and rely on a connected phone or laptop to display their status for them. We will use a phone to control and see the status of our robot throughout the book.

Types of sensors

One of the most important parts of a robot is sensors, for it to respond autonomously to its environment. Let’s see some of the robot sensor types:

Figure 1.18 – A selection of sensors for making robots

Figure 1.18 shows a collection of sensor types used in robotics. They are similar to those that we will explore and use in this book. Let's examine them and their uses. We will add some of them to the robot and cover in more detail.Let's understand each sensor from Figure 1.18 in detail:

  1. Optical interrupt sensor (Figure 1.18 A): These detect light(infrared or visible) passing through a gap between two posts, sensing when the beam is broken. When used with notched wheels, like the one pictured, they can detect rotation and speed by counting notches making them encoders. We will use encoders in Chapter 10, Programming Encoders with Python.
  2. Ultrasonic distance sensor (Figure 1.18 B): The HC-SR04 is a distance/ranging sensor that uses sound pulses, similar to the way bats navigate. It is affected by the types of material an object is made from. It requires precise timing in the controller. We will be programming distance sensors in Chapter 8, Programming Distance Sensors with Python.
  3. Inertial Measurement Unit (Figure 1.18 C): This sensor can detect the orientation of a robot, using gravity, magnetic and rotational forces. We will look at one of these in Chapter 12, IMU Programming with Python.
  4. Solid-state LiDAR (Figure 1.18 D): This sensor (an LD-07) uses an infrared laser array to sense the distance of many points over a 90-degree range. These produce lists of distance points. The LD-07 is hard to get hold of, with most LiDAR (Light Detection and Ranging) sensors being large and expensive.
  5. Raspberry Pi Camera module (Figure 1.18 E): This module lets a Raspberry Pi capture pictures and video sequences. We'll use it for visual processing in Chapter 13, Robot Vision – Using a Pi Camera and OpenCV. It can generate a lot of data quickly, which is one of the problems associated with robot vision. It is sensitive to lighting conditions.

There are many more sensors, including ones to detect positions of limbs, light, smoke, heat sources, and magnetic fields. These can be used to make more advanced robots and add more exciting behavior.

Summary

In this chapter, we have looked at what the word robot means, and the facts and fiction associated with robots. We have defined what a real-world robot is by considering what a machine needs to do in order to be considered a robot.We've investigated the robots seen in the home and in industry, through the lens of determining sensors and outputs. You've been shown some designed to amaze or travel to other planets. We've also looked at hobbyist and education robots, and how some of these are just built for fun. You've seen some block diagrams of real-world devices that may not have been considered robots. You've also spotted how our homes may already have several robots present.I hope this chapter has you thinking about what earns the title of robot. A washing machine can have advanced robotic functions. A machine called a robot, however, could be simply a remote-controlled device, such as telepresence robots or Robot Wars robots. Undoubtedly, all have sophisticated engineering, requiring many similar skills to make them.While some robots are clearly robots, such as NASA’s Valkyrie and Yumi, some others are far harder to draw the line at. If the broad concept of a decision-making, electro-mechanical machine fits these cases, it would exclude the remote-controlled type. If the concept of machines that are mobile is applied, then a toy RC car would be included, while a fully autonomous smart machine that is stationary is excluded. A machine could be made to look robot-like with anthropic (human-like) characteristics, but simply being mechanical, moving an arm up and down – is this a robot? It isn't running a program or reacting to an environment.We have covered robot components like motors, displays, indicators, and sensors, together with examples and some details regarding their types. These are the parts that allow our robot to interact with the world.Now that we have explored what robots are, let's move on to the next chapter, in which we'll explore robot controllers, the parts of a robot that run the code and connect sensors and motors as well as how to plan a robot so that we can build it.

Challenges

Look around your home. There will be automatic machines with many of the features of robots in them. Take a common household machine and look at its inputs and outputs. Use these to make a diagram, showing them going in or out of a controller. Think about how they will move, if they move around the house.Consider further what sensors and feedback loops may be present in this system. What is it monitoring? How is it responding to that information? How would you use sensors like these in a robot?

Further reading

Explore the robots and concepts mentioned in this chapter more with the following links:

Left arrow icon Right arrow icon

Key benefits

  • Boost your Python skills with practical examples to program complex robot behaviors and functionalities
  • Build advanced robots like Mars rovers and household helpers
  • Leverage advanced AI with Vosk for voice recognition and OpenCV for computer vision
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

In an era dominated by automation, smart robots are enhancing our ability to perform complex and repetitive tasks with unprecedented precision and efficiency. Learn Robotics Programming, Third Edition is your gateway to the future of robotics, offering a comprehensive guide to designing, building, and programming AI-powered robots using the Raspberry Pi. This edition is brimming with innovative projects and advanced technologies that will empower you to create remarkable machines, from robots to Mars rovers and even automated home helpers. Gain expert insights on selecting the right components and mastering Raspberry Pi setups. Effortlessly command your robots using interactive dashboards and control panel integration and explore advanced navigation techniques like encoder-based localization. Elevate your robotics with cutting-edge AI for voice interaction, making your creations not only functional but interactive. Ready to push the boundaries of robotics? This updated guide is packed with hands-on projects, advanced algorithms, and the latest AI features, making it your ultimate resource for next-generation robot creation. This book is your passport to pioneering new robotics landscapes. Unlock your potential and start a thrilling journey into the future of technology with Learn Robotics Programming, Third Edition.

Who is this book for?

This robotics book is ideal for programmers, developers, and robotics enthusiasts at any skill level who are eager to design, build, and program cutting-edge, AI-powered robots. Basic knowledge of the Python programming language will help you understand the concepts covered in this robot programming book more effectively. Unlock your potential and embark on an exciting journey towards the future of robotics!

What you will learn

  • Manage your robots with control panels and view their state with interactive dashboards
  • Integrate complex sensor systems for dynamic robot navigation and interaction
  • Learn voice recognition with Vosk and computer vision with OpenCV
  • Explore encoder-based localization with the BNO055 module to enhance your robot's movement accuracy
  • Streamline installation and updates with automated scripts to keep your robot up-to-date effortlessly
  • Explore algorithms that optimize sensor data and computing for better robotic performance

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Last updated date : Sep 19, 2025
Publication date : Dec 31, 2025
Length: 566 pages
Edition : 3rd
Language : English
ISBN-13 : 9781803246987
Category :
Languages :
Concepts :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Last updated date : Sep 19, 2025
Publication date : Dec 31, 2025
Length: 566 pages
Edition : 3rd
Language : English
ISBN-13 : 9781803246987
Category :
Languages :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts

Table of Contents

9 Chapters
Learn Robotics Programming, Third Edition: Build and control cutting-edge AI robots with Raspberry Pi and Python Chevron down icon Chevron up icon
1 Introduction to Robotics Chevron down icon Chevron up icon
2 Exploring Robot Building Blocks – Code and Electronics Chevron down icon Chevron up icon
3 Preparing a Headless Raspberry Pi for a Robot Chevron down icon Chevron up icon
4 Protecting Robot Code with Git Chevron down icon Chevron up icon
5 Building Robot Basics – Wheels, Power, and Wiring Chevron down icon Chevron up icon
6 Drive and Turn – Moving Motors with MQTT and Python Chevron down icon Chevron up icon
7 Driving the Robot with a Phone and Python Chevron down icon Chevron up icon
8 Programming Distance Sensors with Python Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.

Modal Close icon
Modal Close icon