Professional Documents
Culture Documents
001 Robotic Operating System and SLAM
001 Robotic Operating System and SLAM
TNGK Ranganath
1
2
Robotic
Operating
System(ROS)
Robotic
Operating
System
Robotic
Operating
System(ROS)
4
Robotic
Operating
System(ROS)
5
Robotic
Operating
System(ROS)
6
Robotic Operating System(ROS)
7
Robotic Operating System(ROS) – Gazebo Simulator
8
Robotic
Operating
System(ROS)
9
Robotic Operating System(ROS) – Turtle
Bots
10
ROS – Turtle BOTS
11
ROS – Turtle
BOTS
12
ROS – Turtle
BOT
Components
13
ROS – Turtle
BOT
Components
14
ROS – Turtle
BOT
Components
• The major differences between two models are the actuators, the SBC(Single Board
Computer) and the Sensors.
15
Robotic
Operating
System(ROS)
16
Robotic Operating System(ROS)
Robotic Operating System(ROS)
18
Robotic Operating System(ROS)
19
Robotic
Operating
System(ROS)
– SLAM
20
Robotic Operating System(ROS)
• An operating system is a software which performs all the basic tasks like file management, memory
management, process management, handling input and output, and controlling peripheral devices such as disk
drives and printers.
• An operating system is software that enables applications to interact with a computer's hardware.
• The software that contains the core components of the operating system is called the kernel.
• The primary purposes of an Operating System are to enable applications (softwares) to interact with a
computer's hardware and to manage a system's hardware and software resources.
• Some popular Operating Systems include Linux Operating System, Windows Operating System, VMS, OS/400,
AIX, z/OS, etc.
• Today, Operating systems is found almost in every device like mobile phones, personal computers, mainframe
computers, automobiles, TV, Toys etc.
23
Operating System(OS)
• Fourth Generation (1979 – Till Date)
• The fourth generation is characterised by the appearance of the personal computer and the
workstation.
• The component technology of the third generation, was replaced by very large scale
integration (VLSI).
• Many Operating Systems which we are using today like Windows, Linux, MacOS etc
developed in the fourth generation.
24
Operating System(OS)
• Following are some of important functions of an operating System.
• Memory Management
• Processor Management
• Device Management
• File Management
• Network Management
• Security
• Control over system performance
• Job accounting
• Error detecting aids
• Coordination between other software and users
25
Operating System(OS)
• Memory Management
• Main memory is a large array of words or bytes where each word or byte has its own
address.
• Main memory provides a fast storage that can be accessed directly by the CPU.
26
Operating System(OS)
• Memory Management
• Keeps tracks of primary memory, i.e., what part of it are in use by whom, what part are not in
use.
• In multiprogramming, the OS decides which process will get memory when and how much.
• De-allocates the memory when a process no longer needs it or has been terminated.
27
Operating System(OS)
• Processor Management - In multiprogramming environment, the OS decides which process gets the
processor when and for how much time.
• Keeps tracks of all devices. Program responsible for this task is known as the I/O controller.
• Decides which process gets the device when and for how much time.
• De-allocates devices.
29
Operating System(OS)
• File Management - A file system is normally organized into directories for easy navigation and usage.
• Keeps track of information, location, uses, status etc. The collective facilities are often known as file
system.
• Security − By means of password and similar other techniques, it prevents unauthorized access to
programs and data.
• Control over system performance − Recording delays between request for a service and response
from the system.
• Job accoun ng − Keeping track of me and resources used by various jobs and users.
• Error detec ng aids − Produc on of dumps, traces, error messages, and other debugging and error
detecting aids.
• Coordination between other softwares and users − Coordina on and assignment of compilers,
interpreters, assemblers and other software to the various users of the computer systems.
31
Operating System(OS)
• What is an Emulator?
• In computing, an emulator is software or hardware that allows one computer system (host) to
function like another computer system.
• Usually, it allows the host machine to run software or use guest system-designed peripheral devices.
• What is a Simulator?
• You can think of a simulator as a device that mimics or simulates an experience, usually making it feel
so real that you'd swear you were driving a car or flying an airplane.
• ROS – Gazebo is a Robotic Simulator
• Many simulators are used in training people to operate vehicles or machinery, while others help teach
medical students how to perform surgery, inject medication, and insert breathing tubes.
• In Latin, simulator means "copier or feigner," from the root similis, "resembling."
32
Robotic Operating System(ROS)
• Robot Operating System or simply ROS is a framework which is used in various fields in the field of
Robotics and Automation.
• It is a good entry point for nonprofessionals into the field of programming Robots.
• What is a Robot ?
• A robot is any system that can perceive the environment that is its surroundings, take decisions based
on the state of the environment and is able to execute the instructions generated.
33
Robotic Operating System(ROS)
• OS and ROS ?
• An Operating system is a software that provides interface between the applications and the hardware.
• It deals with the allocation of resources such as memory, processor time etc. by using scheduling
algorithms and keeps record of the authority of different users, thus providing a security layer.
• It almost always has a low-level program called the kernel that helps in interfacing with the hardware
and is essentially the most important part of any operating system.
• ROS is not an operating system but a meta operating system meaning, that it assumes there is an
underlying operating system that will assist it in carrying out its tasks.
34
Robotic Operating System(ROS)
• ROS and underlying operating system
• It needs an operating system that is open source so the operating system and ROS can be
modified as per the requirements of application.
• Proprietary Operating Systems such as Windows 10 and Mac OS X may put certain limitations
on how we can use them.
• Most people prefer to run ROS on Linux particularly Debian and Ubuntu since ROS has very
good support with Debian based operating systems especially Ubuntu.
• ROS can be run with Mac OS X or Windows 10 with limited support
35
Robotic Operating System(ROS)
• Meta Operating System:
• A Meta Operating system has a huge amount of functionality, so much that it cannot be
classified as a framework or a cluster of libraries but not so much that it can be categorized as
an operating system either.
• It provides functionalities of both Operating Systems as well as frameworks but not fully hence,
it cannot be classified as either e.g, it does not provide the core functionalities that an
operating system is supposed to provide but provides APIs.
36
Robotic Operating System(ROS)
• Developing a robot with a computer brain requires a bunch of software tools on the computer
side—like software drivers, third party tools for computer vision and simulation tools.
• ROS framework gathers all these tools and manages how you develop a code for your robot.
• Instead of reinventing the wheel every time, ROS framework can help you by gathering all
these tools and managing how you develop code for your robot.
• It’s a special framework initially developed by the Stanford AI Laboratory in 2007 for
developing robots.
37
Robotic Operating System(ROS)
• The Open Source Robotics Foundation now maintains ROS.
• ROS is an OS in concept because it provides all the services that any other OS does—like
• hardware abstraction, low-level device control,
• implementation of commonly-used functionality,
• message-passing between processes, and package management.
• ROS can be installed on a single-board computer (SBC) like Raspberry Pi-level and upwards with
Ubuntu/Debian distro
38
Robotic Operating System(ROS)
• How ROS Works?
• In general, ROS consists of code and tools that help your project's code run and do the required
job—including the infrastructure for running it, like messages passing between processes.
• ROS is designed to be a loosely coupled system where a process is called a node and every
node should be responsible for one task.
39
Robotic Operating System(ROS)
• Nodes communicate with each other using
messages passing via logical channels called
topics.
• One of the primary purposes of ROS is to facilitate communication between the ROS modules
called nodes.
• These nodes represent the executable code and the code can reside entirely on one computer,
or nodes can be distributed between computers or between computers and robots.
• The advantage of this distributed structure is that each node can control one aspect of a
system.
• One node can capture and output camera images, and another node can control a robot's
manipulator in response to the camera view.
41
Robotic Operating System(ROS)
• We will see that the turtlesim simulator has two nodes that are created when turtlesim is
executed.
• The nodes themselves are really software modules but with the capability to register with the
ROS Master node and communicate with other nodes in the system.
• The ROS design idea is that each node is an independent module that interacts with other
nodes using the ROS communication capability.
42
Robotic Operating System(ROS)
• One of the strengths of ROS is that a particular task, such as controlling a wheeled mobile
robot, can be separated into a series of simpler tasks.
• The tasks can include the perception of the environment using a camera or laser scanner
• map making,
• planning a route,
• monitoring the battery level of the robot's battery, and
• controlling the motors driving the wheels of the robot.
• Each of these actions might consist of a ROS node or series of nodes to accomplish the specific
tasks.
43
Robotic Operating System(ROS)
• A node can independently execute code to perform its task but can communicate with other
nodes by sending or receiving messages.
• The messages can consist of data, or commands, or other information necessary for the
application.
• Some nodes provide information for other nodes, as a camera feed would do, for example.
• Such a node is said to publish information that can be received by other nodes.
44
Robotic Operating System(ROS)
• The information in ROS is called a topic.
• As an example, the camera node can publish the image on the camera/image_raw topic.
• Image data from the camera/image_raw topic can be used by a node that shows the image on
the computer screen.
• The node that receives the information is said to subscribe to the topic being published, in this
case camera/image_raw.
45
Robotic Operating System(ROS)
• ROS topics
• Some nodes provide information for other nodes, as a camera feed would do, for example.
• Such a node is said to publish information that can be received by other nodes.
• A topic defines the types of messages that will be sent concerning that topic.
• The nodes that transmit data publish the topic name and the type of message to be sent.
46
Robotic Operating System(ROS)
• The actual data is published by the node.
• A node can subscribe to a topic and transmitted messages on that topic are received by the
node subscribing.
• Continuing with the camera example, the camera node can publish the image on the
camera/image_raw topic.
• Image data from the camera/image_raw topic can be used by a node that shows the image on
the computer screen.
• The node that receives the information is said to subscribe to the topic being published, in this
case camera/image_raw.
• In some cases, a node can both publish and subscribe to one or more topics.
47
Robotic Operating System(ROS)
• ROS messages - ROS messages are defined by the type of message and the data format.
• The ROS package named std_msgs, for example, has messages of type String which consist of
a string of characters.
• Other message packages for ROS have messages used for robot navigation or robotic sensors.
• The turtlesim package has its own set of messages that pertain to the simulation.
• Turtlesim has relatively few topics and messages so it is ideal for the initial study of ROS.
• It is important for you to understand the ROS nodes, topics, and messages as they are involved
in almost every ROS activity. 48
Robotic Operating System(ROS)
• ROS Master
• The ROS nodes are typically small and independent programs that can run concurrently on
several systems.
• The ROS Master provides naming and registration services to the nodes in the ROS system.
• The role of the Master is to enable individual ROS nodes to locate one another.
49
Robotic Operating System(ROS)
• The most often used protocol for connection is the standard Transmission Control
Protocol/Internet Protocol (TCP/IP) or Internet Protocol called TCPROS in ROS.
• Once these nodes are able to locate one another, they can communicate with each other
peer-to-peer.
• One responsibility of the Master is to keep track of nodes when new nodes are executed and
come into the system.
• The nodes cannot communicate however, until the Master notifies the nodes of each others'
existence.
50
Robotic Operating System(ROS)
• Master Name Service Example:
• For instance, let's say we have two Nodes; a Camera node and an Image_viewer node.
• A typical sequence of events would start with Camera notifying the master that it wants to
publish images on the topic "images":
51
Robotic Operating System(ROS)
• Master Name Service Example:
• Now, Camera publishes images to the "images" topic, but nobody is subscribing to that topic
yet so no data is actually sent.
• Now, Image_viewer wants to subscribe to the topic "images" to see if there's maybe some
images there:
52
Robotic Operating System(ROS)
• Master Name Service Example:
• Now that the topic "images" has both a publisher and a subscriber, the master node notifies
Camera and Image_viewer about each others existence so that they can start transferring
images to one another:
53
Robotic Operating System(ROS)
• What Is Robot Programming?
55
Robotic Operating System(ROS)
• The main components of any robot are the actuators and the sensors.
• Examples of robot sensors include wheel encoders, ultrasonic sensors, and cameras.
• Robotic programming creates intelligence in the robot for self-decision making, implementing
controllers like PID to move joints, automating repeated tasks, and creating robotic vision
applications. 56
Robotic Operating System(ROS)
• Why Robot Programming Is Different? - Robot programming is a subset of computer
programming.
• The differences between robot programming and conventional programming are the input and
output devices.
• The input devices include robot sensors, teach pendants, and touch screens, and the output
devices include LCD displays and actuators.
• Good community support, performance, and prototyping time make C++ and Python the most
commonly used. 57
Robotic Operating System(ROS)
• The following are some of the features needed for programming a robot.
• Threading
• High-level object-oriented programming
• Low-level device control
• Easy of Protyping
• Inter Process Communication
• Performance
• Community Support
• Availability of third-party libraries
• Existing robotics software framework support
58
Robotic Operating System(ROS)
• Robots and Sensors Supporting ROS
• TurtleBot 2 (www.turtlebot.com/turtlebot2/)
• A simple mobile robot platform that is mainly used for research and educational purposes.
59
Robotic Operating System(ROS)
• Robots and Sensors Supporting ROS
• Robonaut 2 (https://robonaut.jsc.nasa.gov/R2/)
• A NASA robot designed to automate various tasks on the International Space Station.
60
Robotic Operating System(ROS)
61
Robotic Operating System(ROS)
62
Robotic Operating System(ROS)
Popular Computing Units a) NVDIA TX1/TX2 (www.nvidia.com/en-us/
that run ROS autonomous-machines/embedded-systems-dev-
kits-modules/):
• Capable of running deep learning applications
and computational intensive applications.
• The board has an ARM-based 64-bit processor
that can run Ubuntu.
• This platform is very popular in autonomous
robotics applications, especially drones.
b) Raspberry Pi 3
(www.raspberrypi.org/products/raspberry-pi-3-
model-b/):
• Very popular singleboard computers for
education and research.
• Robotics is a key area.
63
Robotic Operating System(ROS)
• ROS Architecture and Concepts
• For example if program A wants to send a data to program B, and B wants to send data to
program A, we can easily implement it using ROS.
• Yes, we can, but if we build more and more programs, it gets complex, ROS is a good choice
for interprocess communication.
66
Robotic Operating System(ROS)
• How does two programs in ROS communicate?
70
Robotic Operating System(ROS)
71
Robotic Operating System(ROS)
• ROS Computation Concepts
• ROS parameter server: A program that normally runs along with the ROS master.
• The user can store various parameters or values on this server and all the nodes can access it.
• If it is a public parameter, all the nodes have access; if it is private, only a specific node can
access the parameter.
• ROS topics: Named buses in which ROS nodes can send a message.
• ROS message: The messages are basically going through the topic.
• There are existing messages based on primitive data types, and users can write their own
messages.
• ROS service: We have already seen ROS Topics, which is having publishing and subscribing
mechanism. 73
Robotic Operating System(ROS)
• ROS Computation Concepts
• A service call is a function, which can call whenever a client node sends a request.
• The node who create a service call is called Server node and who call the service is called
client node.
• ROS bags: A useful method to save and play back ROS topics.
• Also useful for logging the data from a robot to process it later.
74
Robotic Operating System(ROS)
• The ROS Community
• The following are terms used to exchange ROS software and knowledge.
• The ROS wiki has tutorials on how to set up and program ROS.
• ROS discourse (https://discourse.ros.org) is a forum in which developers can share news and
ask queries related to ROS.
75
Robotic Operating System(ROS)
• ROS Demo: Hello World Example
76
Robotic Operating System(ROS)
77
Robotic Operating System(ROS)
• ROS Demo: Hello World Example - Start the example by using following command.
• Start the talker node by using the following command in another terminal.
• $ rosrun roscpp_tutorials talker
• Now you see the messages printing on the terminal screen.
• If you list the topic by using the following command, you see a new topic called
• /chatter
• $ rostopic list
• Output: /chatter
79
Robotic Operating System(ROS)
• Talker-Listener Example
• $ roslaunch
roscpp_tutorials
talker_listener.launch
80
Robotic Operating System(ROS)
ROS Demo: turtlesim
• You can move the turtle, read the turtle’s current position, and change the turtle’s pattern,
and so forth using ROS topics, ROS services, and parameters.
• When working with turtlesim, you get a better idea of how to control a robot using ROS.
81
Robotic Operating System(ROS)
ROS Demo: turtlesim
• Starting roscore
• $ roscore
• A screen like the one shown in Figure means that everything is working fine.
82
Robotic Operating System(ROS)
ROS Demo: turtlesim
• Starting Turtlesim
application
• $ rosrun turtlesim
turtlesim_node
83
Robotic Operating System(ROS)
ROS Demo: turtlesim
• $ rostopic list
• $ rosservice list
84
Robotic Operating System(ROS)
ROS Demo: turtlesim
• $ rosparam list
85
Robotic Operating System(ROS)
ROS Demo: turtlesim
• $ rosparam list
86
Robotic Operating System(ROS)
ROS Demo: turtlesim
• Moving the Turtle:
• If you want to move the turtle, start
another ROS node by using the following
command.
88
Robotic Operating System(ROS)
• Moving the Turtle in a Square:
• If we want to clear the turtlesim, we can • Starting the node for drawing square
call a service called /reset.
• $ rosservice call /reset • $ rosrun turtlesim draw_square
89
Simultaneous Localization and Mapping - SLAM
• ROS and SLAM
• The objective of the SLAM in mobile robotics is constructing and updating the map of an
unexplored environment with help of the available sensors attached to the robot which is
will be used for exploring.
• Let us see the implementation of the prebuilt ROS packages i.e Navigation stack and
Gmapping to map an unexplored house using SLAM autonomously using the Randomly
Exploring Random Tree (RRT) algorithm to make the robot cover all the regions of the
unknown environment.
90
Simultaneous Localization and Mapping - SLAM
91
Simultaneous Localization and Mapping - SLAM
92
Simultaneous Localization and Mapping - SLAM
93
Simultaneous Localization and Mapping - SLAM
94
Simultaneous Localization and Mapping - SLAM
95
Simultaneous Localization and Mapping - SLAM
96
Simultaneous Localization and Mapping - SLAM
97
Simultaneous Localization and Mapping - SLAM
• RRT Algorithm
• A Rapidly-exploring Random Tree (RRT) is a data structure and algorithm that is designed
for efficiently searching nonconvex high-dimensional spaces.
• RRTs are constructed incrementally in a way that quickly reduces the expected distance of a
randomly-chosen point to the tree.
• RRTs are particularly suited for path planning problems that involve obstacles and
differential constraints (nonholonomic or kinodynamic)
98
Simultaneous Localization and Mapping - SLAM
• RRT Algorithm - RRT Algorithm Animation
99
Simultaneous Localization and Mapping - SLAM
100
Simultaneous Localization and Mapping - SLAM
101
Simultaneous Localization and Mapping - SLAM
102
Simultaneous Localization and Mapping - SLAM
• Setting Exploration region for RRT in RVIZ Window
• Gazebo simulation
• 1) Inside the launch file that comes with the rrt_exploration_tutorials package , you will find several launch
files. In this tutorial we will use the ones made for single robot simulation.
• Mainly, robot frames are prefixed by "robot_1", the same goes for node and topic names.
103
Simultaneous Localization and Mapping - SLAM
• Setting Exploration region for RRT in RVIZ Window
• Gazebo simulation
• 2) Start Exploration
• We will use a launch file called "single.launch" inside the rrt_exploration package.
• This launch file starts the global and local detectors, the filter, and the assigner nodes.
104
Simultaneous Localization and Mapping - SLAM
• Setting Exploration region for RRT in RVIZ
Window
• Gazebo simulation
• 2) Start Exploration
107
Simultaneous Localization and Mapping - SLAM
• $ roslaunch turtlebot3_teleop
turtlebot3_teleop_key.launch
109
Simultaneous Localization and Mapping - SLAM
110
Simultaneous Localization and Mapping - SLAM
111
Simultaneous Localization and Mapping - SLAM