⚡ Build Your Own Robo Buddy! Unleash your inner inventor and bring your robot dreams to life with this ultimate guide ️️. Master the secrets of ROS – the robot whisperer's toolkit – and craft your very own autonomous mobile robot, from pixelated blueprints to polished metal chassis. ️ Navigate uncharted territories, conquer obstacle courses, and even chat with your creation (okay, maybe not chat, but definitely make beeps and boops ). This book is your passport to the exciting world of robot building, packed with hands-on projects, clear explanations, and enough DIY magic to make your circuits sizzle ✨. So grab your soldering iron, fire up your coding skills, and get ready to build a robot that's uniquely yours!
2. Congratulations on purchasing this ebook!
Here's an exclusive list of the Top Crypto Exchanges for you to consider when
registering. These platforms offer excellent opportunities to dive into the exciting
world of cryptocurrencies. Check out the shortened links below and get started
with ease!
1. Binance: the world's leading cryptocurrency exchange, offers a wide range of
trading options and low fees. Registration link: https://mas.so/binance
2. OKX: a popular choice for derivatives trading, provides advanced features
and high liquidity. Registration link: https://mas.so/okx
3. Bybit: known for its copy trading capabilities, allows users to follow
successful traders. Registration link: https://mas.so/bybit
4. Coinbase: a user-friendly US-based exchange, prioritizes security and
compliance. Registration link: https://mas.so/coinbase
5. WhiteBIT: a rapidly growing European exchange, offers a diverse selection of
trading pairs. Registration link: https://mas.so/whitebit
6. Bitforex: a reputable Asian exchange, provides competitive fees and margin
trading. Registration link: https://mas.so/bitforex
7. Bitmart: a popular platform for altcoin trading, offers staking opportunities.
Registration link: https://mas.so/bitmart
8. Gate: an established exchange with advanced features, supports margin
lending and borrowing. Registration link: https://mas.so/gate
9. MEXC: known for its fast matching engine and deep liquidity, caters to
experienced traders. Registration link: https://mas.so/mexc
10. Hotcoin: a user-friendly platform with a focus on emerging markets, offers a
seamless trading experience. Registration link: https://mas.so/hotcoin
11. Huobi (HTX): a renowned Asian exchange, provides diverse trading options
and high liquidity. Registration link: https://mas.so/htx
12. Digifinex: a rising star in the crypto world, offers competitive fees and a
growing user base. Registration link: https://mas.so/digi
Don't wait any longer! Take advantage of these opportunities and embark on
your crypto journey with confidence. Remember, always do your research and
choose the exchange that best suits your needs. Happy trading!
*Disclaimer: All links are provided for convenience and are not endorsed or affili-
ated with this ebook. Users should exercise due diligence and caution when par-
ticipating in any crypto-related activities.*
4. Jump start your path to discovery with the Apress Maker Innovations
series! From the basics of electricity and components through to the most
advanced options in robotics and Machine Learning, you’ll forge a path to
building ingenious hardware and controlling it with cutting-edge software.
All while gaining new skills and experience with common toolsets you can
take to new projects or even into a whole new career.
The Apress Maker Innovations series offers projects-based learning,
while keeping theory and best processes front and center. So you get
hands-on experience while also learning the terms of the trade and how
entrepreneurs, inventors, and engineers think through creating and
executing hardware projects. You can learn to design circuits, program AI,
create IoT systems for your home or even city, and so much more!
Whether you’re a beginning hobbyist or a seasoned entrepreneur
working out of your basement or garage, you’ll scale up your skillset to
become a hardware design and engineering pro. And often using
low-cost and open-source software such as the Raspberry Pi, Arduino, PIC
microcontroller, and Robot Operating System (ROS). Programmers and
software engineers have great opportunities to learn, too, as many projects
and control environments are based in popular languages and operating
systems, such as Python and Linux.
If you want to build a robot, set up a smart home, tackle assembling a
weather-ready meteorology system, or create a brand-new circuit using
breadboards and circuit design software, this series has all that and more!
Written by creative and seasoned Makers, every book in the series tackles
both tested and leading-edge approaches and technologies for bringing
your visions and projects to life.
More information about this series at https://link.springer.com/
bookseries/17311.
7. To nature, for gifting this wonderful life and a loving family
8. vii
Table of Contents
About the Author������������������������������������������������������������������������������xvii
About the Technical Reviewer�����������������������������������������������������������xix
Introduction���������������������������������������������������������������������������������������xxi
Chapter 1:
Introduction to Robotics: Part I�������������������������������������������1
Outline��������������������������������������������������������������������������������������������������������1
The History of Robotics������������������������������������������������������������������������������1
Definition of a Robot�����������������������������������������������������������������������������������4
Generations of Robots��������������������������������������������������������������������������������5
First Generation�����������������������������������������������������������������������������������������������6
Second Generation������������������������������������������������������������������������������������������6
Third Generation����������������������������������������������������������������������������������������������6
Fourth Generation and Above��������������������������������������������������������������������������7
Basic Mathematics for Robotics�����������������������������������������������������������������7
Coordinate Frames������������������������������������������������������������������������������������������7
Transformations�����������������������������������������������������������������������������������������������8
2D Translation��������������������������������������������������������������������������������������������������9
2D Rotation����������������������������������������������������������������������������������������������������11
2
D Translation and Rotation���������������������������������������������������������������������������13
Kinematics of Mobile Robots��������������������������������������������������������������������15
Forward Differential Kinematics��������������������������������������������������������������������16
Inverse Differential Kinematics���������������������������������������������������������������������18
9. viii
Basic Electronics for Robotics������������������������������������������������������������������18
Single-Board Computer (SBC)�����������������������������������������������������������������������19
Single-Board Microcontroller (SBM)��������������������������������������������������������������21
Motor Controller��������������������������������������������������������������������������������������������21
Motor�������������������������������������������������������������������������������������������������������������23
Encoder���������������������������������������������������������������������������������������������������������28
Lidar��������������������������������������������������������������������������������������������������������������31
Battery�����������������������������������������������������������������������������������������������������������32
Proximity Sensor�������������������������������������������������������������������������������������������34
IMU����������������������������������������������������������������������������������������������������������������35
Drive Systems for Mobile Robots�������������������������������������������������������������36
Differential Drive��������������������������������������������������������������������������������������������38
Skid Steer������������������������������������������������������������������������������������������������������39
Tricycle����������������������������������������������������������������������������������������������������������40
Ackermann����������������������������������������������������������������������������������������������������40
Omni-Directional�������������������������������������������������������������������������������������������41
Mecanum�������������������������������������������������������������������������������������������������������42
Ball-bot����������������������������������������������������������������������������������������������������������43
Summary��������������������������������������������������������������������������������������������������43
Chapter 2:
Introduction to Robotics: Part II����������������������������������������45
Outline������������������������������������������������������������������������������������������������������45
Basic 3D Modeling and 3D Printing����������������������������������������������������������45
3D Modeling��������������������������������������������������������������������������������������������������46
3D Printing�����������������������������������������������������������������������������������������������������47
Basic Linux�����������������������������������������������������������������������������������������������52
Basic Linux Commands���������������������������������������������������������������������������������52
Basic Programming����������������������������������������������������������������������������������71
Table of Contents
11. x
Chapter 4: The ROS Framework��������������������������������������������������������131
Outline����������������������������������������������������������������������������������������������������131
What Is ROS?������������������������������������������������������������������������������������������132
Why Use ROS?����������������������������������������������������������������������������������������132
Applications of ROS��������������������������������������������������������������������������������134
The ROS Architecture�����������������������������������������������������������������������������135
The Filesystem��������������������������������������������������������������������������������������������136
The Computation Graph�������������������������������������������������������������������������������142
The ROS Community������������������������������������������������������������������������������������148
Creating a Workspace and Building It����������������������������������������������������151
Publishers/Subscribers��������������������������������������������������������������������������157
Services�������������������������������������������������������������������������������������������������159
Actions���������������������������������������������������������������������������������������������������160
Implementing the Publisher/Subscriber Using Python���������������������������163
Publisher Code��������������������������������������������������������������������������������������������163
Code Description�����������������������������������������������������������������������������������������164
Subscriber Code������������������������������������������������������������������������������������������167
Code Description�����������������������������������������������������������������������������������������167
Implementing the Service Using Python������������������������������������������������169
Service Server���������������������������������������������������������������������������������������������169
Service Client����������������������������������������������������������������������������������������������170
Service Server Code������������������������������������������������������������������������������������170
Code Description�����������������������������������������������������������������������������������������171
Service Client Code�������������������������������������������������������������������������������������173
Code Description�����������������������������������������������������������������������������������������174
Implementing Actions Using Python�������������������������������������������������������177
Action Server Code��������������������������������������������������������������������������������������178
Table of Contents
12. xi
Code Description�����������������������������������������������������������������������������������������180
Action Client Code���������������������������������������������������������������������������������������184
Code Description�����������������������������������������������������������������������������������������186
Creating Custom Messages, Custom Service Definitions, and Custom
Actions���������������������������������������������������������������������������������������������������189
Create a Custom Message Definition����������������������������������������������������������189
Create a Custom Service Definition�������������������������������������������������������������199
Create a Custom Action Definition���������������������������������������������������������������210
Basic ROS, Catkin, and Git Commands���������������������������������������������������224
ROS Debugging Tools�����������������������������������������������������������������������������234
Visual Studio Code���������������������������������������������������������������������������������������234
Catkin_make/Catkin build���������������������������������������������������������������������������234
RViz��������������������������������������������������������������������������������������������������������������235
Rqt_graph����������������������������������������������������������������������������������������������������235
Rosbag���������������������������������������������������������������������������������������������������������235
Rqt_reconfigure�������������������������������������������������������������������������������������������235
Tf View Frames��������������������������������������������������������������������������������������������236
Rqt_console�������������������������������������������������������������������������������������������������237
Rqt_logger_level�����������������������������������������������������������������������������������������238
Rqt_launchtree��������������������������������������������������������������������������������������������240
Rqt���������������������������������������������������������������������������������������������������������������241
Rosnode/rostopic/rosservice list�����������������������������������������������������������������243
Rosnode/rostopic/rosservice info����������������������������������������������������������������244
Rqt_top��������������������������������������������������������������������������������������������������������246
Roswtf���������������������������������������������������������������������������������������������������������246
Coordinate Transformation in ROS���������������������������������������������������������247
Example�������������������������������������������������������������������������������������������������������248
Right-Hand Rule for Coordinate Transformation������������������������������������������250
Table of Contents
13. xii
ROS Navigation Stack�����������������������������������������������������������������������������253
Move Base���������������������������������������������������������������������������������������������������255
Sensor Nodes����������������������������������������������������������������������������������������������256
Sensor Transforms���������������������������������������������������������������������������������������257
Odometry�����������������������������������������������������������������������������������������������������257
Base Controller��������������������������������������������������������������������������������������������258
Map Server��������������������������������������������������������������������������������������������������258
AMCL�����������������������������������������������������������������������������������������������������������258
Summary������������������������������������������������������������������������������������������������259
Chapter 5:
Robot Simulation and Visualization��������������������������������261
Outline����������������������������������������������������������������������������������������������������261
Simulation and Visualization������������������������������������������������������������������261
Gazebo���������������������������������������������������������������������������������������������������262
RViz��������������������������������������������������������������������������������������������������������263
Turtlebot3: Mobile Robot������������������������������������������������������������������������265
Setting Turtlebot3 Up�����������������������������������������������������������������������������������265
Simulation���������������������������������������������������������������������������������������������������266
Teleoperation�����������������������������������������������������������������������������������������������267
Mapping�������������������������������������������������������������������������������������������������������268
Navigation���������������������������������������������������������������������������������������������������270
OpenMANIPULATOR-X: Robot Arm����������������������������������������������������������271
Setting Up OpenMANIPULATOR-X����������������������������������������������������������������271
Simulation���������������������������������������������������������������������������������������������������272
Controlling the Arm��������������������������������������������������������������������������������������273
Turtlebot3 with OpenMANIPULATOR-X: Mobile Manipulator�������������������276
Setting Up����������������������������������������������������������������������������������������������������276
Simulation���������������������������������������������������������������������������������������������������277
Table of Contents
14. xiii
Visualization and Motion Planning���������������������������������������������������������������278
Teleoperation�����������������������������������������������������������������������������������������������280
Mapping�������������������������������������������������������������������������������������������������������281
Navigation���������������������������������������������������������������������������������������������������283
Summary������������������������������������������������������������������������������������������������284
Chapter 6: Arduino and ROS�������������������������������������������������������������285
Outline����������������������������������������������������������������������������������������������������285
Arduino Basics���������������������������������������������������������������������������������������285
Arduino Board Models���������������������������������������������������������������������������������286
Arduino Programming Basics�����������������������������������������������������������������289
Arduino Examples����������������������������������������������������������������������������������294
LED Blink�����������������������������������������������������������������������������������������������������294
Buzzer����������������������������������������������������������������������������������������������������������297
Switch���������������������������������������������������������������������������������������������������������301
LCD Display�������������������������������������������������������������������������������������������������305
Interfacing Arduino with ROS�����������������������������������������������������������������309
Installation���������������������������������������������������������������������������������������������������309
Arduino and ROS Integration Examples��������������������������������������������������315
LED Blink Using ROS Publisher-Subscriber�������������������������������������������������315
LED Trigger Using the ROS Service��������������������������������������������������������������319
Buzzer Control Using the ROS Publisher-
Subscriber�����������������������������������322
Switch Control Using the ROS Publisher-
Subscriber�����������������������������������327
LCD Control Using the ROS Publisher-Subscriber���������������������������������������330
Summary������������������������������������������������������������������������������������������������334
Table of Contents
15. xiv
Chapter 7:
Simulating Bumblebot: A Simple Two-Wheeled Robot����335
Outline����������������������������������������������������������������������������������������������������335
Preliminary Setup�����������������������������������������������������������������������������������336
Building the Robot Model (URDF)�����������������������������������������������������������338
Links������������������������������������������������������������������������������������������������������������340
Joints�����������������������������������������������������������������������������������������������������������341
URDF������������������������������������������������������������������������������������������������������������342
Designing Robot Parts Using 3D Modeling Software�����������������������������354
Using the 3D Models in URDF�����������������������������������������������������������������355
Robot Visualization���������������������������������������������������������������������������������357
Robot Simulation������������������������������������������������������������������������������������360
Teleoperation������������������������������������������������������������������������������������������365
Teleoperation Using the Keyboard���������������������������������������������������������������365
Teleoperation Using a Joystick��������������������������������������������������������������������369
Teleoperation Using an Android Device�������������������������������������������������������371
Mapping�������������������������������������������������������������������������������������������������374
Navigation����������������������������������������������������������������������������������������������382
Tuning Navigation�����������������������������������������������������������������������������������390
Summary������������������������������������������������������������������������������������������������394
Chapter 8:
Building Bumblebot in Hardware������������������������������������395
Outline����������������������������������������������������������������������������������������������������395
The Preliminary Robot Setup Process����������������������������������������������������396
Udev Rules���������������������������������������������������������������������������������������������400
Defining Rules���������������������������������������������������������������������������������������������400
Configuring Arduino to Control Peripherals��������������������������������������������403
3
D Printing the Robot Parts��������������������������������������������������������������������404
Table of Contents
16. xv
Electronics����������������������������������������������������������������������������������������������406
Assembling and Wiring���������������������������������������������������������������������������408
Wiring����������������������������������������������������������������������������������������������������������409
Assembling the Robot���������������������������������������������������������������������������������411
Motor Gear Ratio Calculation������������������������������������������������������������������414
Custom Motor Driver and ROS Interface������������������������������������������������417
Differential Driver and Odometry�����������������������������������������������������������418
twist_to_motors.py�������������������������������������������������������������������������������������419
diff_tf.py������������������������������������������������������������������������������������������������������420
Teleoperation������������������������������������������������������������������������������������������421
Teleoperation Using Keyboard���������������������������������������������������������������������421
Odometry Correction������������������������������������������������������������������������������427
Rotation Test������������������������������������������������������������������������������������������������427
Translation Test��������������������������������������������������������������������������������������������429
Map Building������������������������������������������������������������������������������������������431
Autonomous Navigation�������������������������������������������������������������������������432
Tuning the Navigation�����������������������������������������������������������������������������433
Robot Upstart�����������������������������������������������������������������������������������������437
Autonomous Delivery Application�����������������������������������������������������������438
Summary������������������������������������������������������������������������������������������������455
Chapter 9:
Additional Sensors and Sensor Fusion���������������������������457
Outline����������������������������������������������������������������������������������������������������457
Odometry Sensors����������������������������������������������������������������������������������457
Lidar Based Odometry����������������������������������������������������������������������������459
Installation���������������������������������������������������������������������������������������������������460
Configuration�����������������������������������������������������������������������������������������������461
Table of Contents
17. xvi
Simulation Using Bumblebot�����������������������������������������������������������������������463
IMU-Based Odometry�����������������������������������������������������������������������������475
Adding IMU to the Robot������������������������������������������������������������������������������475
Running the Simulation�������������������������������������������������������������������������������480
Sensor Fusion�����������������������������������������������������������������������������������������483
Installation���������������������������������������������������������������������������������������������������485
Configuration�����������������������������������������������������������������������������������������������485
Simulation���������������������������������������������������������������������������������������������������490
Summary������������������������������������������������������������������������������������������������496
Chapter 10:
Web Interface and Autodocking������������������������������������497
Outline����������������������������������������������������������������������������������������������������497
Web Interface�����������������������������������������������������������������������������������������497
Web Interface in ROS�����������������������������������������������������������������������������������499
Installing ROSBridge������������������������������������������������������������������������������������500
Building a Simple Web Page������������������������������������������������������������������������500
Launch File��������������������������������������������������������������������������������������������������509
Simulation with the Web Interface��������������������������������������������������������������513
Autodocking�������������������������������������������������������������������������������������������515
Autodocking Using ROS�������������������������������������������������������������������������������516
Installation���������������������������������������������������������������������������������������������������517
Configuration�����������������������������������������������������������������������������������������������518
Simulation���������������������������������������������������������������������������������������������������545
Summary������������������������������������������������������������������������������������������������549
Index�������������������������������������������������������������������������������������������������551
Table of Contents
18. xvii
About the Author
Rajesh Subramanian is a robotics engineer
by profession and founder of ThunDroids LLP
(a robotics manufacturing and service firm).
He has more than eight years of experience
in the industry and research areas. He holds
a post-graduate degree from the University of
Queensland, Australia and a research degree
from Edith Cowan University, Australia. Rajesh
has worked with humanoid service robots,
mobile robots, robot arms, and modular
robots in both industry and academics settings, and he published a
research paper on modular robots at the IEEE TENCON 2013 international
conference. He also works as a robotics educator and has published
courses on autonomous robots.
19. xix
About the Technical Reviewer
Massimo Nardone has more than 26 years
of experience in security, web/mobile
development, and cloud and IT architecture.
His true IT passions are security and Android.
He has been programming and teaching
others how to program with Android, Perl,
PHP, Java, VB, Python, C/C++, and MySQL
for more than 25 years. He holds a Master of
Science degree in computing science from the
University of Salerno, Italy. He has worked as a
Chief Information Security Office (CISO), software engineer, chief security
architect, security executive, and an OT/IoT/IIoT security leader and
architect for many years.
20. xxi
Introduction
In this book, you will start from scratch and build a variety of features for
autonomous mobile robots, both in simulation and hardware. This book
shows you how to simulate an autonomous mobile robot using ROS and
then work with its hardware implementation.
It starts by teaching the basic theoretical concepts, including history,
mathematics, electronics, mechanical aspects, 3D modeling, 3D printing,
Linux, and programming.
In the subsequent portions of the book, you learn about kinematics, how
to simulate and visualize a robot, interface Arduino with ROS, teleoperate
the robot, perform mapping, do autonomous navigation, add other sensors,
perform sensor fusion, match laser scans, create a web interface, perform
autodocking, and more. Not only do you learn the theoretical parts, but you
also review the hardware realization of mobile robots.
Projects start by building a very basic two-wheeled mobile robot
and work up to complex features such as mapping, navigation, sensor
fusion, web interface, autodocking, etc. By the end of the book, you’ll have
incorporated important robot algorithms including SLAM, path finding,
localization, Kalman filters, and more!
What You Learn in This Book
In this book, you learn how to:
• Design and build a customized physical robot with
autonomous navigation capability
• Create a map of your house using the Lidar scanner of
the robot
21. xxii
• Command your robot to go to any accessible location
on the map you created
• Interact with the robot using a mobile app, joystick,
keyboard, pushbutton, or remote computer
• Monitor robot updates via LCD, mobile app, sound,
and status LEDs
• Automate delivery of a small payload and return to
home base
• Use sensor fusion to improve accuracy
• Create a web interface to monitor and control the robot
remotely
• Use autodocking to home base for battery charging
Who This Book Is For
This book is for complete beginners who want to build customized robots
from scratch. No prerequisite knowledge is expected, although basic
programming knowledge will be handy.
Introduction
23. 2
The creatures had such astonishing strength, stamina, and lack of
emotions, that they could unceasingly perform tasks without needing rest,
food, or remuneration. They also did not laugh or cry, and never required
love, companionship, or friendship. They worked all the time, obeying the
commands of their human masters without complaint. In the beginning,
everything went as envisioned and the beings were happy to work for their
creators. But as time progressed, these synthetic servants became fed up
serving their overlords and decided to take over. One day they escaped
from the island factory and destroyed all of mankind, taking over the entire
planet! These astonishing beings were called “robots.”
Now relax, this is simply the plot of a science-fiction play called
“R.U.R.” by a Czech writer named Karel Čapek (see Figure 1-1).
R.U.R. stands for Rossumovi Univerzální Roboti (Rossum’s Universal
Robots in English) and was written more than a century ago, in 1920.
Figure 1-1. A depiction of the robots in the island factory mentioned
in R.U.R.
Chapter 1 Introduction to Robotics: Part I
24. 3
The word “robot,” coined in this play, is derived from the Czech
word “robota,” which means “forced labor.” Thenceforth, robots have
been portrayed in various platforms, including stories, comics, cartoons,
movies, and so on. Isaac Asimov, one of the greatest science fiction writers,
coined the word “robotics” in his story called “Liar!” in 1941. Soon after, in
1942, he wrote a short story called “Runaround” in which the three “laws
of robotics” were put forth. They state three rules that must be followed
by robots:
1. A robot cannot injure a human being or, through
inaction, allow a human being to come to harm.
2. A robot must obey the orders given to it by human
beings, except where such orders would conflict
with the First Law.
3. A robot must protect its existence as long as such
protection does not conflict with the First or
Second Law.
As we move from fiction to reality, the predecessors of real-world
robots can be traced back to some fascinating clockwork machines known
as “automatons.” These automatons were essentially mechanical devices
composed of a series of gears powered by some means, such as a wind-
up spring. They were not intelligent devices, but could perform some
mesmerizing actions. Some examples of automatons include Maillardet’s
automaton (created around 1800), which could write poems and create
detailed drawings, and Vaucanson’s automaton (also known as the
“digestive duck” and made in 1739), which resembled a duck that could eat
grains, digest food, and excrete it.
The first modern digital programmable robot called “Unimate” was
created by George C. Devol in 1954. Unimate was a robotic arm. Later,
George C. Devol established a partnership with Joseph F. Engelberger,
which paved the way for the robotics revolution, and robots entered
Chapter 1 Introduction to Robotics: Part I
25. 4
mainstream industries to assist with manufacturing and handling
dangerous jobs. Joseph F. Engelberger worked throughout his life in the
field of robotics; he is called the “Father of Robotics” as a tribute to his
tireless contributions.
Presently, robots come in all shapes and sizes and serve in a variety
of areas, including agriculture, space exploration, healthcare, disaster
management, security, entertainment, and so on. Some popular real-
world robots of modern times include the Perseverance (the space rover),
Sophia (a humanoid robot), DJI Mavic (a drone), Atlas (an agile humanoid
robot), Pepper (a humanoid service robot), Aibo (a robotic dog), Robonaut
(a robotic humanoid astronaut), and UR10 (a robotic arm).
Definition of a Robot
A robot is a device that can perform a certain task or set of tasks by
gathering information about its environment, developing a strategy, and
performing actions to achieve the goal. A robot can also adjust its behavior
to accomplish the task even in the case of unforeseen circumstances (to a
certain degree).
The three basic operations of a robot are described here and presented
in Figure 1-2:
Sense: Gather information about the working
environment
Plan: Develop a strategy to achieve the goal
Act: Execute operations based on the plan
Chapter 1 Introduction to Robotics: Part I
26. 5
Figure 1-2. Basic operations of a robot
For instance, consider a household vacuum robot. Its various
operations involve:
Sense: Sensing may involve detecting the obstacles
(such as doors, fridges, people), detecting dirt,
and so on.
Plan: Planning might involve finding a path to
cover all the areas of the house to clean, avoiding
obstacles along the way.
Act: Action could involve moving according to the
planned path, picking up dirt along the way, and
coming back to the home position after cleaning or
when the battery is running low.
Generations of Robots
Based on the advancements in the capabilities and technologies, the
evolution of robots can be broadly categorized into four generations.
Chapter 1 Introduction to Robotics: Part I
27. 6
First Generation
The robots in this generation were basic mechanical arms used for
industrial purposes. They were used to performing dangerous, strenuous,
and repetitive tasks. Some of the tasks performed included painting
surfaces, welding metals, picking and placing massive objects, handling
hazardous materials, and so on. The robots had to be constantly
supervised to ensure accuracy. These robots were popular during
1960-1980.
Second Generation
With the dawn of computers and computer programs, robots could be
controlled with pre-programmed instructions from a computer. The
robots in this generation used basic intelligence when performing tasks.
They could sense the environment using various sensors, like pressure
sensors, ultrasound sensors, lidars, cameras, and so on. A computer would
process the sensory inputs and decide the actions of the robot accordingly.
Even though they were controlled by computers, they needed occasional
supervision.
Third Generation
The advancements in artificial intelligence paved the way for the third
generation of robots. These robots are autonomous and require minimal
or no supervision. Present robots fall into this category, including the
Perseverance rover, Sophia, Atlas, and so on.
Chapter 1 Introduction to Robotics: Part I
28. 7
Fourth Generation and Above
Futuristic robots with advanced capabilities and extraordinary
intelligence, capable of evolving and reproducing on their own and so on,
could be categorized in this generation. These types of robots do not exist
yet. Robots after the fourth generation have not yet been designed and
reside beyond our imaginations.
Basic Mathematics for Robotics
Coordinate Frames
René Descartes, a renowned French philosopher and mathematician,
invented the concept of coordinate frames in the 17th
Century. To define
the position and orientation (a portmanteau known as pose) of any
object, you need a reference. This reference is called a frame of reference
or a coordinate system. You cannot define the pose of an object without
specifying a frame of reference. A real-world example of a coordinate
frame is the latitude and longitude of the earth, and you can define any
location in the globe using these coordinates. In another instance, suppose
you have a robot in a room and want to specify the position of the robot.
For that, you need to have a frame of reference, or a coordinate system.
Assuming that a corner of the room is the origin, you can specify the
x, y and z distances to the robot. There are several coordinate systems,
including cartesian, polar, cylindrical, and spherical. This book primarily
uses the cartesian coordinate system to define the position and orientation
of objects.
Chapter 1 Introduction to Robotics: Part I
29. 8
Figure 1-3. Coordinate frame example
For example, say you have a robot whose center of mass is placed at
a distance of x=30cm, y=40cm, and z=0cm from the origin of the frame of
reference. This could be depicted visually as shown in Figure 1-3.
Transformations
Transformation is the process of defining the pose of an object with
respect to another frame of reference. For instance, a robot wants to
perform navigation in a room containing some obstacles. Let’s assume that
you have two frames of reference—the room frame (whose origin is located
in the southwest corner) and the robot frame (whose origin is located in
the center of mass). The position of the goal is specified wrt (with respect
to) the room frame. This allows the robot to compute a global path from
the starting point to the goal.
When the robot detects an obstacle, the pose of the obstacle is
obtained wrt the robot’s frame. Now, to compute a new path to avoid the
obstacle, you need to convert the obstacle’s pose from the robot frame
to the room frame. This conversion between various frames is called
coordinate transformation.
Chapter 1 Introduction to Robotics: Part I
30. 9
In the context of robotics, all the objects are considered rigid bodies
(i.e., their shapes and sizes remain constant) and the motion of objects
is rigid (i.e., the pose of objects changes without any alteration in their
shapes or sizes).
There are two types of frame transformations—translation and
rotation. If an object changes position, it is called translation and if an
object changes its orientation, it is called rotation.
2D Translation
Figure 1-4. Translation in 2D
Chapter 1 Introduction to Robotics: Part I
31. 10
Suppose that you have an object at position (x,y) wrt coordinate frame F2.
If you want to find the position of the object wrt another frame, say F1,
that is in the same orientation as the previous frame, you need to perform
translation using this formula:
F x F x xd
1 2
= +
F y F y yd
1 2
= +
Where:
F1
x = x position of the object wrt frame F1
F2
x = x position of the object wrt frame F2
xd = x distance between origins of frames F1 and F2
F1
y = y position of the object wrt frame F1
F2
y = y position of the object wrt frame F2
yd = y distance between origins of frames F1 and F2
For example, in Figure 1-4, you can see that the object is at position
(3,2) wrt frame F2. To perform translation from coordinate frame F2 to F1,
apply the formula as follows:
F x F x xd
1 2
= +
F y F y yd
1 2
= +
Where:
F2
x = 3
xd = 4
F2
y = 2
yd = 2
Therefore:
F x
1 3 4 7
= + =
F y
1 2 2 4
= + =
Chapter 1 Introduction to Robotics: Part I
32. 11
You can cross-check these (F1
x, F1
y) values by looking at Figure 1-4, the
position of object wrt frame F1.
Also, in matrix format, you can express translation as follows:
F x F y F x F y x y
d d
1 1 2 2
[ ]= [ ]+[ ]
The matrix [xd yd ] is known as a translation matrix and it indicates the
difference in the positions between the origins of two coordinate frames.
2D Rotation
Figure 1-5. Rotation in 2D
Chapter 1 Introduction to Robotics: Part I
33. 12
Suppose that you have an object at position (x,y) wrt coordinate frame F2.
If you want to find the position of the object wrt another frame (say F1) that
is at the same origin as the previous frame but with a different orientation,
you need to perform rotation using this formula:
F x F x Cos F y Sin
1 2 2
= ∗ − ∗
θ θ
F y F x Sin F y Cos
1 2 2
= ∗ + ∗
θ θ
Where:
F1
x = x position of the object wrt frame F1
F2
x = x position of the object wrt frame F2
F1
y = y position of the object wrt frame F1
F2
y = y position of the object wrt frame F2
θ = angle between axes of frames F1 and F2
For example, in Figure 1-5, you can see that the object is at position
(3,2) wrt frame F2. To perform rotation from coordinate frame F2 to F1, you
can apply the formula as follows:
F x F x Cos F y Sin
1 2 2
= ∗ − ∗
θ θ
F y F x Sin F y Cos
1 2 2
= ∗ + ∗
θ θ
Where:
F2
x = 3
F2
y = 2
θ = 30
Therefore:
F x
1 3 30 2 30 1 598
= ∗ − ∗ =
Cos Sin .
F y
1 3 30 2 30 3 232
= ∗ + ∗ =
Sin Cos .
Chapter 1 Introduction to Robotics: Part I
34. 13
You can cross-check these (F1
x, F1
y) values by looking at Figure 1-5, the
position of the object wrt frame F1.
Also, in matrix format, you can express rotation (anticlockwise
direction) as follows:
F x F y Cos Sin Sin Cos F x F y
1 1 2 2
[ ]= −
[ ]∗[ ]
θ θ θ θ
The matrix [Cosθ − Sinθ Sinθ Cosθ ] is known as a rotation matrix and
it indicates the difference in the rotation between two coordinate frames.
2D Translation and Rotation
Figure 1-6. Translation and rotation in 2D
Chapter 1 Introduction to Robotics: Part I
35. 14
Suppose that you have an object at position (x, y) wrt coordinate frame F2.
Now you want to find the position of the object wrt to another frame (say
F1) whose origin resides at a different location. Also, the two frames have
different orientations. In this case, you need to perform both translation
and rotation using this formula:
F x F x Cos F y Sin xd
1 2 2
= ∗ − ∗ +
θ θ
F y F x Sin F y Cos yd
1 2 2
= ∗ + ∗ +
θ θ
Where:
F1
x = x position of the object wrt frame F1
F2
x = x position of the object wrt frame F2
F1
y = y position of the object wrt frame F1
F2
y = y position of the object wrt frame F2
xd = x distance between origins of frames F1 and F2
yd = y distance between origins of frames F1 and F2
θ = angle between axes of frames F1 and F2
For example, in Figure 1-6, you can see that the object is at position
(3,2) wrt frame F2. To perform translation and rotation from coordinate
frame F2 to F1, you can apply the formula as follows:
F x F x Cos F y Sin xd
1 2 2
= ∗ − ∗ +
θ θ
F y F x Sin F y Cos yd
1 2 2
= ∗ + ∗ +
θ θ
Where:
F2
x = 3
F2
y = 2
θ = 30
xd = 4
yd = 3
Chapter 1 Introduction to Robotics: Part I
36. 15
Therefore:
F x
1 3 30 2 30 4 5 598
= ∗ − ∗ + =
Cos Sin .
F y
1 3 30 2 30 3 6 232
= ∗ + ∗ + =
Sin Cos .
You can cross-check these (F1
x, F1
y) values by looking at Figure 1-6,
which shows the position of object wrt frame F1.
Also, in matrix format, you can express translation and rotation
(anticlockwise direction) as follows:
F x F y Cos Sin x Sin Cos y F x F y
d d
1 1 1 0 01 2 2 1
[ ]= −
[ ]∗[ ]
θ θ θ θ
The matrix [Cosθ − Sinθ xd Sinθ Cosθ yd 0 0 1 ] is known as a
homogeneous transformation matrix. It is a convenient way of
representing the translation and rotation matrices together, using a
single matrix.
Kinematics of Mobile Robots
Kinematics defines the relationship between the robot’s joints and the pose
of the robot. To understand the kinematics of a mobile robot, consider a
simple differential drive robot. In this robot, there are two independent
driving wheels (which can turn at different speeds) attached to the robot
on the same axis. The robot can also have one or two free wheels (caster
wheels) to prevent the robot from falling over. The motion of a differential
drive robot is governed by the speed and direction of rotation of the driving
wheels. For instance, if the robot wants to go straight to the front, the
two driving wheels have to rotate forward at the same speed. If the robot
needs to turn, the two driving wheels need to turn at different speeds. See
Figure 1-7.
Chapter 1 Introduction to Robotics: Part I
37. 16
Figure 1-7. a) Both wheels with equal speed in the forward direction,
b) both wheels with equal speed in the backward direction,
c) left wheel with higher speed, d) right wheel with higher speed,
e) both wheels with equal speed, but in opposite directions
Forward Differential Kinematics
Forward kinematics involves finding the final pose of the robot using its
joint positions as input. In the case of a mobile robot, forward differential
kinematics involves finding the position and orientation of the robot
at a given time by using the left and right wheel velocities as input. The
Chapter 1 Introduction to Robotics: Part I
38. 17
estimate of the robot’s pose from its initial pose is also called odometry.
For example, assuming that the robot starts from pose (x=0, y=0, θ=0) at
time t=0 seconds, and the robot moves one meter along the x-axis for one
second, then the final odometry is (x=1, y=0, θ=0).
In Figure 1-8, the robot has the following parameters:
Figure 1-8. Differential drive robot
• (x,y): Current position of the robot
• θ: Current orientation of the robot
• vl: Velocity of the left wheel
• vr: Velocity of the right wheel
• L: Distance between the center of the wheels
• R: Radius of the wheels
Chapter 1 Introduction to Robotics: Part I
39. 18
To define how the position of the robot changes wrt the changes
in wheel velocities, you can define the forward kinematics equation as
follows:
x
R
v v cos cos
r l
= +
( )
2
θ
y
R
v v sin sin
r l
= +
( )
2
θ
θ = −
( )
R
L
v v
r l
Where:
x : Change in x position
y : Change in y position
θ : Change in orientation
Inverse Differential Kinematics
Inverse kinematics involves finding the individual joint positions to
bring the robot to the desired pose. In the case of a mobile robot, inverse
differential kinematics involves controlling the wheel velocities of the
robot to bring it to the required destination pose. As the robot movements
have constraints, that is, it cannot move along the y-axis (sideways), the
wheel velocities required to reach a pose (x, y, θ) cannot be computed
directly. This is achieved by using motion planning algorithms.
Basic Electronics for Robotics
Electronics is one of the vital elements for building an actual physical
robot. Some of the core electronic components required to build an
autonomous mobile robot include Single-Board Computers (SBC),
Chapter 1 Introduction to Robotics: Part I