Book Image

Learning Robotics using Python

Book Image

Learning Robotics using Python

Overview of this book

Table of Contents (19 chapters)
Learning Robotics Using Python
About the Author
About the Reviewers


Learning Robotics with Python contains twelve chapters that mainly aims at how to build an autonomous mobile robot from scratch and how to program it using Python. The robot mentioned in this book is a service robot, which can be used to serve food at home, hotels, and restaurants. From the beginning to end, this book discusses the step-by-step procedure on how to build this robot. The book starts with the basic concepts of robotics and then moves on to the 3D modeling and simulation of the robot. After the successful simulation of the robot, it discusses the hardware components required to build the robot prototype in order to complete the robot navigation.

The software part of this robot is mainly implemented using the Python programming language and software frameworks, such as Robot Operating System (ROS), Open-CV, and so on. You will understand the application of Python from the aspects of designing the robot to the robot’s user interface. The Gazebo simulator is used to simulate the robot and machine vision libraries, such as Open-CV and OpenNI. PCL is used to process the 2D and 3D image data of the robot. Each chapter is presented with an adequate theory to understand the application aspect. The book is reviewed by experts in this field who are passionate about robotics.

What this book covers

Chapter 1, Introduction to Robotics, contains basic concepts and terminologies of robotics. This chapter is a must for beginners who are just starting with robotics.

Chapter 2, Mechanical Design of a Service Robot, discusses the 2D and 3D CAD designing aspect of the robot using LibreCAD and Blender (free software). This chapter also demonstrates how to use Blender Python APIs in order to build the 3D model.

Chapter 3, Working with Robot Simulation Using ROS and Gazebo, takes you through the simulation of the service robot using Gazebo and ROS.

Chapter 4, Designing ChefBot Hardware, explains the hardware designing of the robot, including block diagram and hardware components required to build ChefBot.

Chapter 5, Working with Robotic Actuators and Wheel Encoders, covers interfacing of robotic actuators and wheel encoders using Tiva C LaunchPad. It also mentions high-end smart actuators like dynamixel.

Chapter 6, Working with Robotic Sensors, discusses interfacing of ultrasonic distance sensors, IR proximity sensors, and IMU using Tiva C LaunchPad.

Chapter 7, Programming Vision Sensors Using Python and ROS, talks about the introduction to Open-CV, OpenNI, and PCL libraries and interfacing these to ROS and programming using Python.

Chapter 8, Working with Speech Recognition and Synthesis Using Python and ROS, discusses speech recognition and synthesis using various libraries and interfacing it to ROS programming using Python.

Chapter 9, Applying Artificial Intelligence to ChefBot Using Python, covers tutorials to build a ChatterBot. This can be used to make the robot interactive.

Chapter 10, Integration of ChefBot Hardware and Interfacing it into ROS, Using Python, explores tutorials to integrate the complete hardware and essential software section. It mainly discusses autonomous navigation of the service robot and how to program it using ROS and Python.

Chapter 11, Designing a GUI for a Robot Using Qt and Python, covers tutorials on how to build a GUI for the user who operates the robot in a typical restaurant. The GUI is built using Qt and the PyQt Python wrapper.

Chapter 12, The Calibration and Testing of ChefBot, explores tutorials on how to calibrate and test the robot for the final run.

What you need for this book

The book is all about how to build a robot. To start with this book, you should have some hardware. The robot can be built from scratch, or you can buy a differential-drive configuration robot with an encoder feedback. You should buy a controller board, such as Texas Instruments Launchpad, for embedded processing. You should have at least a laptop/net book for the entire robot process. In this book, we will use Intel NUC for robot processing. It’s very compact in size and delivers high performance. For the 3D vision, you should have 3D sensors, such as laser scanner, Kinect, and Asus Xtion Pro.

In the software section, you should have a good understanding on how to work with GNU/Linux commands. You should also have a good knowledge of Python. You should install Ubuntu 14.04.2 LTS to work with the examples. If you have knowledge about ROS, OpenCV, OpenNI, and PCL, it will be a great add-on. You have to install ROS Indigo to test these examples.

Who this book is for

Learning Robotics with Python is a good companion for entrepreneurs who want to explore the service robotics domain, professionals who want to implement more features to their robots, researchers who want to explore more about robotics, and hobbyist or students who want to learn robotics. The book follows a step-by-step guide that can be easily understood by anyone.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: “ The first procedure is to create a world file and save it with the .world file extension.”

A block of code is set as follows:

<xacro:include filename=”$(find chefbot_description)/urdf/chefbot_gazebo.urdf.xacro”/> 
<xacro:include filename=”$(find chefbot_description)/urdf/chefbot_properties.urdf.xacro”/> 

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

$ roslaunch chefbot_gazebo chefbot_empty_world.launch

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: “ we can command the robot to navigate to some position on the map using the 2D Nav Goal button”.


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from:


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from


Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.