[ROS study notes 3] ROS architecture

[ROS study notes 3] ROS architecture

Written in the front, this series of notes refers to the tutorial of AutoLabor, the specific project address is here


Zero. Foreword

From the perspective of system architecture, ROS can be divided into three layers

  • The OS layer is the operating system in the classic sense

    ROS is just a meta-operating system, which needs to rely on a real operating system. At present, the better compatibility is Linux Ubuntu

  • The middle layer is the middleware for robot development encapsulated by ROS, such as:

    • TCPROS/UDPROS communication system based on TCP/UDP continuous encapsulation
    • Used for inter-process communication Nodelet, providing support for real-time data transmission
    • In addition, it also provides a large number of robot development and implementation libraries, such as: data type definition, coordinate transformation, motion control...
  • application layer

    Feature packs, and nodes within feature packs.

From the point of view of its own structure, ROS can be divided into three layers

  • System Files

    The ROS filesystem level refers to the organization of ROS source code viewed on disk

  • Computation graph

    Different processes in the ROS distributed system need to interact with data. The calculation graph can represent the data interaction process in the form of a point-to-point network. The important concepts in the calculation graph: node (Node), message (Message), communication mechanism - topic (topic) , Communication mechanism - service (Service)


1. ROS system files

The ROS file system level refers to the organizational form of the ROS source code on the hard disk, and its structure can be roughly shown in the figure

WorkSpace --- 自定义的工作空间

    |--- build:编译空间,用于存放CMake和catkin的缓存信息、配置信息和其他中间文件。

    |--- devel:开发空间,用于存放编译后生成的目标文件,包括头文件、动态&静态链接库、可执行文件等。

    |--- src: 源码

        |-- package:功能包(ROS基本单元)包含多个节点、库与配置文件,包名所有字母小写,只能由字母、数字与下划线组成

            |-- CMakeLists.txt 配置编译规则,比如源文件、依赖项、目标文件

            |-- package.xml 包信息,比如:包名、版本、作者、依赖项...(以前版本是 manifest.xml)

            |-- scripts 存储python文件

            |-- src 存储C++源文件

            |-- include 头文件

            |-- msg 消息通信格式文件

            |-- srv 服务通信格式文件

            |-- action 动作格式文件

            |-- launch 可一次性运行多个节点 

            |-- config 配置信息

        |-- CMakeLists.txt: 编译的基本配置

1、package.xml

This file defines properties about the package, such as package name, version number, author, maintainer, and dependencies on other catkin packages.

2、CMakeLists.txt

Files CMakeLists.txtare input to the CMake build system for building packages. Any CMake-compatible package contains one or more CMakeLists.txtfiles that describe how to build the code and where to install it.


Two, ROS file system related commands

ROS's file system is essentially an operating system file. We can use Linux commands to operate these files. However, in order to be more convenient in ROS, ROS provides some Linux-like commands. These commands are better than native Linux commands. , more concise and efficient. File operations are nothing more than operations such as adding, deleting, checking, modifying, and executing. Next, we will introduce some common commands of the ROS file system from these five dimensions.

1. increase

catkin_create_pkg  自定义包名 依赖包  #创建新的ROS功能包
sudo apt install xxx				#安装ROS功能包

2. delete

sudo apt purge xxx   #删除某个功能包

3. Check

rospack list		#列出所有的功能包
rospack find 包名		#查找某个功能包是否存在,如果存在返回安装路径
roscd 包名			#进入某个功能包
rosls 包名			#列出某个包下的文件
apt search xxx		#搜索某个功能包

4. Change

rosed 包名 文件名 #修改功能包文件

5. Execution

roscore		#roscore是ROS系统先决条件节点和程序的集合,必须运行roscore才能使ROS节点进行通信
roscore -p xxxx		#可以指定端口号

roscore will start

  • ros master
  • ros parameter server
  • rosout log node
rosrun 包名 可执行文件名	#运行指定的ROS节点
roslaunch 包名 launch文件名	#执行某个包下的launch文件

3. ROS calculation diagram

A useful tool is provided in ROS:rqt_graph

rqt_graphAbility to create a computational graph that shows the current system operation. Different processes in the ROS distributed system need to interact with data, and the calculation graph can represent the process of data interaction in the form of a point-to-point network.

1. Installation of calculation graph

If all the function packages (packages) have been installed in the early stage, enter directly in the terminal window

rosrun rqt_graph rqt_graph

That's it, if it is not installed, enter it in the terminal

$ sudo apt install ros-<distro>-rqt
$ sudo apt install ros-<distro>-rqt-common-plugins

Please replace it with your ROS version name (for example: kinetic, melodic, Noetic, etc.).

For example, the current version is Noetic, just enter in the terminal window

$ sudo apt install ros-noetic-rqt
$ sudo apt install ros-noetic-rqt-common-plugins

2. The use of calculation graphs

Use it directly when running the ros program smoothly

rosrun rqt_graph rqt_graph

The calculation graph is displayed.
Take controlling the movement of a little turtle as an example


4. Reference

http://www.autolabor.com.cn/book/ROSTutorials/chapter1/15-ben-zhang-xiao-jie.html

Guess you like

Origin blog.csdn.net/qq_44940689/article/details/129209138