当前位置:网站首页>[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 .

边栏推荐
- How to install mathtype6.9 and related problem solutions in office2016 (word2016)
- 嵌入式学习资料和项目汇总
- How to ensure the sequence of messages, that messages are not lost or consumed repeatedly
- Introduction and basic construction of kubernetes
- ion_mmap
- oracle带xy字段值的关系表同步到pg数据库转为几何字段
- SQL audit | "cloud" users can use the SQL audit service with one click
- Kubernetes入门介绍与基础搭建
- About the log traffic monitoring and early warning small project | standardized return of interaction with the database in flask
- Wechat applet to realize OCR scanning recognition
猜你喜欢

Dynamic programming classical topic triangle shortest path

Detailed explanation of five types of load balancing principle scenarios

lucene思维导图,让搜索引擎不再难懂

What exactly does Devops mean?

Small project on log traffic monitoring and early warning | environment and foundation 1

Kubeflow 1.2.0 installation

亿级搜索系统(优酷视频搜索)的基石,如何保障实时数据质量?v2020

Loop structure statement

SLAM卡尔曼滤波&&非线性优化

浅谈有赞搜索质量保障体系 v2021
随机推荐
Download Google gcr IO image
Google搜索为什么不能无限分页?
Introduction and basic construction of kubernetes
年金险还能买吗?年金险安不安全?
LeetCode 8. String to integer (ATOI) (medium, string)
海贼oj#146.字符串
Josephus problem_ Unidirectional circular linked list_ code implementation
Dynamic programming classical topic triangle shortest path
What exactly does Devops mean?
Solid basic knowledge + correct method is the key to quickly read the source code
logback日志框架
扎实的基础知识+正确的方法是快速阅读源码的关键
About the log traffic monitoring and early warning small project | standardized return of interaction with the database in flask
MySQL
Pirate OJ 448 luck draw
MySQL trigger
集线器、交换机与路由器有什么区别?
一些有的没的闲话
Using solrj to add, delete, modify, and query Solr is too simple
Animation