Hello, everyone, I’m Xiao Zhi. Recently, things have been a bit much. There are many friends who have encountered problems with Gazebo simulation.
Today, I received a task to investigate ROS, so Xiao Zhi went through the ROS official documents again and deepened her understanding of ROS.
The general introduction to robotics is definitely ROS, and while the initial phase is a bit painful, ROS incorporates a lot of functionality packages that are handy.
Today, Xiaozhi will talk about the topic and service communication mechanism in ROS through the legendary story of the mayor of ROS, so as to deepen the understanding of those new to ROS.
1. Is ROS an operating system?
It is said that ROS is a robot operating system. When you say THAT ROS is a robot operating system, it feels very impressive. Many students who have just learned ROS will misunderstand the meaning of this operating system and think that it is an operating system like Android, Windows and IOS. ROS is just a piece of software that runs on top of an existing operating system (it’s like having an APP on your phone, but the APP is called ROS).
2. Does ROS need money?
Free, open source, free
The legendary story of Mayor ROS
3.1 Unified Dialect
Once upon a time in a mountain, there were five villages, each of which had its own dialect. It is very complicated for villagers in different villages to communicate with each other. First of all, it is necessary to find an interpreter who can speak two dialects at the same time to communicate with each other.
Later, the five villages merged into one town, and a mayor named ROS came. Seeing how much this affected communication, he started to promote Mandarin. Later, many other villages moved into the town, and it was easy for everyone to communicate with each other because of the unified language.
After the unification of dialect, communication was convenient, and three industries sprang up in the town. The first industry was newspaper industry, specializing in selling newspapers. The second industry is the delivery industry, which specializes in delivering food.
3.2 Wang ‘er subscription
Mayor ROS developed a subscription mechanism for the newspaper, called Topic, and set up a newspaper department to manage the issue: Wang Er, a villager who had been single for many years, liked to read the magazine “Legend of The Lady” written by Li Si, a villager.
Single Subscriber Wang Er wants to read the topic-Name magazine. First of all, he should go to the news service department and tell the section chief that I want to order The topic-Name magazine. The section chief will leave wang er’s contact information and write it in the manual. But when Publisher was updated, he sent the magazine to the town’s newspaper department, which had a manual with a list of villagers who had subscribed to “The Fairy Tale.” When the section chief sees who has made a reservation, he will send a copy of the magazine to Node.
Magazine = Topic
After reading the above content, let’s summarize. In fact, Topic and Service are two very important communication methods in ROS. Topic is a publishing-subscription model, in which the subscriber (Wang 2) needs to subscribe to the publisher (Li si) through the Topic (” Lady Legend “) to the Master node (section chief). This is still a one-to-one (one publisher, one subscriber) model, but in real ROS it can be 1 to N,n to 1,n to N.
And meet the following rules:
- The topic name is the key, subscribers must subscribe to the topic name to complete the subscription;
- The same person can subscribe to and publish multiple topics, just as the author of one book can be a reader of another;
- The same magazine cannot have more than one author, but the same topic can have more than one publisher.
3.3 Li Si orders take-out
In order to concentrate on his magazine writing, Li Si stays at home every day and orders takeout. In town, ordering takeout is primitive, which is decided by writing letters. If you want to order takeout, first write a letter (request), write the name of the dish and the restaurant clearly, and then send the letter through the delivery boy (service boy). The boy will send the letter to a corresponding restaurant (service end) in the town, and the restaurant in the town makes the food (response). Then let the delivery boy take back, this time Li Si (client) can eat the takeaway.
Take-out = service
Li Si is the client of the service, and the restaurant is the server. The client (Li Si) sends a request (letter) to the server (restaurant). The server processes the request according to the content in the letter, and then asks the delivery boy to send the response back.
The service meets the following rules:
- The requester must know the name of the service and the type of service, just as The requester knows the name of the restaurant and the name of the dish
- The requestor cannot or the server processing progress before returning. It’s like Li Si doesn’t know if the delivery guy changed his dish until it arrives
- Each node can provide or request multiple services. It’s not quite like a restaurant
4. Centralization of power by Mayor ROS
The town of ROS has become very prosperous under the governance of Mayor ROS, but Mayor ROS is a very controlling person, to what extent? Without mayor ROS, the newspaper department and the delivery boys will not be able to operate, and the villagers will not be allowed to share magazines (topic correspondence) or order delivery (service correspondence) with each other.
In addition, everyone from the village needs to register with the Population Management Department of the MAYOR of ROS to become a legal villager, and is also under the management of the Mayor of ROS.
To summarize: The MAYOR of ROS and his subordinate departments are actually the master nodes in ROS, a mechanism only available in ROS1. At the same time, the topic and service communication between nodes also needs to be connected by the master node.
Write in the last
This article is ready to write a series of small wisdom, first from ROS1 to start, then began to talk about ROS2, ROS2 domestic data is still relatively small, or the little sister on the idle fish will not take the initiative to find small wisdom, back to share with you.
I am xiaozhi, a veteran player in the field of robotics, and now I am an engineer of a unicorn robot algorithm in Shenzhen
I learned programming in junior high school. I started to learn robotics in senior high school. I played robot related competitions in college to earn 2W+ per month (prize money).
At present, I am doing an official account to output robot learning guide, paper annotations and work experience. Welcome to pay attention to Xiaozhi, exchange technology and learn robot together