Basic concepts and system architecture of ROS Installation and simple testing of ROS

Publisher:QingfangLatest update time:2023-11-15 Source: 车路漫漫Author: Lemontree Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The build folder contains caches, configurations, intermediate files, etc. generated when compiling CMake and catkin function packages.

The devel folder contains compiled executable programs that can be run directly without installation. Once the source code of the feature package is compiled and tested, these compiled executable files can be directly exported and shared with other developers.

A function package is the basic form of software organization in ROS. It has the minimum structure and content for creating a ROS program. It contains ROS node source code, scripts, configuration files, etc.

CMakeLists.txt is a feature package configuration file, which is used to compile the compilation configuration when compiling the Cmake feature package.

package.xml is a feature package manifest file, which uses XML format to mark various aspects of the feature package, such as the package name, developer information, dependencies, etc., mainly to make the installation and distribution of the feature package easier.

include/ This is the function package header file directory. You can put the *.h header files included in the function package program here. The reason why the include directory needs to add a first-level path This is to better distinguish between self-defined header files and system standard header files. Replace it with the name of the actual package. However, this folder is not necessary, for example, some programs do not have header files.

The three folders msg, srv and action are used to store the definition files of non-standard topic messages, service messages and action messages respectively. ROS supports user-defined message types used in the message communication process. These custom messages are not necessary, for example, the program only uses standard message types.

The scripts directory stores script files such as Bash and Python and is not necessary.

The launch directory stores the startup files of the nodes. The *.launch files are used to start one or more nodes. They are very useful in large projects with multiple nodes and are not necessary.

The src directory stores the source code corresponding to the function package nodes. A function package can have multiple node programs to complete different functions, and each node program can run independently. The src directory stores the source code of these node programs. You can create folders and files as needed to organize the source code. The source code can be written in C++, Python, etc.

6.3. Understanding ROS architecture from the perspective of the open source community

ROS is open source software. Independent online communities share and contribute to the software, forming a powerful ROS open source community, as shown in the figure below.

The development of ROS relies on open source and shared software, which is shared and released by different organizations, such as GitHub source code sharing, Ubuntu software repository release, third-party libraries, etc. The official wiki of ROS is an important document discussion community, where you can easily publish and modify the corresponding document pages. The ROS answer homepage has a large number of questions and answers from ROS developers, and the discussion on various problems encountered in ROS development is very active.

7. Installation and testing of ROS

7.1. Update software sources

Before starting the installation, it is strongly recommended that you update the system source (many basic environment packages will be installed from here). I used Alibaba's source here, and the update method is as follows:

First you need to back up the original source list file

sudocp -/etc/apt/sources.list/etc/apt/sources.list.bak

Then start editing the source list file:

sudo gedit /etc/apt/sources.list

Delete the original contents in sources.list, then fill in the following contents and save:

debhttp://mirrors.aliyun.com/ubuntu/jammymainrestrictduniversemultiverse
deb-srchttp://mirrors.aliyun.com/ubuntu/jammymainrestricteduniversemultiverse
debhttp://mirrors.aliyun.com/ubuntu/jammy-securitymainrestricteduniversemultiverse
deb-srchttp://mirrors.aliyun.com/ubuntu/jammy-securitymainrestricteduniversemultiverse
debhttp://mirrors.aliyun.com/ubuntu/jammy-updatesmainrestricteduniversemultiverse
deb-srchttp://mirrors.aliyun.com/ubuntu/jammy-updatesmainrestricteduniversemultiverse
debhttp://mirrors.aliyun.com/ubuntu/jammy-proposeinrestricteduniversemultiverse
deb-srchttp://mirrors.aliyun.com/ubuntu/jammy-proposedmainrestricteduniversemultiverse
debhttp://mirrors.aliyun.com/ubuntu/jammy-backportsmainrestricteduniversemultiverse
deb-srchttp://mirrors.aliyun.com/ubuntu/jammy-backportsmainrestricteduniversemultiverse

Note: Although they are all from the Ali source, there are different source versions for different systems. My Ubuntu system is the jammy version, and the Ali source should also be this version. Then update the software in your system according to this source:

sudo apt-get update
sudo apt-getupgrade

This process should take quite a long time, but there should be no errors when it is completed. If there are task errors, please search on Baidu.

Then install ROS2 according to the official tutorial. The official installation tutorial link is as follows:

https://docs.ros.org/en/humble/Installation.html

7.2. Check the operating system language environment

In the official ROS2 documentation, you need to check the operating system language environment before installing ROS2. Official explanation: Make sure you have a language environment that supports U-8. If you are in a minimal environment (such as a Docker container), then the language environment may be minimal like POSIX. We check it with the following settings.

We can press Ctrl+Alt+T to call up the terminal and enter locale to check whether UTF-8 is supported. If not, you need to continue to execute the following instructions to set it:

locale#Check if UTF-8 is supported
sudoaptupdate&&sudoaptinstalllocales
sudolocale-genen_USen_US.UTF-8
sudoupdate-localeLC_ALL=en_US.UTF-8LANG=en_US.UTF-8
exportLANG=en_US.UTF-8
locale#Verify that the settings are correct

7.3、Ubuntu universe repository setup and startup

Before setting up the ROS2 software source, we need to first enable the Ubuntu universe repository. To enable the Ubuntu universe repository, we can do this through the command line by opening a terminal.

According to the official documentation, we can start the Ubuntu universe repository by entering the following command in the command line:

sudoaptinstallsoftware-properties-common
sudod-apt-repositoryuniverse

7.4. Set up ROS software source

First add the ROS 2 apt repository updates to the system, then authorize the ROS 2 GPG key through apt, using the commands below:

sudoaptupdate&&sudoaptinstallcurl
sudocurl-sSLhttps://raw.githubusercontent.com/ros/rosdistro/master/ros.key-o/usr/share/keyrings/ros-archive-keyring.gpg

Then add the repository to our sources list with the following instructions.

echo"deb[arch=$(dpkg--print-architecture)signed-by=/usr/share/keyrings/ros-archive-keyring.gpg]http://packages.ros.org/ros2/ubuntu$(. /etc/os-release&&echo$UBUNTU_CODENAME)main"|sudotee/etc/apt/sources.list.d/ros2.list>/dev/null

7.5. Install ROS2

After setting up the repository, first update the apt repository cache by running the following command:

sudo apt update

Since ROS 2 is built on the frequently updated Ubuntu system, it is officially recommended to make sure your system is up to date before installing new packages. We can update the installed software with the following instructions:

sudo apt upgrade

ROS installation version selection and installation instructions:

ROS2 desktop version installation (official), including: ROS, Rviz, official demo, tutorial

sudoaptinstallros-humble-desktop

ROS2 basic version installation (bare metal), including: communication library, message package, command line tools, etc., but no GUI tools.

sudoaptinstallros-humble-ros-base

Here we install the desktop version of ROS2 and enter the following installation command:

sudoaptinstallros-humble-desktop

7.6 Environment Configuration

The official document gives the method of environment configuration. Before executing the ROS2 program in the terminal, you need to call the following command to configure the environment so that the program can be executed correctly.

#Replace".bash"withyourshellifyou'renotusingbash
#Possiblevaluesare:setup.bash,setup.sh,setup.zsh
source/opt/ros/humble/setup.bash

For the official environment configuration method, since each time a new terminal is opened, the environment needs to be configured, which reduces the efficiency of development and testing. In order to avoid this problem of environment configuration each time a new terminal is opened, we can write the configuration environment instructions into the "~/.bashrc" file through the following instructions, so that each time a new terminal is started, there is no need to manually configure the environment:

#Write the configuration environment instructions into the "~/.bashrc" file using the following instructions
echo "source/opt/ros/humble/setup.bash">>~/.bashrc
#View the "~/.bashrc" file
sudogedit ~/.bashrc

So far, we have completed the installation and environment configuration of ROS2. Next, we will conduct environmental testing of ROS2.

8. Use cases of ROS operating system

8.1. Case 1 - talker and listener

We need to open two terminal windows and enter the following command in each.

Start the first terminal and start a data publisher node with the following command :

ros2rundemo_nodes_cpptalker

Start a second terminal and start a data subscriber node with the following command :

ros2rundemo_nodes_pylistener

[1] [2] [3]
Reference address:Basic concepts and system architecture of ROS Installation and simple testing of ROS

Previous article:Pangu is here! China's first bridge-type explosion-proof heavy-load handling robot rolls off the production line
Next article:Transmission efficiency test of precision reducer for industrial robot

Latest robot Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号