Learning about workspaces in ROS

Introduction to ROS workspace:

The schematic diagram of the workspace is as follows:

insert image description here

 The content of the ROS workspace is divided into 4 categories:


- src: The folder with the most dealings, saves all the codes, each subfolder is a pakage, the source space (src folder), where function packages, projects, copied packages, etc. are placed. In this space, the most important file is CMakeLists.txt. When configuring the package in the workspace, there is CMakeLists.txt in the src folder because cmake calls it. This file is created by the catkin_init_workspace command.
- build: Intermediate compilation files, unless there are strange bugs during compilation, in the build folder, cmake and catkin save cache information, configuration and other intermediate files for function packages and projects.
- devel: The directory of all exec/.py generated, which is also the directory where the ROS system guides the packages written by itself, and will be introduced in detail later

Development (Devel) space: The devel folder is used to save compiled programs, which are programs that can be used for testing without installation. Once a project has passed testing, feature packs can be installed or exported to share with other developers.
- install: The directory where the program is saved when it can be released to the outside world

src directory


Each folder in the src directory represents a package, and each pakage can generate multiple executable files, and each executable file is a ROS node.
Each package contains the following:

include: store the written header file, specify include/*.h when adding CMakeLists.txt
src: save the written source file, specify include/*.cpp
srv (optional) when adding CMakeLists.txt: service agreement The storage location of the file *.src, used with add_service_files() of CMakeLists.txt, directly write the file name, do not add the prefix
msg (optional): the storage location of the service agreement file *.msg, with the add_message_files() of CMakeLists.txt Use, write the file name directly without adding a prefix

devel directory


This directory is usually not independent, but ROS supports both c++/Python output, so it is placed in a folder independently, and the ROS system boot file is provided by default. Specifically include:
-setup.sh/.zsh/.bash: scripts invoked by different shells. After source, the current workspace is booted in the ROS system, and then the generated package can be invoked with commands such as rosrun/roscd/….
-local_setup.sh/.zsh/.bash: used to call setup.sh in the current directory
-__setup__util.py: similar to setup.sh, but used to guide python to load
-env.sh: the environment settings of the current workspace, not Need to call manually
-include: C++ header file directory
-lib: c++ compilation, python code and configuration file directory

[pkg*]: The output directory of the c++ executable file, divided according to the package folder [pkgconfig]: the external boot configuration of C++, used when it is depended on by other libraries, and the *.pc configuration file python3
is provided for each package:
Python output file directory, under which site-package is provided, which can be called externally by python

 Create a ros workspace

1. Create package        

        mkdir -p ~/catkin_ws/src

2. Enter the src folder and initialize

        cd ~/catkin_ws/src

        catkin_init_workspace

3. Go back and compile

        cd ~/catkin_ws/         

        catkin_make

4. Source and add the workspace to the environment variable  

        source devel/setup.bash

Guess you like

Origin blog.csdn.net/weixin_62705892/article/details/127624030