You are previewing Learning Robotics Using Python.
O'Reilly logo
Learning Robotics Using Python

Book Description

Design, simulate, program, and prototype an interactive autonomous mobile robot from scratch with the help of Python, ROS, and Open-CV!

In Detail

Learning about robotics will become an increasingly essential skill as it becomes a ubiquitous part of life. Even though robotics is a complex subject, several other tools along with Python can help you design a project to create an easy-to-use interface.

Learning Robotics Using Python is an essential guide for creating an autonomous mobile robot using popular robotic software frameworks such as ROS using Python. It also discusses various robot software frameworks and how to go about coding the robot using Python and its framework. It concludes with creating a GUI-based application to control the robot using buttons and slides.

By the end of this tutorial, you'll have a clear idea of how to integrate and assemble all things into a robot and how to bundle the software package.

What You Will Learn

  • Understand the core concepts and terminologies of robotics

  • Create 2D and 3D drawings of robots using freeware such as LibreCAD and Blender

  • Simulate your robot using ROS and Gazebo

  • Build robot hardware from the requirements

  • Explore a diverse range of actuators and its interfacing

  • Interface various robotic sensors to robots

  • Set up and program OpenCV, OpenNI, and PCL to process 2D/3D visual data

  • Learn speech processing and synthesis using Python

  • Apply artificial intelligence to robots using Python

  • Build a robot control GUI using Qt and Python

  • Calibration and testing of robot

  • Downloading the example code for this book. 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.

    Table of Contents

    1. Learning Robotics Using Python
      1. Table of Contents
      2. Learning Robotics Using Python
      3. Credits
      4. About the Author
      5. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Introduction to Robotics
        1. What is a robot?
          1. History of the term robot
          2. Modern definition of a robot
        2. Where do robots come from?
        3. What can we find in a robot?
          1. The physical body
          2. Sensors
          3. Effectors
          4. Controllers
        4. How do we build a robot?
          1. Reactive control
          2. Hierarchical (deliberative) control
          3. Hybrid control
        5. Summary
      9. 2. Mechanical Design of a Service Robot
        1. The Requirements of a service robot
        2. Robot drive mechanism
          1. Selection of motors and wheels
            1. Calculation of RPM of motors
            2. Calculation of motor torque
          2. The design summary
          3. Robot chassis design
        3. Installing LibreCAD, Blender, and MeshLab
          1. Installing LibreCAD
          2. Installing Blender
          3. Installing MeshLab
        4. Creating a 2D CAD drawing of the robot using LibreCAD
          1. The base plate design
          2. Base plate pole design
          3. Wheel, motor, and motor clamp design
          4. Caster wheel design
          5. Middle plate design
          6. Top plate design
        5. Working with a 3D model of the robot using Blender
          1. Python scripting in Blender
          2. Introduction to Blender Python APIs
          3. Python script of the robot model
        6. Questions
        7. Summary
      10. 3. Working with Robot Simulation Using ROS and Gazebo
        1. Understanding robotic simulation
          1. Mathematical modeling of the robot
            1. Introduction to the differential steering system and robot kinematics
            2. Explaining of the forward kinematics equation
            3. Inverse kinematics
          2. Introduction to ROS and Gazebo
            1. ROS Concepts
              1. The ROS filesystem
              2. The ROS Computation Graph
              3. The ROS community level
          3. Installing ROS Indigo on Ubuntu 14.04.2
            1. Introducing catkin
            2. Creating an ROS package
            5. Introducing Gazebo
            6. Installing Gazebo
            7. Testing Gazebo with the ROS interface
            8. Installing TurtleBot Robot packages on ROS Indigo
            9. Installing TurtleBot ROS packages using the apt package manager in Ubuntu
            10. Simulating TurtleBot using Gazebo and ROS
            11. Creating the Gazebo model from TurtleBot packages
            12. What is a robot model, URDF, xacro, and robot state publisher?
            13. Creating a ChefBot description ROS package
              1. chefbot_base_gazebo.urdf.xacro
              2. kinect.urdf.xacro
              3. chefbot_base.urdf.xacro
          4. Simulating ChefBot and TurtleBot in a hotel environment
        2. Questions
        3. Summary
      11. 4. Designing ChefBot Hardware
        1. Specifications of the ChefBot hardware
        2. Block diagram of the robot
          1. Motor and encoder
            1. Selecting motors, encoders, and wheels for the robot
          2. Motor driver
            1. Selecting a motor driver/controller
              1. Input pins
              2. Output pins
              3. Power supply pins
          3. Embedded controller board
          4. Ultrasonic sensors
            1. Selecting the ultrasonic sensor
          5. Inertial Measurement Unit
          6. Kinect
          7. Central Processing Unit
          8. Speakers/ mic
          9. Power supply/battery
        3. Working of the ChefBot hardware
        4. Questions
        5. Summary
      12. 5. Working with Robotic Actuators and Wheel Encoders
        1. Interfacing DC geared motor with Tiva C LaunchPad
          1. Differential wheeled robot
          2. Installing the Energia IDE
          3. Interfacing code
        2. Interfacing quadrature encoder with Tiva C Launchpad
          1. Processing encoder data
          2. Quadrature encoder interfacing code
        3. Working with Dynamixel actuators
        4. Questions
        5. Summary
      13. 6. Working with Robotic Sensors
        1. Working with ultrasonic distance sensors
          1. Interfacing HC-SR04 to Tiva C LaunchPad
            1. Working of HC-SR04
            2. Interfacing code of Tiva C LaunchPad
            3. Interfacing Tiva C LaunchPad with Python
        2. Working with the IR proximity sensor
        3. Working with Inertial Measurement Unit
          1. Inertial Navigation
          2. Interfacing MPU 6050 with Tiva C LaunchPad
            1. Setting up the MPU 6050 library in Energia
          3. Interfacing code of Energia
        4. Interfacing MPU 6050 to Launchpad with the DMP support using Energia
        5. Questions
        6. Summary
      14. 7. Programming Vision Sensors Using Python and ROS
        1. List of robotic vision sensors and image processing libraries
        2. Introduction to OpenCV, OpenNI, and PCL
          1. What is OpenCV?
            1. Installation of OpenCV from source code in Ubuntu 14.04.2
            2. Reading and displaying an image using the Python-OpenCV interface
            3. Capturing from web camera
          2. What is OpenNI
            1. Installing OpenNI in Ubuntu 14.04.2
          3. What is PCL?
        3. Programming Kinect with Python using ROS, OpenCV, and OpenNI
          1. How to launch OpenNI driver
          2. The ROS interface of OpenCV
            1. Creating ROS package with OpenCV support
            2. Displaying Kinect images using Python, ROS, and cv_bridge
        4. Working with Point Clouds using Kinect, ROS, OpenNI, and PCL
          1. Opening device and Point Cloud generation
        5. Conversion of Point Cloud to laser scan data
        6. Working with SLAM using ROS and Kinect
        7. Questions
        8. Summary
      15. 8. Working with Speech Recognition and Synthesis Using Python and ROS
        1. Understanding speech recognition
          1. Block diagram of a speech recognition system
          2. Speech recognition libraries
            1. CMU Sphinx/Pocket Sphinx
            2. Julius
          3. Windows Speech SDK
          4. Speech synthesis
          5. Speech synthesis libraries
            1. eSpeak
            2. Festival
        2. Working with speech recognition and synthesis in Ubuntu 14.04.2 using Python
          1. Setting up Pocket Sphinx and its Python binding in Ubuntu 14.04.2
          2. Working with Pocket Sphinx Python binding in Ubuntu 14.04.2
          3. Output
        3. Real-time speech recognition using Pocket Sphinx, GStreamer, and Python in Ubuntu 14.04.2
        4. Speech recognition using Julius and Python in Ubuntu 14.04.2
          1. Installation of Julius speech recognizer and Python module
          2. Python-Julius client code
          3. Improving speech recognition accuracy in Pocket Sphinx and Julius
          4. Setting up eSpeak and Festival in Ubuntu 14.04.2
        5. Working with speech recognition and synthesis in Windows using Python
          1. Installation of the Speech SDK
        6. Working with Speech recognition in ROS Indigo and Python
          1. Installation of the pocketsphinx package in ROS Indigo
        7. Working with speech synthesis in ROS Indigo and Python
        8. Questions
        9. Summary
      16. 9. Applying Artificial Intelligence to ChefBot Using Python
        1. Block diagram of the communication system in ChefBot
        2. Introduction to AIML
          1. Introduction to AIML tags
        3. Introduction to PyAIML
          1. Installing PyAIML on Ubuntu 14.04.2
          2. Installing PyAIML from source code
        4. Working with AIML and Python
          1. Loading a single AIML file from the command-line argument
        5. Working with A.L.I.C.E. AIML files
          1. Loading AIML files into memory
          2. Loading AIML files and saving them in brain files
          3. Loading AIML and brain files using the Bootstrap method
        6. Integrating PyAIML into ROS
          5. start_chat.launch
          6. start_tts_chat.launch
          7. start_speech_chat.launch
        7. Questions
        8. Summary
      17. 10. Integration of ChefBot Hardware and Interfacing it into ROS, Using Python
        1. Building ChefBot hardware
        2. Configuring ChefBot PC and setting ChefBot ROS packages
        3. Interfacing ChefBot sensors with Tiva C LaunchPad
          1. Embedded code for ChefBot
        4. Writing a ROS Python driver for ChefBot
        5. Understanding ChefBot ROS launch files
        6. Working with ChefBot Python nodes and launch files
          1. Working with SLAM on ROS to build the map of the room
          2. Working with ROS localization and navigation
        7. Questions
        8. Summary
      18. 11. Designing a GUI for a Robot Using Qt and Python
        1. Installing Qt on Ubuntu 14.04.2 LTS
        2. Working with Python bindings of Qt
          1. PyQt
            1. Installing PyQt on Ubuntu 14.04.2 LTS
          2. PySide
            1. Installing PySide on Ubuntu 14.04.2 LTS
        3. Working with PyQt and PySide
          1. Introducing Qt Designer
          2. Qt signals and slots
          3. Converting a UI file into Python code
          4. Adding a slot definition to PyQt code
          5. Up and running of Hello World GUI application
        4. Working with ChefBot's control GUI
          1. Installing and working with rqt in Ubuntu 14.04.2 LTS
        5. Questions
        6. Summary
      19. 12. The Calibration and Testing of ChefBot
        1. The Calibration of Xbox Kinect using ROS
          1. Calibrating the Kinect RGB camera
          2. Calibrating the Kinect IR camera
        2. Wheel odometry calibration
          1. Error analysis of wheel odometry
          2. Error correction
        3. Calibrating the MPU 6050
        4. Testing of the robot using GUI
          1. Pros and cons of the ROS navigation
        5. Questions
        6. Summary
      20. Index