Introduction to ROS
Goal: Understanding the general concept of ROS framework
What is ROS?
If you have ever had the chance to develop code for a robot or take part in a robotics team, you have definitely heard of ROS. The Robot Operating System (ROS) is the most used and flexible framework for writing robot software. It is a collection of tools, libraries, and best practices to simplify the task of creating complex and robust robot applications. In a nutshell, ROS uses a distributed publish-subscribe architecture where different software components communicate with each other via messages. Distributed architecture means that your program, which is running on one machine (e.g. your PC or a tablet), can communicate with and command a second program running on another machine (e.g. on the robot). Taking a deep dive into ROS software architecture is beyond the objective of this blog. Nevertheless, I will explain its main concepts using simpler words and examples in the following sections.
Topics and Messages
You may still recall online chatrooms from some late 90s chat programs. People who were interested in a specific topic used to show up in a relevant chat room and talk with each other by exchanging messages. ROS topics and messages work in a similar manner. A software program can show interest in a specific topic by subscribing to its channel or advertising a channel on a new topic. Via these channels, programs can then communicate by exchanging messages.

To understand each other, people must speak the same language in a common chatroom. Likewise, ROS programs must also know the type of the message used in a specific topic. For example, QTrobot advertises a topic called /qt_robot/speech/say which uses a message of type std_msgs/String. It is a very common and standard message type in ROS which represents a simple String (text) message. Messages can have a more complex type composed of different, simpler messages. For example, the /qt_nuitrack_app/faces topic uses a custom message of type qt_nuitrack_app/FaceInfo. This message represents a collection of human facial features such as emotions (e.g. happy, angry, surprised), the person's estimated age, face angles, etc. You may want to take a look at the List of available topics which are advertised by QTrobot.
Publishers and Subscribers
Consider again our chatroom example. The person who is writing a message is the publisher, and those who are reading the message are subscribers. One or multiple publishers can send (publish) messages on the same topic. Similarly, multiple subscribers can receive messages from the same topic.
Service calls
The publish-subscribe model that we have explained is a very flexible communication paradigm. However, it is a one-way communication: one talks and the others listen. Indeed, it is possible to establish two-way communication by letting each entity become a publisher and subscriber at the same time, but as you can imagine, this may get chaotic (especially when everyone wants to talk simultaneously) and become tedious to synchronize. We need something like a request-response model: one requests something from an entity and waits until the other replies. Let's consider a pizza ordering scenario: there is a restaurant which provides a pizza delivery service. The name of this restaurant is Pizzeria. We make a call and request a pizza. If the restaurant offers only one type of pizza, then we do not need to provide them any more information, but in most cases we need to let them know at least which type of pizza we would like. We may even want to further customize our order by choosing among different topping options (parameters) they offer. Then all we need is to wait until the restaurant sends us our pizza.
ROS services work in a similar fashion. A software program provides and advertises a specific type of service along with the required parameters. Other programs can call that service and get the response. For example, QTrobot provides a service called /qt_robot/speech/config to configure the robot's speaking language. The type of this service is qt_robot_interface/speech_config and has some parameters such as language and speed. Another program can call this service to change the robot's speaking language and talking speed at run time.
QTrobot ROS Topics and Services
To get the list of all Topics or Services, you can run one of these commands:
Topics:
rostopic list
Services:
rosservice list
QTrobot speech interface
Let's start with the QTrobot speech interface. If you run rostopic list, you will see that one of the topics is /qt_robot/speech/say. If we publish to that topic, QTrobot will say the text message that we wrote. Open the terminal and try this:
Publisher:
rostopic pub /qt_robot/speech/say std_msgs/String "data: 'Hello I am QT'"
Service call:
rosservice call /qt_robot/speech/say "message: 'Hello I am QT'"
QTrobot talk text interface
The /qt_robot/behavior/talkText interface is similar to the /qt_robot/speech/say interface, with the only difference being that the talkText interface asks QTrobot to move his lips while reading the text message. To try it, just add the following lines to your code and look at the QTrobot's face:
Publisher:
rostopic pub /qt_robot/behavior/talkText std_msgs/String "data: 'Hello I am QT'"
Service call:
rosservice call /qt_robot/behavior/talkText "message: 'Hello I am QT'"
QTrobot emotion interface
Now let's show an emotion on QTrobot's face. QTrobot comes with plenty of predefined emotion animations. You can find the complete list of the available emotions either using the QTrobot Educator app or by looking into the ~/robot/data/emotions folder in QTRP.
Publisher:
rostopic pub /qt_robot/emotion/show std_msgs/String "data: 'QT/happy'"
Service call:
rosservice call /qt_robot/emotion/show "name: 'QT/happy'"
As shown in the above example, you should not give the emotion's file extension (.avi) to the interface!
QTrobot gesture interface
Now let's play a gesture with QTrobot. QTrobot comes with plenty of predefined gestures. You can find the complete list of the available gestures either using the QTrobot Educator app or by looking into the ~/robot/data/gestures folder in QTRP.
Publisher:
rostopic pub /qt_robot/gesture/play std_msgs/String "data: 'QT/happy'"
Service call:
rosservice call /qt_robot/gesture/play "name: 'QT/happy'
speed: 0.0"
rosservice call /qt_robot/gesture/play "name: '' speed: 0.0"
As shown in the above example, you should not give the gesture's file extension (.xml) to the interface!
QTrobot audio interface
Now let's play an audio file on QTrobot. QTrobot comes with some audio examples. You can find the complete list of the available audio files either using the QTrobot Educator app or by looking into the ~/robot/data/audios folder in QTRP. QTrobot can play both wav and mp3 audio files.
Publisher:
rostopic pub /qt_robot/audio/play std_msgs/String "data: 'QT/Komiku_Glouglou'"
Service call:
rosservice call /qt_robot/audio/play "filename: 'QT/Komiku_Glouglou'
filepath: ''"
As shown in the above example, you do not need to give the audio file's extension (.wav or .mp3) to the interface!