9 - Robot Operating System - Slideshow
9 - Robot Operating System - Slideshow
2
ROS Features
• Open-source software
• Freely available for commercial application
• All the Transforms of the robot are tracked in ROS
• No need to find the Forward kinematics equations to find the position of the
end-effector
• Robot description is provided in URDF format to ROS
• tf or tf2 module keeps track of all the transforms of the robot from base to
end-effector
• There are IK slovers to solve Inverse kinematics problems
• There are many plugins that solves the Ik problem for simple to complex
robotic manipulators
• Few Ik solvers are IKfast(Analytical Solver) and kdl (Numerical Solver)
3
ROS Features
• Moveit - path planning and obstacle avoidance
• Set of packages and tools for doing motion planning, manipulation, 3D
perception, kinematics, collision checking, control, and navigation in ROS
• ROS navigation stack - differential drive robots
• Contains ready to-use navigation algorithms which can be used in mobile
robots, especially for differential wheeled robots
• Robot move autonomously in given environment using ROS navigation
• ROS control package - control the actuators of the robots
• Provides built-in PID control loop with joint limits to make the motion of the
robot swift and smooth
• Open CV Interfaced to ROS
• Vision and perception tasks
4
ROS Features
• Rviz and Gazebo - tools to visualize robot
• Gazebo
• Simulation environment where an exact replica of the robot can be implemented with all
physical properties(like weight, inertia, collisions, etc)
• Code can be tested in simulation first before testing it on real hardware
• Rviz
• Debugging tool which visualizes what a real/simulated robot is experiencing (like joint
motion, vision, etc)
• ROS is light
• Can run on embedded boards like Rasberry pi
5
Working with ROS
• ROS works with Linux operating system
• ROS versions: ROS Noetic Ninjemys, ROS Melodic Morenia, ROS Lunar
Loggerhead, ROS Kinetic, etc.,
• Following explanation is based on ROS kinetic
• ROS uses catkin to build the ROS projects
• First step is to create a catkin workspace
• Following folders are created once workspace is ready
• source space (/src) – contains packages for robotic projects which contains
the source code files
• build space (/build)
• development space (/devel)
• ROS packages can be written in C++ or python
6
ROS Node
• An executable program which contains a part of code of the robot
• A robotic application can have more than one node
• Node to compute inverse kinematics
• Node to send commands to the actuators
• Node to get the joint angle values from sensors and etc
• All these nodes communicates with each other through messages
• There is a Master node running which will have all the address of the
nodes running in the system
• It is Master node's responsibility to connect the Nodes with each
other to start communication
• Modes of communication: topics, services and Actions
7
ROS Node – Registration
• Master allows all other ROS pieces of
software (Nodes) to find and talk to each
other
Send this sensor data to that computer at
127.0.0.1
✓ One can program Node 1 to send messages to
Node 2
8
ROS Node – Topic
• Topics are named buses over which nodes exchange messages
• Commonly used mode of communication for nodes in ROS
• Publisher node → Broadcasts a message with a topic name
• Subscriber node → A node that want to receive the message will subscribe to a
specific topic name
• This mode of communication is unidirectional
• The nodes are unaware of who they are communicating with
• A publisher will keep on publishing the data even if there is no/multiple subscriber
• Subscriber will keep listening to the topic if there is no/ multiple publishers
• It is responsibility of the ROS master to establish the connection between the
publisher and subscriber when they are on the same topic
9
ROS Node – Topic
• Consider a camera on a Robot
• Images from the camera must be available to both the
Robot itself and to another laptop
• All Nodes have registered with the Master
• Master: lookup table where all the nodes go to find where exactly
to send messages
• During registration, the Camera Node states that it will Publish a
Topic called /image_data
• Both of the other Nodes register that they are Subscribed to the
Topic /image_data
• once the Camera Node receives some data from the Camera, it
sends the /image_data message directly to the other two nodes
(via TCP)
10
ROS Node – Service
• Sometimes a node wants to perform/execute a task or provide data when asked
for
• This requires a mode of communication where there is a response to the request
(Technically these are RCP (Remote procedure calls))
• A node providing service is known as Service Server node
• A node asking for service is known as Service Client node
• A ROS node offers a service under a string name, and a client calls the service by
sending the request message and awaiting the reply
• There can be only one Service server node with a unique service name
• The same service can be requested by one/multiple client nodes
11
ROS Node – Service
• Image Processing Node can request data
from the Camera Node at a specific time
• ROS implements Services
• A Node can register a specific service with
the ROS Master, just as it registers its
messages
• The Image Processing Node first requests
/image_data, the Camera Node gathers
data from the Camera, and then sends the
reply
12
ROS Node – Services
Drawback
• When service is requested by the client, the request is assigned in the
global callbacks queue
• If this service for any reason takes long time to complete the task, it
may have side effect on the other nodes
• Therefore, services should never be used for longer running
processes, in particular processes that might be required to preempt
if exceptional situations occur
• however, if the service takes a long time to execute, the user might
want the ability to cancel the request during execution or get periodic
feedback about how the request is progressing
13
ROS Node – Action
• actionlib package provides tools to create servers that execute long-running goals
and that can be preempted if required
• It also provides a client interface in order to send requests to the server
• Actions are used for longer tasks like execution of robot motions or perception –
for real world actions
• Analogy: Ordering food online from a restaurant through a mobile App
• Mobile app is the Action Server
• Person who has ordered the food is the Action Client
• Delivery boy at your doorstep is the Goal
• The current location of the delivery boy is the Feedback
• Option to cancel order is the Preemption of goal
14
Launch File
• A robot project can have N nodes
• To run all the nodes in a project, one may need to open N terminals
all at once to realise a robot – Difficult
• Launch file will come in handy
• Launch file is an xml file format which can be used to run multiple
nodes, load variables into ROS parameter server, etc
• One can even include another launch file in existing launch file
15
URDF
• Universal Robotic Description Format
• An XML file format used in ROS to describe all elements of a robot
and their properties
• Contains information about the robot's physical construction, geometry,
dynamics, etc
• URDF will tell ROS how the links and joints are connected, type of
joints, the dimensions of links, mass and inertia of the links, etc
16
Scripts of URDF file for the model shown on the left
17
tf2
• Almost everything in robotics is concerned with where things are -
either relative to the robot itself or relative to other things
• Whenever a robot wants to interact with the real world, it will need
to know where the things it wants to interact with are
• Each link of robot is assigned with a coordinate frame from the base
to the end-effector
• These frames will tell us the position and orientation of the frame
w.r.t to other frames
• The coordinates of these frames are determined using the
Transformation matrices
• These frame coordinates need to be updated whenever either the
robot moves, or other things move
18
tf2
• The tf2 package enables ROS nodes to keep track of coordinate
frames and transform data between coordinate frames
• A node that knows a transform between frames will publishes it to a
tf ROS topic
• Nodes that are interested use tf to subscribe to the transforms
• tf can then efficiently compose the net transform between requested
frames
• Tf package replaces manual derivation of the transformation matrices
and forward kinematics equations of the robot
19
Usage of tf
• Our part is to write the URDF file of our robot and and a node to
publishing the joint sensors data continuously on "/joint_states" topic
• Load this URDF file in parameter server, run node publishing joint
positions data and run the robot_state_publisher node
• The robot_state_publisher will receive the joint positions data from
"/joint_states" topic, compute the transformations of all the frames
and publish those transforms on "/tf" and "/tf_static" topics
20
Rviz
• Rviz (ROS visualizer) is powerful 3D visualization tool that allows to
view the robot's sensors and internal state
• Rviz uses the URDF file to load the designed robot in the tool
• It can also display live representations of sensor values coming over
ROS Topics including camera data, point cloud data, infrared distance
measurements, sonar data, and more
• Using Rviz one can
• Check our path planning or collision checking algorithms by inserting objects
• Trace the motion of any link of the robot
• Use interactive markers to move the robot and do lot things
21
Movelt Quickstart in RViz 22
Robot navigating to a location in ROS 23
Reference
• Ros 101: Intro to the Robot Operating System (no date) Robohub.
Available at: https://robohub.org/ros-101-intro-to-the-robot-
operating-system/ (Accessed: November 13, 2022).
• Basics of ROS: Ros Robotics (no date) Home. Available at:
https://www.rosroboticslearning.com/basics-of-ros (Accessed:
November 13, 2022).
24