Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Learn Robotics Programming
Learn Robotics Programming

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

eBook
$26.99 $38.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Learn Robotics Programming

Exploring Robot Building Blocks - Code and Electronics

In this chapter, we will go over the parts and systems that make up robots. What are the parts of a robot? These parts will be both software (code, and other) and hardware. How do they go together? When starting to make a robot, it's valuable to think about the parts you want and how they relate to each other. I recommend you sketch a plan of your robot—a block diagram as a guide to the connected code and parts.

In this chapter, we will be covering the following topics:

  • What is inside a robot? We will take apart a robot and examine its parts
  • Types of motors, sensors, and actuators - details on these robot parts
  • Controllers and IO - we will look at the main controllers and input/output functions
  • Planning components and code structure—we will make block diagrams to describe code, and components anywhere
  • ...

Technical requirements

For this chapter, you will require basic drawing materials, such as a pen and paper. While software such as Draw.io, Dia, Pencil, Inkscape, or Visio could be used, a back-of-an envelope sketch of a block diagram is a great start to robot planning. Most of my robots start that way.

What is inside a robot?

We can start by looking at a robot as a physical system. However, instead of looking at it all joined together, you can see how a typical hobby rover looks when totally disassembled in the following diagram:

A hobby rover with components laid out

A robot can also be visualized as a block diagram of connected parts. Block diagrams use simple shapes to show a rough idea of how things may be connected. Refer to the following diagram:

A robot block diagram

The preceding diagram is a block diagram. This is not a formal notation; the important factor is that you can clearly see the blocks of functionality you intend in the hardware, with the high-level flow of data between them. This can be a sketch on the back of a bit of scrap paper. The key I've created is off the top of my head, but it must be something that helps distinguish sensors, outputs, and...

Types of motors, sensors, and actuators

A motor is an output device that results in rotation when power is applied. An actuator is an output device, which is any device that creates movements from an electrical signal. Examples of actuators are solenoids, valves, and pneumatic rams. Motors are a subset of actuators too.

A sensor is a device that provides input to a robot, allowing it to sense its environment. There are more sensor types than a single book can list, so we'll keep to the commonly available and fun-to-use ones.

Motors and actuators

I've laid out some of the different kinds of motors, all of which are used in robotics. Let's take a look at what each one does, and how we might use them for different...

Controllers and IO

At the center of the robot block diagram are the controllers. Robots usually have a main controller, a computer of some kind. They may also have some secondary controllers, and some more unusual robots have many controllers. Sticking with the conventional main controller, this is the system that your code will run. It is the part that connects all the other components together and forms the basis of their interactions.

IO pins

IO pins are used for input and output from the controller; they give the controller its ability to connect to real-world sensors and motors.

The number of IO pins on the controller can be a major limiting factor in what you can connect to a robot without using secondary controllers...

Planning components and code structure

You've now briefly seen some components you might use in a robot, and you've encountered a block diagram to put them together. This is where you may start taking the next step and thinking further about how things will be connected, and how the code you write for them will be structured. Code is easier to reason about when taken as logical blocks instead of one large lump. Arranging code in ways that are similar to a hardware functionality diagram will help navigate your way around as it becomes more complicated.

So, let's return to the robot block diagram seen before.

This diagram has three sensors and two outputs. Throughout this book, you will see diagrams like this, and then be adding new modules along with new bits of code to deal with them. Each component (sensor, output, and controller board) may need a few bits of code...

Planning our robot

Let's put all of this to use, and plan the robot that we are making in this book. Although as we go through chapters we will be adding new components each time, having an overall map in our minds as we go helps us to see where we are. It is quite exciting to start to picture all the things a robot will do. Let's start with a list of what our robot will do and be:

  • It will have wheels and be able to drive around the floor
  • It will have a Raspberry Pi 3 controller
  • It will have a motor controller for the wheels
  • It will be able to follow lines with a pair of line following sensors
  • It will be able to indicate its status with a set of multicolored LEDs
  • The robot will use a pair of servo motors for a pan and tilt mechanism
  • It will be able to avoid walls and navigate around obstacles with either ultrasonic or laser distance sensors
  • It will have an encoder...

Summary

In this chapter, you've been able to see a number of the different component parts that go into a robot, and through a block diagram as a plan, start to visualize how you'd combine those blocks to make a whole robot. You've seen how you can quickly sketch your robot ideas on an envelope, and that drawing tools on a computer can be used for a neater version of the same diagram.

You've had a quick tour of motors, sensors, and controllers, along with a few ways, such as analog, digital, PWM, and databuses, for controllers to communicate with the other devices connected to them.

Following on from this, you've seen a plan of the robot we will build in this book.

Questions

  1. What is an IO pin?
  2. What tools do you need to make a block diagram?
  3. What are the drawbacks of the laser ranging sensor versus the ultrasonic distance sensor?
  4. What type of system is a microphone?
  5. What kind of IO pin is correct for measuring varying resistance?
  6. What type of IO pin would be suitable for detecting an on/off signal?

Further reading

  • Raspberry Pi Sensors by Rushi Gajjar: Integrate sensors into your Raspberry Pi projects and let your powerful microcomputer interact with the physical world.

  • Make Sensors: A Hands-On Primer for Monitoring the Real World with Arduino and Raspberry Pi by Tero Karvinen, Kimmo Karvinen, and Ville Valtokari. Learn to use sensors to connect a Raspberry Pi or Arduino controller with the real world.

  • Make Electronics: Learning by Discovery by Charles Platt: This is useful if you want to find out more about electronic components and dive deeper into individual components.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Get up and running with the fundamentals of robotic programming
  • Program a robot using Python and the Raspberry Pi 3
  • Learn to build a smart robot with interactive and AI-enabled behaviors

Description

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.

Who is this book for?

Learn Robotics Programming is for programmers, developers, and enthusiasts interested in robotics and developing a fully functional robot. No major experience required just some programming knowledge would be sufficient.

What you will learn

  • Configure a Raspberry Pi for use in a robot
  • Interface motors and sensors with a Raspberry Pi
  • Implement code to make interesting and intelligent robot behaviors
  • Understand the first steps in AI behavior such as speech recognition visual processing
  • Control AI robots using Wi-Fi
  • Plan the budget for requirements of robots while choosing parts
Estimated delivery fee Deliver to Egypt

Standard delivery 10 - 13 business days

$12.95

Premium delivery 3 - 6 business days

$34.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 29, 2018
Length: 472 pages
Edition : 1st
Language : English
ISBN-13 : 9781789340747
Category :
Languages :
Concepts :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Estimated delivery fee Deliver to Egypt

Standard delivery 10 - 13 business days

$12.95

Premium delivery 3 - 6 business days

$34.95
(Includes tracking information)

Product Details

Publication date : Nov 29, 2018
Length: 472 pages
Edition : 1st
Language : English
ISBN-13 : 9781789340747
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 $5 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 $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 163.97
Learn Robotics Programming
$54.99
Artificial Intelligence for Robotics
$59.99
Python Robotics Projects
$48.99
Total $ 163.97 Stars icon

Table of Contents

19 Chapters
Introduction to Robotics Chevron down icon Chevron up icon
Exploring Robot Building Blocks - Code and Electronics Chevron down icon Chevron up icon
Introducing the Raspberry Pi - Starting with Raspbian Chevron down icon Chevron up icon
Preparing a Raspberry Pi for a Robot - Headless by Default Chevron down icon Chevron up icon
Backing Up the Code with Git and SD Card Copies Chevron down icon Chevron up icon
Building Robot Basics - Wheels, Power, and Wiring Chevron down icon Chevron up icon
Drive and Turn - Moving Motors with Python Chevron down icon Chevron up icon
Programming Line-Following Sensors Using Python Chevron down icon Chevron up icon
Programming RGB Strips in Python Chevron down icon Chevron up icon
Using Python to Control Servo Motors Chevron down icon Chevron up icon
Programming Distance Sensors with Python Chevron down icon Chevron up icon
Programming Encoders with Python Chevron down icon Chevron up icon
Robot Vision - Using a Pi Camera and OpenCV Chevron down icon Chevron up icon
Voice Communication with a Robot Using Mycroft Chevron down icon Chevron up icon
Programming a Gamepad on Raspberry Pi with Python Chevron down icon Chevron up icon
Taking Your Robot Programming Skills Further Chevron down icon Chevron up icon
Planning Your Next Robot Project - Putting It All Together Chevron down icon Chevron up icon
Assessments Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.9
(8 Ratings)
5 star 87.5%
4 star 12.5%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Jim Link May 27, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I successfully built a small robot which is controlled by a Raspberry Pi computer board, using this book! What fun!The author's explanations and instructions are very clear. Make sure you read his recommendations for the hardware devices that are attached to the robot.Please note that in the picture, are two items that I added myself, and which are NOT in the book:1) The LCD screen at the back. I'm using it to display the robot's WIFI IP address.2) The switchboard at right front. I designed and created it myself, so I can power the robot either from the onboard battery pack, or from a plug-in power supply.
Amazon Verified review Amazon
Oct 12, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
素晴らしい本です
Amazon Verified review Amazon
Robert Ing Sep 21, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is excellent for anyone wanting to begin their self-learning journey into robotics. Easy to read, but certainly not intended for those who just want a light read before bed, you will have to be attentive on this one. However, this get you robotic literate in no time. Recommended!
Amazon Verified review Amazon
Amazon Customer Nov 04, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book! Would highly recommend if you’re just getting started with robotics
Amazon Verified review Amazon
Amazon Customer Jan 12, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A well written book that guides you through the process of building and programming in a fun and interesting way. Great for someone like me who is new to the building side.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela