UvodDoKomponent: ROS

from Wiki KIVu

Navigace

Robot Operating System (ROS)

ROS is an open-source, meta-operating system for your robot. It provides the services you would expect from an operating system, including hardware abstraction, low-level device control, implementation of commonly-used functionality, message-passing between processes, and package management. It also provides tools and libraries for obtaining, building, writing, and running code across multiple computers. It is a distributed framework of processes (aka Nodes) that enables executables to be individually designed and loosely coupled at runtime. These processes can be grouped into Packages and Stacks, which can be easily shared and distributed. ROS also supports a federated system of code Repositories that enable collaboration to be distributed as well. This design, from the filesystem level to the community level, enables independent decisions about development and implementation, but all can be brought together with ROS infrastructure tools.

In this case, ROS is just one implementation then the terms model and framework are not different. When we talk about ROS it is meant as the framework and definitions of each part of it is the model.

More and up to date information you can find at the official documentation webpage: http://wiki.ros.org/ROS/Introduction

Architecture

ROS represents a peer-to-peer network that processes data together. The basic graph concept is composed of nodes, services and topics.

Node

A node is a process that performs computation. It represents a component. Nodes are combined together into a graph and communicate with one another using streaming topics, RPC services, and the Parameter Server. These nodes are meant to operate at a fine-grained scale; a robot control system will usually comprise many nodes.

There is additional fault tolerance as crashes are isolated to individual nodes. Implementation details are also well hidden as the nodes expose a minimal API to the rest of the graph and alternate implementations, even in other programming languages, can easily be substituted.

A ROS node is written with the use of a ROS client library, such as roscpp or rospy. You can find an example in C++ language that is shown below.

 bool add(beginner_tutorials::AddTwoInts::Request  &req, beginner_tutorials::AddTwoInts::Response &res) {
   res.sum = req.a + req.b;
   ROS_INFO("request: x=%ld, y=%ld", (long int)req.a, (long int)req.b);
   ROS_INFO("sending back response: [%ld]", (long int)res.sum);
   return true;
 }

 int main(int argc, char **argv) {
   ros::init(argc, argv, "add_two_ints_server");
   ros::NodeHandle n;
   ros::ServiceServer service = n.advertiseService("add_two_ints", add);
   ROS_INFO("Ready to add two ints.");
   ros::spin();
   return 0;
 }

More information at the official documentation: http://wiki.ros.org/Nodes

Topic

Topics are named buses over which nodes exchange messages. Topics have anonymous publish/subscribe semantics, which decouples the production of information from its consumption. In general, nodes are not aware of who they are communicating with. Instead, nodes that are interested in data subscribe to the relevant topic; nodes that generate data publish to the relevant topic. There can be multiple publishers and subscribers to a topic.

Service

Request / reply is done via a Service, which is defined by a pair of messages: one for the request and one for the reply (see example below). A providing ROS node offers a service under a string name, and a client calls the service by sending the request message and awaiting the reply. Client libraries usually present this interaction to the programmer as if it were a remote procedure call.

An example of service definition is shown below:

int64 a
int64 b
---
int64 sum

More information at the official documentation: http://wiki.ros.org/Services

Message

Nodes communicate with each other by passing messages. A message is simply a data structure, comprising typed fields. Standard primitive types (integer, floating point, boolean, etc.) are supported, as are arrays of primitive types. Messages can include arbitrarily nested structures and arrays (much like C structs).

More information at the official documentation: http://wiki.ros.org/Messages

Conclusion

ROS is a framework and is the only implementation of the model. The component of the ROS is a node, which represents a computing unit. The node publishes messages into a bus (topics), and another node receives messages. In this mode, the node implements a publish / subscribe pattern. The two nodes can also be used as a client / server mode or RPC service. This is done by services that have a defined message for request and part for response. The whole solution is hosted on roscore, which is a runtime environment of the framework and runs on a supported platform, and individual nodes can be run on microcontrollers and connected to the master node (to the platform).

Tutorials

0. Installing and Configuring Your ROS Environment

1. Creating a ROS Package

Publish / Subscribe pattern (C++)

2. Writing a Simple Publisher and Subscriber

3. Examining the Simple Publisher and Subscriber

Remote procedure pattern (C++)

2. Creating a ROS msg and srv

3. Writing a Simple Service and Client

4. Examining the Simple Service and Client

Retrieved from http://wiki.kiv.zcu.cz/UvodDoKomponent/ROS
Content last modified on 28 January 2021, 11:47