当前位置:网站首页>[introduction to ROS] - 03 ROS workspace and function pack
[introduction to ROS] - 03 ROS workspace and function pack
2022-06-11 01:01:00 【Life is like Zhaoxu】

List of articles
Just like other software learning ,ROS You also need to start with the project , about ROS Come on , At the beginning of the project, you need to create a workspace , Create a feature pack after compiling the build folder , Then continue through the command line , Or programming through code to achieve the goal function , This blog section mainly introduces the contents of the first part , It also briefly introduces the functions of the files in the workspace .
One 、 working space
1. Create a workspace
- Create folder :
mkdir -p ~/catkin_ws/src
In the above order catkin_ws, Is the name of the workspace , This name will be covered in subsequent courses , So you can also use the appropriate name by yourself ,src Is the folder where the feature pack is placed , For storing source code . - Switch to src Folder :
cd ~catkin_ws/src - Create a workspace :
catkin_init_workspace
Command line output prompt :
Creating symlink "/home/zhaoxu/project/ROS/catkin_ws/src/CMakeLists.txt" pointing to "/opt/ros/noetic/share/catkin/cmake/toplevel.cmake"
- Switch to working directory :
cd ~/catkin_ws/ - Compile workspace :
catkin_make
there catkin Note that it is independent of the workspace name , It belongs to fixed command , After compilation, the command line indicates as follows :
- Generate install Folder :
catkin_make install
The instructions here are only intended to be the first to create install file , Essentially meaningless .
2. Set the environment variable
- General practice : You need to reload each time you open the terminal
source devel/setup.bash
- Once and for all : stay .bashrc Add a fixed path to the file , There is no need to source
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
- Query environment variables :
echo $ROS_PACKAGE_PATH
The results are as follows , It proves that the modification is successful
3. Introduction to workspace

- src: Code space ,Source Space, Used to place feature packs ( Code 、 The configuration file 、launch file );
- build: Compilation space ,Build Space, Used to place intermediate files 、 Binary files, etc ;
- devel: Development space ,Development Space, Used to place the executable generated by compilation 、 Script 、 Kuo et al ;
- install: Installation space ,Install Space, Used to place installed files ;
Two 、 Function pack
1. Create and compile feature packs
- Switch to the specified directory :
cd ~/catkin_ws/src - Create Feature Pack :
catkin_create_pkg pkg_ts std_msgs rospy roscpp
Standard directive :catkin_create_pkg <package_name> [depend1] [depend2] …
That is to usecatkin_create_pkgInstruction to create function pack , Depends on the above three dependencies

- Switch to the workspace Directory :
cd ~catkin_ws - Compile function packs :
catkin_make
Be careful : Under the same workspace , A feature pack with the same name is not allowed ; In different workspaces , Feature packs with the same name are allowed
2. Function package file parsing

- include: For placement The header file
- src: For placement Source file
- CMakelist.txt: Compile configuration file , Describe the Compilation Rules of the function package
- package.xml: Feature Pack list file , contain name、version、 Description information 、author email、depend、license etc.
Here we focus on the latter two :
1)CMakelist.txt
The function of documents :CMakeList.txt File is CMake The input file of the compilation process of the compilation system . whatever CMake Compatible packages contain one or more CMakeLists.txt file , These documents describe How to compile the code and where to install it . take CMakeLists.txt File applies to a catkin Project time , It is a standard with some restrictions vanilla CMakeLists.txt file . Use CMake When compiling a program ,cmake Instruction basis CMakeLists.txt File generation makefiles file ,make The order is based on makefiles The file compilation link can generate Executable files
Supplementary knowledge :catkin_make, It's actually ROS Compiler system of take cmake and make Unified encapsulated instructions , Therefore, in essence, it is still the use of cmake and make The process of compiling .
Sequential structure analysis :

- CMake edition :cmake_minimum_required(VERSION 3.0.2)
- Package name :project(pkg_ts)
- Declare dependency Library :find_package()

- start-up python Module support :catkin_python_package()

- news / service / operation (Message/Service/Action) generator : add_message_files(),add_service_files(),add_action_files()

- Call message / service / Operation generation :generate_messages()

- Dynamically reconfigure parameters :generate_dynamic_reconfigure_options() ,cfg The configuration file , Used to configure some rviz Format , Record some configuration parameters

- Specify the export of package compilation information :catkin_package()

- a key : Add libraries and executables to compile :add_library()/add_executable()/target_link_libraries()

- Installation rules :install()

- Test compilation [ To configure :catkin_add_gtest()
2)package.xml
The specific explanation here is mainly within the code , See the explanation below :
<?xml version="1.0"?>
<!‐‐ At present xml edition ‐‐>
<package format="2">
<name>learning_cplus</name>
<!‐‐ The Feature Pack name is learning_cplus,name, name ‐‐>
<version>0.0.0</version>
<!‐‐ The current feature pack version is 0.0.0,version, edition ‐‐>
<description>The learning_cplus package</description>
<!‐‐ Introduction to the current feature pack ,description, detailed ‐‐>
<maintainer email="[email protected]">waveshare</maintainer>
<!‐‐ Current maintainer information ( Mailbox and nickname )‐‐>
<!‐‐ BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 ‐ ‐>
<license>TODO</license>
<!‐‐ Protocol version , Default TODO Can . You can learn by yourself if you are interested .‐‐>
<!‐‐ <url type="website">http://wiki.ros.org/learning_cplus</url> ‐‐>
<!‐‐ Shareable path , You can upload your package to ROS Community or github.‐‐>
<author email="[email protected]">Jane Doe</author>
<!‐‐ Current developer information ( Mailbox and nickname )‐‐>
<!‐‐ The *depend tags are used to specify dependencies ‐‐>
<!‐‐ Dependencies can be catkin packages or system dependencies ‐‐>
<!‐‐ Examples: ‐‐>
<!‐‐ Use depend as a shortcut for packages that are both build and exec dependencies ‐‐>
<!‐‐ <depend>roscpp</depend> ‐‐>
<!‐‐ Note that this is equivalent to the following: ‐‐>
<!‐‐ <build_depend>roscpp</build_depend> ‐‐>
<!‐‐ <exec_depend>roscpp</exec_depend> ‐‐>
<!‐‐ Use build_depend for packages you need at compile time: ‐‐>
<!‐‐ <build_depend>message_generation</build_depend> ‐‐>
<!‐‐ Use build_export_depend for packages you need in order to build ag ainst this package: ‐‐>
<!‐‐ <build_export_depend>message_generation</build_export_depend> ‐‐>
<!‐‐ Use buildtool_depend for build tool packages: ‐‐>
<!‐‐ <buildtool_depend>catkin</buildtool_depend> ‐‐>
<!‐‐ Use exec_depend for packages you need at runtime: ‐‐>
<!‐‐ <exec_depend>message_runtime</exec_depend> ‐‐>
<!‐‐ Use test_depend for packages you need only for testing: ‐‐>
<!‐‐ <test_depend>gtest</test_depend> ‐‐>
<!‐‐ Use doc_depend for packages you need only for building documentati on: ‐‐>
<!‐‐ <doc_depend>doxygen</doc_depend> ‐‐>
<buildtool_depend>catkin</buildtool_depend>
<!‐‐ The compiler tool is catkin ‐‐>
<build_depend>roscpp</build_depend>
<!‐‐ Compile dependencies roscpp ‐‐>
<build_depend>rospy</build_depend>
<!‐‐ Compile dependencies rospy ‐‐>
<build_depend>std_msgs</build_depend>
<!‐‐ Compile dependencies std_msgs ‐‐>
<build_export_depend>roscpp</build_export_depend>
<!‐‐ Compile output dependencies roscpp ‐‐>
<build_export_depend>rospy</build_export_depend>
<!‐‐ Compile output dependencies rospy ‐‐>
<build_export_depend>std_msgs</build_export_depend>
<!‐‐ Compile output dependencies std_msgs ‐‐>
<exec_depend>roscpp</exec_depend>
<!‐‐ Operational dependency roscpp ‐‐>
<exec_depend>rospy</exec_depend>
<!‐‐ Operational dependency rospy ‐‐>
<exec_depend>std_msgs</exec_depend>
<!‐‐ Operational dependency std_msgs ‐‐>
<!‐‐ The export tag contains other, unspecified, tags ‐‐>
<export>
<!‐‐ Other tools can request additional information be placed here ‐‐>
<!‐‐ Output ‐‐>
</export>
</package>
summary
This article mainly introduces the workspace 、 The basic content of the function pack , And the process of creating and compiling them ; And in-depth analysis of CMakelist.txt And package.xml Specific content of , The blog content refers to Gu Yueju's ROS introduction 21 Talk to the light snow class ROS Basic series of tutorials , The next blog will mainly introduce how to use the turtle test to analyze the actual effect of each instruction , And simply test the use of programming code , Coming soon .

边栏推荐
- systemd 下开机启动的优化,删除无用的systemd服务
- 【ROS入门教程】---- 03 ROS基本概念及指令
- [论文阅读] FixMatch: Simplifying Semi-Supervised Learning with Consistency and Confidence
- zabbix离线安装
- Blend for visual studio overview
- Win11 uninstall widget
- oracle带xy字段值的关系表同步到pg数据库转为几何字段
- Kubernetes入门介绍与基础搭建
- table_exists_action=append和table_exists_action=truncate
- Room first use
猜你喜欢

Kubernetes入门介绍与基础搭建

Adapter mode

Complete collection of MySQL exercises (with answers) - you will know everything after practice

最好的创意鼓工具:Groove Agent 5

Pirate OJ 148 String inversion

Using solrj to add, delete, modify, and query Solr is too simple

大厂是面对深度分页问题是如何解决的(通俗易懂)

阻塞隊列 — DelayedWorkQueue源碼分析

"Past and present" of permission management

数组的字典排序
随机推荐
How to guarantee the quality of real-time data, the cornerstone of the 100 million level search system (Youku Video Search)? v2020
QT thread and interface
一些有的没的闲话
【ROS入门教程】---- 02 ROS安装
五大类型负载均衡的原理场景详解
The JVM determines whether an object can be recycled
How to solve the deep paging problem in large factories (easy to understand)
The best creative drum tool: groove agent 5
文件“Setup”不存在,怎么办?
Adapter mode
CentOS7 实战部署MySQL8(二进制方式)
Using solrj to add, delete, modify, and query Solr is too simple
Why web development with golang
Dynamic programming classical topic triangle shortest path
Room first use
What exactly does Devops mean?
增额终身寿险产品都有哪些优势?门槛高吗?
async await
Golang中的深拷贝与浅拷贝
"Past and present" of permission management