Download as pdf or txt
Download as pdf or txt
You are on page 1of 114

Robotic Operating System and

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

• TurtleBot3 is available in two types of models: Burger and Waffle Pi.

• 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)

Robot local path and global path planning


21
Robotic Operating System(ROS)

Robot MOVE TO GOAL action


22
Operating System(OS)
• An Operating System (OS) is an interface between a computer user and computer hardware.

• 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

• Memory management refers to management of Primary Memory or Main Memory.

• 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.

• For a program to be executed, it must in the main memory.

• An Operating System does the following activities for memory management

26
Operating System(OS)
• Memory Management

• An Operating System does the following activities for 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.

• Allocates the memory when a process requests it to do so.

• 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.

• This function is called process scheduling.

• An Opera ng System does the following ac vi es for processor management −

• Keeps tracks of processor and status of process.

• The program responsible for this task is known as traffic controller.

• Allocates the processor (CPU) to a process.

• De-allocates processor when a process is no longer required. 28


Operating System(OS)
• Device Management

• An Operating System manages device communication via their respective drivers.

• It does the following ac vi es for device management −

• 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.

• Allocates the device in the efficient way.

• De-allocates devices.
29
Operating System(OS)
• File Management - A file system is normally organized into directories for easy navigation and usage.

• These directories may contain files and other directions.

• An Opera ng System does the following ac vi es for file management −

• Keeps track of information, location, uses, status etc. The collective facilities are often known as file
system.

• Decides who gets the resources.

• Allocates the resources.

• De-allocates the resources 30


Operating System(OS)
• Other Important Activities of OS - Following are some of the important activities that an Operating
System performs −

• 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

• ROS depends on the underlying Operating System.


• ROS demands a lot of functionality from the 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.

• The concept of ROS goes far beyond just a framework.

• 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?

• Let us see the big-picture of the ROS system.

• 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.

• Each node can send or get data from the other


node using the publish/subscribe model.

• The primary goal of ROS is to support code


reuse in robotics research and development so
you can find a built-in package system.

• Keep in mind that ROS is not an OS, a library, or


an RTOS. It’s a framework using the concept of
an OS.
40
Robotic Operating System(ROS)
• ROS nodes

• 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.

• Basically, nodes are processes that perform some action.

• 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.

• Nodes can publish and nodes can subscribe

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.

• The information in ROS is called a topic.

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.

• The information in ROS is called a topic.

• 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.

• Communication is established between the nodes by the ROS Master.

• The ROS Master provides naming and registration services to the nodes in the ROS system.

• It tracks publishers and subscribers to the topics.

• 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.

• Thus, the Master provides a dynamic allocation of connections.

• 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?

• A robot is a machine with sensors, actuators


(motors), and a computing unit that behaves
based on user controls, or it can make its own
decisions based on sensors inputs.

• The brain of the robot is a computing unit.

• It can be a microcontroller or a PC.

• The decision making and actions of the robot


completely depends on the program running
the robot’s brain. 54
Robotic Operating System(ROS)
• What Is Robot Programming?

• This program can be firmware running on a


microcontroller, or C/C++ or Python code
running on a PC or a single board computer, like
the Raspberry Pi.

• Robot programming is the process of making


the robot work from writing a program for the
robot’s brain (i.e., the processing unit).

55
Robotic Operating System(ROS)
• The main components of any robot are the actuators and the sensors.

• Actuators move a robot’s joints, providing rotary or linear motion.

• Servo, Stepper, and DC gearmotors are actuator brands.

• Sensors provide the robot’s state and environment.

• 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.

• Most robots have a “brain” that can make decisions.


• It can be a microcontroller or a PC.

• 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

• Pepper (www.ald.softbankrobotics.com/en/ robots/pepper)


• A service robot used for assisting people in a variety of ways.

• REEM-C (http://pal-robotics.com/en/products/ reem-c/)


• A full-size humanoid robot that is mainly used for research purposes.

• 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.

• Universal Robot arm (www.universal-robots.com/products/ur5-robot)


• One of the popular semiindustrial robots widely used for automating various tasks in
manufacturing.

60
Robotic Operating System(ROS)

Robots that work in ROS

61
Robotic Operating System(ROS)

Popular Sensors that


Support 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

• Basically, ROS is a framework to communicate between two programs or process.

• 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.

• So, the question is should we implement it directly using socket programming?

• Yes, we can, but if we build more and more programs, it gets complex, ROS is a good choice
for interprocess communication.

• Do we really need interprocess communication in a robot?

• Can we program a robot without it?


64
Robotic Operating System(ROS)
• ROS Architecture and Concepts

• A robot may have many sensors and


actuators, as well as a computing unit.

• How can we control many actuators and


process so much sensor data?

• Can we do it in a single program?


• Yes, but that is not a good way to do it.

• The better way is, we can write


independent programs to handle sensor
data and controlling actuators, and
often we may need to exchange data
between these programs.
65
Robotic Operating System(ROS)

• ROS Architecture and Concepts

• This is the situation where we use


ROS.

• So, can we program a robot without


ROS?

• Yes, but the complexity of software


increases according to the number of
actuators and sensors.

66
Robotic Operating System(ROS)
• How does two programs in ROS communicate?

• Figure shows two programs marked as node 1


and node 2.

• When any of the programs start, a node


communicates to a ROS program called the
ROS master.

• The node sends all its information to the ROS


master, including the type of data it sends or
receives.

• The nodes that are sending a data are called


publisher nodes, and the nodes that are
receiving data are called subscriber nodes.
67
Robotic Operating System(ROS)
• How does two programs in ROS communicate?

• The ROS Master has all the publisher and


subscriber information running on computers.

• If node 1 sends particular data called “A” and


the same data is required by node 2, then the
ROS master sends the information to the
nodes so that they can communicate with
each other.

• The ROS nodes can send different types of


data to each other, which includes primitive
data types such as integer, float, string, and so
forth.
68
Robotic Operating System(ROS)
• How does two programs in ROS communicate?

• The different data types being sent are called


ROS messages.

• With ROS messages, we can send data with a


single data type or multiple data with different
data types.

• These messages are sent through a message


bus or path called ROS topics.

• Each topics has a name;


• for example, a topic named “chatter” sends a
string message.
69
Robotic Operating System(ROS)

• How does two programs in ROS communicate?

• When a ROS node publishes a topic, it sends a


ROS topic with a ROS message, and it has data
with the message type.

• In Figure the ROS topic is publishing and


subscribing node 1 and node 2.

• This process starts when the ROS master


exchange the node details to each other.

70
Robotic Operating System(ROS)

71
Robotic Operating System(ROS)
• ROS Computation Concepts

• These are the terms associated with ROS computation concepts.

• ROS nodes: Process that use ROS APIs to perform computations.

• ROS master: An intermediate program that connects ROS nodes.

• 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.

• The user can set privacy of the parameter too.


72
Robotic Operating System(ROS)
• ROS Computation Concepts

• 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.

• A node can publish or subscribe any number of topics.

• 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

• The ROS Service has Request/Reply mechanism.

• 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 distribution is a collection of versioned packages.

• The ROS wiki has tutorials on how to set up and program ROS.

• ROS Answers (https://answers.ros.org/questions/) has ROS queries and solutions, similar to


Stack Overflow.

• 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

• The example is already installed in ROS.

• There are two nodes: talker and listener.

• The talker node publishes a string


message.

• The listener node subscribes it.

• In this example of the process, the talker


publishes a Hello World message and the
listener subscribes it and prints it.

76
Robotic Operating System(ROS)

• ROS Demo: Hello World Example

• Figure shows a diagram of the two


nodes.

• Both nodes need to communicate with


the ROS master to get the information
from the other node.

77
Robotic Operating System(ROS)
• ROS Demo: Hello World Example - Start the example by using following command.

• The first step in starting any node in ROS is roscore.


• $ roscore

• 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

• Now start the listener node by using the following command.


• $ rosrun roscpp_tutorials listener 78
Robotic Operating System(ROS)
• Talker-Listener Example

79
Robotic Operating System(ROS)
• Talker-Listener Example

• If you want to run two of


the nodes together, use
the roslaunch command.

• $ roslaunch
roscpp_tutorials
talker_listener.launch

80
Robotic Operating System(ROS)
ROS Demo: turtlesim

• Through an interesting application let us learn ROS concepts.

• The application is called turtlesim, which is a 2D simulator with a turtle in it.

• 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

• The turtlesim application is already installed on ROS.

• You can start this application by using the following commands.

• Starting roscore
• $ roscore

• Starting Turtlesim application

• $ rosrun turtlesim turtlesim_node

• 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

• A screen like the one shown


in Figure means that
everything is working fine.

83
Robotic Operating System(ROS)
ROS Demo: turtlesim

• Now you can open a new terminal and list


the topics by publishing the turtlesim
node.

• $ rostopic list

• Figure lists the services created by the


turtlesim node.

• You can list the services by using the


following command.

• $ rosservice list
84
Robotic Operating System(ROS)
ROS Demo: turtlesim

• List the ROS parameters by using the


following command

• $ rosparam list

85
Robotic Operating System(ROS)
ROS Demo: turtlesim

• List the ROS parameters by using the


following command

• $ 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.

• This command has to start in another


terminal.

• $ rosrun turtlesim turtle_teleop_key

• You can control the robot using your


keyboard’s arrow keys.

• When you press an arrow key, it publishes


velocity to /turtle1/cmd_vel, which makes
the turtle move
87
Robotic Operating System(ROS)
ROS Demo: turtlesim

• Moving the Turtle:

• If you want to see the back end of


these nodes, check the diagram in
Figure.

• It shows the topic data going to


turtlesim.

88
Robotic Operating System(ROS)
• Moving the Turtle in a Square:

• This section shows how to move the turtle along a


square path.

• Close all the running nodes by pressing Ctrl+C, and


start a new turtlesim session using the following
command see Figure.
• Starting roscore
• $ roscore

• Starting turtlesim node


• $ rosrun turtlesim turtlesim_node

• 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

• One of the most popular applications of ROS is SLAM(Simultaneous Localization and


Mapping).

• 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

• Setting Exploration region for RRT in RVIZ Window

• The RRT exploration requires a rectangular region


around the robot to be defined in the RVIZ window
using four points and a starting point for exploration
within the known region of the robot.

• The total five points must be defined in the exact


sequence given below using the RVIZ Publish Points
option.

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.

• In a terminal, run the following command:

• $ roslaunch rrt_exploration_tutorials single_simulated_house.launch

• This will open Gazebo, and RViz.

• The robot is set to work with the rrt_exploration package.

• 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.

• $ roslaunch rrt_exploration single.launch

104
Simultaneous Localization and Mapping - SLAM
• Setting Exploration region for RRT in RVIZ
Window

• Gazebo simulation

• 2) Start Exploration

• When defining the rectangular region for


exploration, the sequence of points is
important.

• The sequence is as follows: top-left corner,


bottom-left corner, bottom-right corner, top
right corner, and finally the initiation point.

• Initiation point can be chosen anywhere within


the known area (white area in the occupancy
grid).
105
Simultaneous Localization and Mapping - SLAM

• Setting Exploration region for RRT in RVIZ Window

• Monitor the Mapping process in the RVIZ window and


sit back and relax until our robot finishes mapping XD.

• Once you are satisfied with the constructed map, Save


the map.

• $ rosrun map_server map_saver -f my_map

• The my_map.pgm and my_map.yaml gets saved in


your home directory.

• Move these files to the package’s maps folder


(catkin_ws\src\ros_autonomous_slam\maps).

• Now your new map which is basically an occupancy


grid is constructed!
106
Simultaneous Localization and Mapping - SLAM

• Setting Exploration region for RRT in RVIZ Window

• Once you are satisfied with the constructed map, Save


the map.

• $ rosrun map_server map_saver -f my_map

• The my_map.pgm and my_map.yaml gets saved in


your home directory.

• Move these files to the package’s maps folder


(catkin_ws\src\ros_autonomous_slam\maps).

• Now your new map which is basically an occupancy


grid is constructed!

107
Simultaneous Localization and Mapping - SLAM

• Setting Exploration region for RRT in RVIZ Window

• Incase of Autonomous Fails you can manually control


the robot in the environment using the keyboard with a
separate launch execution given below.

• You can also manually explore and construct the map


like a game.

• $ roslaunch turtlebot3_teleop
turtlebot3_teleop_key.launch

Manual Robot Mapping 108


Simultaneous Localization and Mapping - SLAM

109
Simultaneous Localization and Mapping - SLAM

110
Simultaneous Localization and Mapping - SLAM

111
Simultaneous Localization and Mapping - SLAM

Robot local path and global path planning 112


Simultaneous Localization and Mapping - SLAM

Robot MOVE TO GOAL action 113


114

You might also like