Ros or Robot operating system is an open-source project which helps in communication between different robotics applications and with time ROS became an ecosystem that interlinks different robotic applications. a lot of firms and companies such as NASA, Apple, AMD, and many more (list of companies). It is getting popular these days because not only it is an easy way to merge and synchronize different modules or applications to create a system or robot but also there are so many codes and applications prebuilt by so many developers which are reusable and modifiable according to users needs and you can save a lot of time, hence you should also need to learn how to use it if you want to advance robotic applications,
ROS(robot operating system) has 2 versions ROS1 and ROS2. ROS 1 was built mainly for hobbyists and project use, it wasn’t enough to be used for industrial purposes, and for it, the ROS2 project was started. ROS2 has a significant improvement over ROS1.
Difference between ROS1 and ROS2
ROS1 needs a rosmaster to run before executing of application, while ROS2 does not need the rosmaster.
With ROS1 you can only run one ros application as it works over local ip only, unlike ROS2 which can run upto 120 ros applications over different domain ids(more than 120 is not possible because domains will start colliding)
ROS1 is stable for Debian, and Ubuntu versions of the Linux operating system while ROS2 can be installed for Linux, Windows, and macOS as well.
There are a lot more differences between these two when going further such as the launch file on ROS1 is only in XML format while ROS2 supports XML, yaml, and Python.
ROS Terminologies
Before continuing with how ros work, let's first understand the basic terminologies used by ROS
- Rosmaster-It is used to define which host is the master
- Nodes- every program or application in ros is a node. A node in ROS can interact with other nodes with help of Topics, Services, or actions
- Topic- a topic in ros is a way different nodes can interact with each other. A node can subscribe and publish to many topics.
- Message-its a special type of variable that depicts what kind of value is given to a topic. Every node must indicate which type of variable will it be subscribing or publishing to. For example(insert example
- Service- it is another way of communication in ros. It differs from the topic in that the publisher can communicate back or give feedback to the publisher unlike the ros topic where the publisher is free from subscriber's events
- Actions-this communication is similar to service but at each instance of time, it sends information to the node, unlike service which only feedback when the task is completed.
- Publisher- the publisher is a node that publishes a topic
- Subscriber- the subscriber is the node that listens to a topic
How ROS1 works
- ROS1 first initializes a master to define which local host is the Rosmaster. The job of the rosmaster is to approve every node request to subscribe and publish to a topic.
- Next subscriber starts, it resolves which topics will it read to and what type of message format it needs
- Then Publisher will publish will resolve which topic will it publish to
- Both Publisher and Subscriber will register with rosmaster
- Rosmater then informs subscribers of new publishers
- Then the publisher requests a topic for connections from the publisher and they both negotiate on the protocol on which they will form communication it can be tcp, udp, or any other internet protocol
- The publisher then sends the subscriber the setting of the selected protocol
- And at last, the subscriber connects to the publisher using the selected protocol
Apart from the communication protocol ros has some prevalent tools which use ros protocol for interactions and these tools are of much help in improving efficiency
Some of the popular tools are (explain)
- Gazebo - It is a 3rd simulator built specifically for ROS(for both ROS1 and ROS2) application
- Rviz - It helps to visualize various parameters or ros topics for example Lidar scans or 3d representation of your robot, or maps of environments(if provided the right sensors such as lidar or 3d camera)
- rqt - It is a tool that is implemented by the ROS to update the applications dynamically like changing the parameter of a node(rosparam)
![]() |
Ros Rviz example |
Even though ROS1 seems a great tool it has some disadvantages
- ROS1 works stably with Debian and the Ubuntu version of Linux and Ubuntu version 22.04 and later deprecated its service, it is moved to ROS2.
- ROS1 heavily depends on rosmaster, it won’t matter if you are using one computer for running tasks but if you are using multiple computers then we start seeing some issues, as, if the host computer is offline then applications on the other won't be able to communicate.
- ROS1 data communications have some serious security threats which can be exploited.
- The older version of ros python was built on python2 while builds such as noetic shifted completely to python3 and some applications don't build properly because of that.
- You can only run one rosmaster per ros project and this makes things complicated if the project gets bigger.
Because of these disadvantages, ROS2 was implemented. ROS2 fixes some of the major issues by ROS1 such that it can be used for industrial purposes as well
Like
- ROS2 works on dds(distributed data service) plus each ros project works on ros domain id. This not only removes the dependency on rosmaster but also allows multiple ros projects to work on the same host computer such that they won’t interfere with one another
- With ROS2 you can integrate security measures for dds servers
- With ROS2 you can create launch files that are not limited to XML format only. (launch files can run multiple nodes with setting parameters if a node requires one)
This is how ROS2 works
ROS2’s most of the work is done with the help of the DDS protocol. DDS was first implemented by a French defense company and it found its uses in iot systems as well, and ROS2 heavily depends on it
- First, the ROS Client library for C++ and Python converts your code to a DDS-compliant application. This RCL(ROS Client library) works as middleware between your program and DDS API(Application Programming Interface).
- Any DDS application must have dataWriter(aka publisher), dataReader(aka subscriber), and domainParticipant. A domainParticipant handles finding other applications or domainParticipants
- A domainParticipant will periodically broadcast its address and port from where it is going to broadcast data traffic
- If there is another domainParticipant and on the same domain id* then they will share the information about dataWriters and dataReaders on the communications channels which dataParticipant established.
DomainParticipants broadcasting periodically on their respective domain(which the user will have to specify) - The information shared between them contains topics and data type among other things(data type and topics of ROS topic and type of message data which is exactly that of ROS1 type)
- Data transmission between DomainParticipants will happen only if the topic and data type matches
- Then RCL again decodes the DDS data at the other node’s end
*Domain ID works on IP ports and it can be calculated from (link to more info on domain id and how to calculate domain id)
This is pretty much how ROS works as ROS has a specific architecture, and its workspaces are generic in nature which means for the ideal condition if it works for one device it will work for other devices as well.
0 Comments