Technology Sharing

ROS Basic Learning-ROS Operation Management

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

ROS operation management

1. Brief introduction to ROS operation management

ROS is a multi-process (node) distributed framework. A complete ROS system implements:

May contain multiple hosts;
There are multiple workspaces on each host;
Each workspace contains multiple functional packages;
Each function package contains multiple nodes, and different nodes have their own node names;
Each node may also set one or more topics...

insert image description here
In a multi-level ROS system, there may be some problems in its implementation and maintenance, such as:
1. How to associate different function packages----(meta function packages)
2. How to start various ROS nodes----(launch file)
3. How to deal with duplicate names of function packages, nodes, topics, and parameters? (Solution to duplicate name problem)
4. How do nodes on different hosts communicate? (Distributed communication)

This chapter mainly introduces the solution strategies for the above problems in ROS (see the table of contents of this chapter). The expected learning objectives also correspond to the above problems:

  • Master the syntax of using meta-function packages;
  • Master the syntax of launch files;
  • Understand what ROS workspace overlays are and what security risks they pose;
  • Understand how to handle duplicate node names;
  • Understand how to handle topic names that have the same name;
  • Understand how to handle duplicate parameter names;
  • Capable of implementing ROS distributed communication.

2. ROS Meta-Function Package

Scenario: To complete a systematic function in ROS, multiple function packages may be involved. For example, a robot navigation module is implemented, which has different sub-function packages such as map, positioning, path planning, etc. So when the caller installs the module, does he need to install each function package one by one?

Obviously, installing function packages one by one is inefficient. In ROS, a way is provided to package different function packages into one function package. When installing a function module, you can directly call the packaged function package, which is also called a metapackage.

2.1 Concept

MetaPackage is a file management system concept in Linux. It is a virtual package in ROS. It has no substantial content, but it depends on other software packages. In this way, other packages can be combined. We can think of it as a directory index of a book, telling us which sub-packages are in this package set and where to download them.

For example:

  • The command sudo apt install ros-noetic-desktop-full uses the meta-function package when installing ros. This meta-function package depends on some other function packages in ROS. When installing this package, the dependencies will be installed together.
    There are also some common MetaPackages: navigation moveit! turtlebot3 …

2.2 Function

To facilitate user installation, we only need this one package to organize other related software packages together for installation.

2.3 Implementation

Step 1: First: create a new function package
Step 2: Then: modify package.xml, the content is as follows:

<exec_depend>Integrated function packages</exec_depend>

<export>
<metapackage />
</export>
insert image description here

step3: Finally: modify CMakeLists.txt, the content is as follows:

cmake_minimum_required(VERSION 3.0.2)
project(demo)
find_package(catkin REQUIRED)
catkin_metapackage()

Only keep the above four lines and delete the rest

Also see:
http://wiki.ros.org/catkin/package.xml#Metapackages

3. ROS-launch file

We are already familiar with the use of launch files. In the first chapter, we introduced:

A program may need to start multiple nodes. For example, in the ROS built-in turtle case, if you want to control the turtle's movement, you need to start multiple windows, starting roscore, turtle interface node, and keyboard control node respectively. If you call rosrun to start them one by one each time, it is obviously inefficient. How can you optimize it?

The optimization strategy adopted is to use the roslaunch command set launch file to start the management node, and the launch file is also used many times in subsequent tutorials.

3.1. ROS node management launch file

3.1.1 Concept

The launch file is an XML file that can start multiple local and remote nodes and set parameters in the parameter server.

3.1.2 Function

Simplify the configuration and startup of nodes and improve the startup efficiency of ROS programs.

3.1.3 Use

Take turtlesim as an example

Step 1. Create a new launch file
Add a launch directory under the function package, create a new xxxx.launch file under the directory, and edit the launch file

<launch>
<node pkg=“turtlesim” type=“turtlesim_node” name=“myTurtle” output=“screen” />
<node pkg=“turtlesim” type=“turtle_teleop_key” name=“myTurtleContro” output=“screen” />
</launch>

Step 2. Call the launch file

roslaunch package name xxx.launch

Note: When the roslaunch command executes the launch file, it will first determine whether roscore is started. If it is started, it will not be started again. Otherwise, roscore will be called automatically.

For reference:
http://wiki.ros.org/roslaunch/XML

3.2 launch file tags

https://www.bilibili.com/video/BV1Ci4y1L7ZZ?p=150&spm_id_from=pageDriver&vd_source=15dd2e64f0499027ca66125b65dd2de9