📜 ⬆️ ⬇️

Robotic Operating System Basics

Introduction


Good all the time of day!
Learning once again the open spaces of Habr, I noticed that there is practically no information about the Robotic Operating System (hereinafter simply ROS). I will hasten to correct this mistake and popularize a wonderful product.
image
What is it? ROS is an add-on operating system that allows you to easily and easily develop robot control systems. What does this mean and how to live with it then - and a series of topics is intended to tell.
Essentially, ROS is a collection of various widely (and non-very) well-known libraries, such as:

Also in ROS includes drivers for various manipulators and sensors (including MS Kinect). But what distinguishes ROS from a simple build of libraries? The fundamental advantage is the client-server architecture of ROS - the developers have implemented a mechanism for sending messages between different objects, the ability to build distributed systems, and the provision of bridges to C ++ and Python languages.
To start using ROS, you still have to start with the installation. The very same work plan looks like this:
  1. Installation, basic concepts
  2. Create your package, get acquainted with the messages, a simple program
  3. Services and options

Deployment


Today, ROS is stably installed and works only on Ubuntu versions 10 and above, using the example of Natty, we will consider all the details of this process.
So, the first step is setting up repositories. We need to unblock the "restricted," "universe," and "multiverse" components; for this, the following lines need to be uncommented in the /etc/apt/sources.list file:
deb-src http://security.ubuntu.com/ubuntu natty-security main restricted deb http://security.ubuntu.com/ubuntu natty-security universe deb-src http://security.ubuntu.com/ubuntu natty-security universe deb http://security.ubuntu.com/ubuntu natty-security multiverse deb-src http://security.ubuntu.com/ubuntu natty-security multiverse 

Then you need to add a repository for installation and updates:
 sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu natty main" > /etc/apt/sources.list.d/ros-latest.list' 

The next step is the installation of a digital signature. Here, everything is also quite trivial:
 wget http://packages.ros.org/ros.key -O - | sudo apt-key add - 

After this update:
 sudo apt-get update 

and try to install the ROS meta-package itself. There are 4 installation packages that differ in the amount of modules provided. I will use the most complete:
 sudo apt-get install ros-electric-desktop-full 

After the process of downloading and deploying all sorts of gizmos, in the directory / opt you should see the ros folder.
The last step is to update the environment variables:
 source /opt/ros/electric/setup.bash 

From this point on, ROS is ready for battle . To make sure the installation is successful, open two terminals, in one write:
 roscore 

This will launch the master process from which the ROS, in fact, begins work.
In another write
 rosrun turtlesim turtlesim_node 

And do not forget to initialize the environment variables in each terminal first!
 source /opt/ros/electric/setup.bash 

image If a cute little turtle appeared in front of you, then everything is fine. Do not close this window, it is still useful to us. To make it not so boring, open a new terminal and enter the following:
 rosrun turtlesim turtle_teleop_key 

From this terminal you can now control the reptile.
The installation process on other operating systems is not much more complicated, but, unfortunately, much less stable (on Fedora 15, for example, I never managed to start). We can only recommend to write bug reports, publish patches and be happy to everyone.

Basic concepts


We start by looking at the basic concepts of the ROS file system.
Package (package) is the smallest unit of FS. It is a directory containing any data, libraries, executable and configuration files, etc. etc., logically combined into some useful module. The purpose of such structuring is completely transparent - increasing usability and reusability.
The package structure is as follows:

In turn, the packages are combined into stacks . In the picture you can see an example of such a structure.
image
As you can see, ROS has a rather complicated file system and in order not to bother with long paths to various directories, users are provided with a number of utilities.
rospack find [pack_name] - gives the full path to the directory with the package
 crady@cradyLap:~$ rospack find rviz /opt/ros/electric/stacks/visualization/rviz 


rosstack find [pack_name] is the same, but for the stack
 crady@cradyLap:~$ rosstack find navigation /opt/ros/electric/stacks/navigation 

This, so to speak, is static. Dynamics in ROS is described by nodes (node) and tires (topic).
A node is a running process that can communicate with other processes.
A bus is a named pipe connecting various nodes.
Nodes and buses form an asynchronous data exchange mechanism. If you still have a window with a bug, then you can see it now. If it is closed, then somewhere above it is written how to put everything back.
Open the third terminal and enter the command
 rxgraph 

image
In the new window you will see which nodes are now active and which tires they communicate with each other. If you also want to hear what they are discussing there, then you need the following command:
 rostopic echo /turtle1/command_velocity 

Move the turtle and see how the commands appear on the / turtle1 / command_velocity bus.
image
')
image

Conclusion


On this, perhaps, that's all for today. There are more services, parameters, detailed explanations of messages and tires, and now it's time to reward those who have mastered the basics of ROS with a bottle of the cold-one. )



Useful links:
  1. www.ros.org/wiki - headquarters of users and developers
  2. answers.ros.org/questions - collective intelligence will help you with any problems (but, nevertheless, not beyond ROS)

Source: https://habr.com/ru/post/128024/


All Articles