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

边栏推荐
- Blend for visual studio overview
- Download Google gcr IO image
- CentOS7 实战部署MySQL8(二进制方式)
- Complete uninstallation of MySQL under Linux
- With a market value of 21.5 billion yuan, will the post-80s generation in Sichuan make TV history?
- 项目连接不到远程虚拟机The driver has not received any packets from the server.
- logback日志框架
- 团队管理|如何提高技术Leader的思考技巧?
- Alicloud configures SLB (load balancing) instances
- Qt线程与界面
猜你喜欢

Philips coo will be assigned to solve the dual crisis of "supply chain and product recall" in the face of crisis due to personnel change

What is the difference between hubs, switches and routers?

海贼oj#148.字符串反转

DevOps到底是什么意思?

On the quality assurance system of youzan search V2021

Synchronized keyword for concurrent programming

How to ensure the sequence of messages, that messages are not lost or consumed repeatedly

AQS explanation of concurrent programming

87.(leaflet之家)leaflet军事标绘-直线箭头修改

负载均衡策略图文详解
随机推荐
Block queue - delayedworkqueue Source Analysis
How word inserts a guide (dot before page number) into a table of contents
systemd 下开机启动的优化,删除无用的systemd服务
手把手教你前后分离架构(五) 系统身份验证实现
SQL audit | "cloud" users can use the SQL audit service with one click
SqlServer中的锁
招聘 | 南京 | TRIOSTUDIO 三厘社 – 室内设计师 / 施工图深化设计师 / 装置/产品设计师 / 实习生等
SQL审核 | “云上”用户可以一键使用 SQLE 审核服务啦
pytorch分类问题总结
Small project on log traffic monitoring and early warning | environment and foundation 1
compiler explorer
ts+fetch实现选择文件上传
Baidu PaddlePaddle paddlepaddle latest series AI course playback address
记录oracle的几个参数 db_files,Cursor_sharing ,open_cursor
RPC details
最好的创意鼓工具:Groove Agent 5
MESI cache consistency protocol for concurrent programming
How word removes the header line
Dynamic programming classical topic triangle shortest path
Philips coo will be assigned to solve the dual crisis of "supply chain and product recall" in the face of crisis due to personnel change