Introduction to ROS – Week 1

By: Jin Pyo Jeon

Recommended Reading: A Gentle Introduction to ROS (Chapter 1), ROS Wiki on Publisher and Subscriber.

Robot Operating System, commonly abbreviated as ROS, is a misnomer – after all, it is not an operating system like Windows and Linux, nor does it perform various tasks that ‘proper’ OS do, like file management.

However, it is an operating system in a sense that it helps manage the difficulties of running multiple programs in a collaborative fashion.

What do I mean? Since there are many technical descriptions of ROS online, let me instead tell you of the problems that ROS solves.

ROS solves problems like:

  • the need to develop a communication scheme between programs, either within one computer or across multiple computers
  • the need to develop and implement tools, algorithms, and hardware drivers that are commonly used in Robotics
  • the problem of programs of different sources having a different interface – and thus being difficult to ‘stitch’ together
  • the difficulty of building, developing and launching several programs (or, more accurately, processes)

There are, of course, other frameworks and libraries that solve some, maybe even most, of these problems, but you should use ROS because it is

  • rapidly becoming industry standard due to its open-source nature
  • and its emphasis on distributed computing (that is, ROS is focused on being able to run on multiple computers and devices, ranging from laptops to microcontrollers like Arduino).

Of course, these introductions do not mean anything if we can’t do anything practical, so let’s dive in immediately.

ROS supports both C++ and Python (and for some, Lisp), but I recommend that you use Python for all but really computationally intensive tasks (like image processing or rapid calculations), as programs in Python do not need to involve a relatively complicated build system called Catkin in order to run. Nor is it fun to resolve pointer issues when you just want the robot to run.

However, you can indeed use both languages in the same robot by using the communication interface provided in ROS. ROS programs primarily communicate using two interfaces: topic and service.

Communicating through a topic is a many-to-many communication, that is, multiple programs can read and write to the same topic, done by programs called subscribers and publishers respectively. The communications through topics are managed by a node (term for programs in ROS) called master node.

Service is one-to-one communication in that one node sends a request for a service and another responds (using a function specified called callback); however, many nodes (called client) can call a service.

As an example, topics are commonly used for the streaming of the sensor data, and services are used to occasionally request for a specific state or data.

For more info on the applications, refer to:

http://answers.ros.org/question/11834/when-should-i-use-topics-vs-services-vs-actionlib-actions-vs-dynamic_reconfigure/

http://wiki.ros.org/ROS/Patterns/Communication#Communication_via_Topics_vs_Services_vs_X

Now, given that most functions could be done with a publisher & subscriber (but not so with service & request), refer to the ROS wiki on writing publisher and subscriber (preferrably in Python).

http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber(python)

Challenge: Write a publisher that publishes random odometry data (message name is nav_msgs/Odometry) and a subscriber that echoes the message.

Leave a Reply

Your email address will not be published. Required fields are marked *