Difference between revisions of "ROS HOWTO"

From AIRWiki
Jump to: navigation, search
m
m
Line 1: Line 1:
[http://www.ros.org/wiki/ ROS] (Robot Operating System) is an open-source framework for the creation of software for robots. It is a very interesting tool, since it promises to take care of many of the lower-level issues that make realizing the software for autonomous robots so difficult and time-consuming. By leaving such issues (e.g., communication among modules) to ROS, the programmer can focus on the more interesting high-level issues (e.g., perception).
+
[http://www.ros.org/wiki/ ROS] (Robot Operating System) is an open-source framework for the creation of software for robots. It is a very interesting tool, since it promises to take care of many of the lower-level issues that make realizing the software for autonomous robots so difficult and time-consuming. By leaving such issues (e.g., communication among modules) to ROS, a researcher can focus on the more interesting high-level issues (e.g., perception).
More precisely, in the words of [http://www.willowgarage.com/ its creators]:
+
In the words of [http://www.willowgarage.com/ its creators]:
  
 
''"ROS provides libraries and tools to help software developers create robot applications. It provides hardware abstraction, device drivers, libraries, visualizers, message-passing, package management, and more."''
 
''"ROS provides libraries and tools to help software developers create robot applications. It provides hardware abstraction, device drivers, libraries, visualizers, message-passing, package management, and more."''
  
ROS includes a large collection of '''packages''' that you can incorporate into your own system. A ROS package is a bundle of software dedicated to a single functionality (e.g., data acquisition from a Hokuyo URG-series laser scanner). Your own ROS-based applications will take the form of one or more ROS packages. If they can be useful to other people as well, once they are completed and tested such packages could become part of ROS: much of ROS has this type of origin.
+
ROS includes a large collection of '''packages''' that you can incorporate into your own system. A ROS package is a bundle of software dedicated to a single functionality (e.g., data acquisition from a Hokuyo URG-series laser scanner). Your own ROS-based applications will take the form of one or more ROS packages. If they can be useful to other people as well, once they are completed and tested such packages could become part of ROS: much of ROS was born in this way.
  
Though striving to be as easy-to-use as possible, ROS is a very complex tool. This is unavoidable, as autonomous robots themselves are extremely complex systems. Before you can start building your own software based on ROS, you have to devote a fair amount of time to studying how it works and how to use it. '''This part of the wiki is dedicated to helping you start using ROS as quickly as possible.'''
+
Though striving to be as easy-to-use as possible, ROS is a complex tool. This is unavoidable, as autonomous robots themselves are very complex systems. Before you can start writing your own ROS-based software, you have to devote a fair amount of time to studying how it works and how to use it. '''This part of the wiki is dedicated to helping you start using ROS as quickly as possible.'''
  
 
== How to get ROS ==
 
== How to get ROS ==
This is probably the single aspect where the ROS team succeeded best in removing all the difficulties, even for beginners. Installing and updating ROS is very simple: [http://www.ros.org/wiki/ROS/Tutorials/InstallingandConfiguringROSEnvironment this webpage tells you how].
+
This is probably the single aspect where the ROS team succeeded best in removing all the difficulties, even for beginners. Installing ROS is very simple: [http://www.ros.org/wiki/ROS/Tutorials/InstallingandConfiguringROSEnvironment this webpage tells you how].
  
 
== Resources ==
 
== Resources ==
The [http://www.ros.org/wiki/ ROS website] itself includes a good deal of information, and you are invited to use it. However, not all of this information is very clear, nor all topics are equally covered. Here we'll try to complement what's provided by ROS with additional information, instead of saying the same things in another way.
+
The [http://www.ros.org/wiki/ ROS website] itself includes a good deal of information, and you are invited to use it heavily. However, not always the information it provides is very clear for someone who is not an expert in ROS, nor all topics are equally covered. Here we'll try to complement what's provided by ROS with additional information, instead of saying the same things in another way.
Arguably, the most useful tools to learn how to use ROS are the [http://www.ros.org/wiki/ROS/Tutorials basic tutorials]. Be sure to go through them before writing a single line of code. Once you have worked your way through the tutorials, the next thing to do is to write your own ROS package and apply what you have learned. The "Nodes" section below is the suggested starting point for that.
+
Arguably, the most useful tools to learn how to use ROS are the [http://www.ros.org/wiki/ROS/Tutorials basic tutorials]. Be sure to go through them before writing a single line of code (except those that you will write for the tutorial, of course!). Once you have worked your way through the tutorials, the next thing to do is to write your own ROS package and apply what you have learned. The "Nodes" section below is the suggested starting point for that.
 +
Maybe you should start experimenting with a "test" package, before passing to a real application: in this way you can experiment without worrying if the end result is a mess :-)  ''You are strongly invited to experiment'': as always happens with programming, that's the best way to understand and check if you have correctly understood, all at the same time.
  
Finally, [http://www.ros.org/wiki/ROS/Introduction this] is an introduction to the concepts behind ROS: you will not necessarily understand how things are done in practice until you have completed the tutorials, but reading it before passing to these will provide you with useful background. So, do it first thing.
+
Before you start with the tutorials, please read this [http://www.ros.org/wiki/ROS/Introduction introduction to the concepts behind ROS]: you will not necessarily understand how things are done in practice until you have completed the tutorials, but reading it before passing to these will provide you with useful background.
  
 
== Programming languages ==
 
== Programming languages ==

Revision as of 15:51, 18 April 2012

ROS (Robot Operating System) is an open-source framework for the creation of software for robots. It is a very interesting tool, since it promises to take care of many of the lower-level issues that make realizing the software for autonomous robots so difficult and time-consuming. By leaving such issues (e.g., communication among modules) to ROS, a researcher can focus on the more interesting high-level issues (e.g., perception). In the words of its creators:

"ROS provides libraries and tools to help software developers create robot applications. It provides hardware abstraction, device drivers, libraries, visualizers, message-passing, package management, and more."

ROS includes a large collection of packages that you can incorporate into your own system. A ROS package is a bundle of software dedicated to a single functionality (e.g., data acquisition from a Hokuyo URG-series laser scanner). Your own ROS-based applications will take the form of one or more ROS packages. If they can be useful to other people as well, once they are completed and tested such packages could become part of ROS: much of ROS was born in this way.

Though striving to be as easy-to-use as possible, ROS is a complex tool. This is unavoidable, as autonomous robots themselves are very complex systems. Before you can start writing your own ROS-based software, you have to devote a fair amount of time to studying how it works and how to use it. This part of the wiki is dedicated to helping you start using ROS as quickly as possible.

How to get ROS

This is probably the single aspect where the ROS team succeeded best in removing all the difficulties, even for beginners. Installing ROS is very simple: this webpage tells you how.

Resources

The ROS website itself includes a good deal of information, and you are invited to use it heavily. However, not always the information it provides is very clear for someone who is not an expert in ROS, nor all topics are equally covered. Here we'll try to complement what's provided by ROS with additional information, instead of saying the same things in another way. Arguably, the most useful tools to learn how to use ROS are the basic tutorials. Be sure to go through them before writing a single line of code (except those that you will write for the tutorial, of course!). Once you have worked your way through the tutorials, the next thing to do is to write your own ROS package and apply what you have learned. The "Nodes" section below is the suggested starting point for that. Maybe you should start experimenting with a "test" package, before passing to a real application: in this way you can experiment without worrying if the end result is a mess :-) You are strongly invited to experiment: as always happens with programming, that's the best way to understand and check if you have correctly understood, all at the same time.

Before you start with the tutorials, please read this introduction to the concepts behind ROS: you will not necessarily understand how things are done in practice until you have completed the tutorials, but reading it before passing to these will provide you with useful background.

Programming languages

ROS, per se, does not force the developer to use a specific programming language. In practice, while there are expansion plans for the future, at present only two languages are supported: C++ and Python. That is to say, only for these two languages ROS provides client libraries that enable non-ROS software to interface with ROS. Such libraries are called roscpp (for C++) and rospy (for Python). You can choose what language to use on a module-per-module basis, choosing C++ or Python (or whatever other language will be supported in the future) separately for each software module of your ROS system. As we will explain shortly, ROS software modules are called nodes.

Nodes

The basic element of a ROS-based software system is the node. A node is a module of the system, which communicates with other modules using ROS. Communications take the form of messages, the internal structure of which is defined by the programmer. For instance, messages can be used to exchange sensor data or to issue commands. Messages that deal with the same aspect (or set of aspects) of the robot can be grouped by publishing them on the same topic. Each node can subscribe to any number of topics (thus receiving all the messages that are published on them) and/or publish on any number of topics (thus ensuring that each published message reaches all the interested nodes).

In practice, a node is a single executable file: if you use C++, you will write a .cpp file including a main block (along with anything else it needs) and then compile it to produce such executable. A node can perform several types of activities, including:

  • publishing messages to a ROS topic;
  • requesting a service from ROS servers as a ROS client;
  • acting as a ROS server, providing a service to ROS clients;
  • executing a task whenever a message is published on a ROS topic;
  • managing a timeout and execute a task whenever it expires;
  • execute a task periodically.

AIRLab's basic ROS node template provides all the elements that you need to set up the structure of the .cpp file of a basic ROS node, including those that are required for the types of activities listed above. Such elements are implemented in the form of a single C++ class comprehending a suitable set of member variables and member functions, plus a very simple main block. By uncommenting the parts of the template file that you need in your ROS node, you can quickly set up the structure of the node. Moreover, the template includes notes and comments that explain how a ROS node is built and works in practice. So, definitely, take a look at it.