Learning Robotics using Python
eBook - ePub

Learning Robotics using Python

Design, simulate, program, and prototype an autonomous mobile robot using ROS, OpenCV, PCL, and Python, 2nd Edition

Lentin Joseph

Share book
  1. 280 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learning Robotics using Python

Design, simulate, program, and prototype an autonomous mobile robot using ROS, OpenCV, PCL, and Python, 2nd Edition

Lentin Joseph

Book details
Book preview
Table of contents
Citations

About This Book

Design, simulate, and program interactive robots

Key Features

  • Design, simulate, build, and program an interactive autonomous mobile robot
  • Leverage the power of ROS, Gazebo, and Python to enhance your robotic skills
  • A hands-on guide to creating an autonomous mobile robot with the help of ROS and Python

Book Description

Robot Operating System (ROS) is one of the most popular robotics software frameworks in research and industry. It has various features for implement different capabilities in a robot without implementing them from scratch.

This book starts by showing you the fundamentals of ROS so you understand the basics of differential robots. Then, you'll learn about robot modeling and how to design and simulate it using ROS. Moving on, we'll design robot hardware and interfacing actuators. Then, you'll learn to configure and program depth sensors and LIDARs using ROS. Finally, you'll create a GUI for your robot using the Qt framework.

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

What you will learn

  • Design a differential robot from scratch
  • Model a differential robot using ROS and URDF
  • Simulate a differential robot using ROS and Gazebo
  • Design robot hardware electronics
  • Interface robot actuators with embedded boards
  • Explore the interfacing of different 3D depth cameras in ROS
  • Implement autonomous navigation in ChefBot
  • Create a GUI for robot control

Who this book is for

This book is for those who are conducting research in mobile robotics and autonomous navigation. As well as the robotics research domain, this book is also for the robot hobbyist community. You're expected to have a basic understanding of Linux commands and Python.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Learning Robotics using Python an online PDF/ePUB?
Yes, you can access Learning Robotics using Python by Lentin Joseph in PDF and/or ePUB format, as well as other popular books in Computer Science & Hardware. We have over one million books available in our catalogue for you to explore.

Information

Year
2018
ISBN
9781788629973
Edition
2

Interfacing Actuators and Sensors to the Robot Controller

In the previous chapter, we discussed the selection of the hardware components needed to build our robot. The important components in a robot are actuators and sensors. Actuators provide mobility to the robot and sensors provide information about the robot environment. In this chapter, we will concentrate on the different types of actuators and sensors that we are going to use in this robot and how they can be interfaced with Tiva C LaunchPad, which is a 32 bit ARM micro controller board from Texas Instruments, working at 80 MHz. We will start by discussing actuators. The actuator that we are going to discuss first is a DC-geared motor with an encoder. A DC-geared motor works using direct current and has gear reduction to reduce the shaft speed and increase the torque of the final shaft. These kinds of motors are very economical and satisfy our robot design requirement. We will use this motor in our robot prototype.
In the first section of this chapter, we will deal with the design of our robot drive system. The drive system of our robot is a differential drive and consists of two DC-geared motors with encoders and a motor driver. The motor driver is controlled by Tiva C LaunchPad. We will look at the interfacing of the motor driver and quadrature encoder with Tiva C Launchpad. After that, we will look at some of the latest actuators that can replace the existing DC-geared motor with an encoder. If the desired robot needs more payload and accuracy, we have to switch to these kinds of actuators. Finally, we will look at some different sensors that are commonly used for robots.
In this chapter, we will cover:
  • Interfacing a DC-geared motor with Tiva C LaunchPad
  • Interfacing a quadrature encoder with Tiva C LaunchPad
  • An explanation of interfacing code
  • Interfacing Dynamixel actuators
  • Interfacing ultrasonic sensors and IR proximity sensors
  • Interfacing inertial measurement units (IMUs)

Technical requirements

You will need the necessary robot hardware component and Energia IDE set up in Ubuntu 16.04 LTS.

Interfacing DC geared motor to Tiva C LaunchPad

In the previous chapter, we selected a DC-geared motor with an encoder from Pololu and an embedded board from Texas Instruments, called Tiva C LaunchPad. We need the following components to interface the motor with LaunchPad:
  • Two Pololu metal gear motors, 37Dx73L mm with 64 counts per revolution encoder
  • Pololu wheel, 90x10 mm and a matching hub
  • Pololu dual VNH2SP30 motor driver carrier, MD03A
  • A sealed lead acid/lithium ion battery of 12V
  • A logic level convertor of 3.3V to 5V; visit https://www.sparkfun.com/products/11978.
  • A Tiva C LaunchPad and its compatible interfacing wires
The following diagram shows the interfacing circuit of two motors using Pololu H-Bridge:
Motor interfacing circuit
To interface with Launchpad, we have to connect a level shifter board in between these two motors. The motor driver works in 5V but the Launchpad works in 3.3V, so we have to connect a level shifter, as shown in the following diagram:
Level shifter circuit
The two geared DC motors are connected to OUT1A, OUT1B, and OUT2A, OUT2B of the motor driver. VIN (+) and GND (-) are the supply voltage of the motor. These DC motors can work with a 12V supply, so we give 12V as the input voltage. The motor driver will support an input voltage ranging from 5.5V to 16V.
The control signals/input pins of the motor drivers are on the left side of the driver. The first pin is 1DIAG/EN; in most cases, we leave this pin disconnected. These pins are externally pulled high in the driver board itself. The main use of this pin is to enable or disable the H-bridge chip. It is also used to monitor the faulty condition of the H-Bridge IC. Pins 1INA and 1INB control the direction of the rotation of the motor. The 1PWM pin will switch the motor to the ON and OFF state. We achieve speed control using PWM pins. The CS pin will sense the output current. It will output 0.13V per Ampere of the output current. The VIN and GND pins give the same input voltage that we supplied for the motor. We are not using these pins here. The +5V(IN) and GND pins are the supply for the motor driver IC. The supply to the motor driver and motors are different.
The following table shows the truth table of the input and output combinations:
INA
INB
DIAGA/ENA
DIAGB/ENB
OUTA
OUTB
CS
Operating mode
1
1
1
1
H
H
High Imp
Brake to Vcc
1
0
1
1
H
L
Isense = Iout / K
Clockwise (CW)
0
1
1
1
L
H
Isense = Iout / K
Counterclockwise (CCW)
0
0
1
1
L
L
High Imp
Breaker to GND
The value DIAG/EN pins are always high because these pins are externally pulled high in the driver board itself. Using the aforementioned signal combinations, we can move the robot in any direction and by adjusting the PWM signal, we can adjust the speed of the motor too. This is the basic logic behind controlling a DC motor using an H-Bridge circuit.
While interfacing motors to Launchpad, we may require a level shifter. This is because the output pins of Launchpad can only supply 3.3V but the motor driver needs 5V to trigger; so, we have to connect 3.3V to the 5V logic level convertor to start working.
The two motors work in a differential drive mechanism. The following section discusses the differential drive and its operation.

Differential wheeled robot

The robot we have designed is a differential wheeled/drive robot. In a differential wheeled robot, the movement is based on two separately driven wheels placed on either side of the robot's body. It can change its direction by changing the relative rate of rotation of its wheels, and hence, doesn't require additional steering motion. To balance the robot, a free turning wheel or caster wheels may be added. The following diagram shows a typical representation of a differential drive:
Differential wheeled robot
If the two motors are in the same direction, the robot will move forward or backward. If one motor has more speed than the other, then the robot turns to the slower motor side; so, to turn left, stop the left motor and move the right motor. The following diagram shows how we connect the two motors in our robot. The two motors are mounted on the opposite sides of the base plate and we put two casters in the front and back of the robot for balancing:
Top view of robot base
Next, we can program the motor controller using Launchpad according to the truth table data. Programming is done using an IDE called Energia (http://energia.nu/). We are programming Launchpad using the C++ language, very simila...

Table of contents