当前位置:网站首页>ROS learning 1- create workspaces and function packs
ROS learning 1- create workspaces and function packs
2022-07-05 08:45:00 【m0_ forty-six million ninety-three thousand eight hundred and t】
One 、 Workspace concept
stay ros Workspaces in are collectively referred to as workspace, It is used to store the relevant documents you need for a project development , stay ros It is a folder with empty seat space .
This folder usually contains 4 Subfolders ;
src: Used to store function packs
build( Compilation space ): It is used to store binary files generated during compilation
devel( Development space ): The executable generated after compilation , Everything generated by the final compilation will eventually run here
install( Installation space ): use install The results of successful installation of instructions are placed here
Two 、 The process and instructions for creating a workspace are as follows :
2.1 Create workspace process
1、 Create a workspace
Create a folder , Then create a... In the folder src A folder ( Here you need to pay attention to the name of the workspace. You can go anywhere , But in the workspace src The name cannot be changed , Because the above introduction says src It is used to store function packs , In the future ros I will use it at work src This path goes to your Feature Pack )
Give the folder you just created the nature of the workspace , stay src Input command in :catkin_init_workspace
2、 Compile workspace
Compiled to make ros I know there is such a workspace , You can find it in the future :catkin_make( But here we need to pay attention to compiling under the main directory of the workspace )
The compiled results will be placed in build and devel Under the folder , So you will see that these two folders will be automatically generated after you compile
Finally, let me explain , because install Folders are not commonly used in our development process , and ros2 hold install and delve The contents of the document have been merged , So don't care about it . But if you want this folder, you can create it yourself : In the workspace main directory :catkin_make install that will do
The overall code is as follows
Create a workspace
midir -p ~/catkoin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
Compile workspace
cd ~/catkin_ws/
catkin_make
3、 ... and 、 Create Feature Pack
ROS Of Catkin A feature of the compiling system is to make the program package ( be called catkin package perhaps ROS package) In the form of , It can be understood as modularization .
The process of creating a function package is as follows ;
1、 Create Feature Pack :
catkin_create_pkg < Function report name > Dependencies 1 Dependence 2...( When creating a function package, you should create it in the workspace src Create under directory )
2、 Compile function packs : take c++ And other high-level languages to compile the code into a language that the machine can see and understand
catkin_make( To compile in the workspace home directory )
3、 Configure workspace environment variables : What is environment variable ? Easy to understand explanation 「 What exactly is an environment variable ?」| Code | Chihokyo BLOG | Wangcai's blog What this website says is quite clear ( After reading it, my understanding is : When the system runs a program or instruction , Sometimes you need to use its path , And when you don't tell the specific path , Then it will be in PATH Looking for , So some software needs your command path .)
source ~/catkin_cs/devel/setup.bash
notes : After compilation, you must use source Command to refresh the workspace environment , When you first learn, you may think , Do it once in the workspace source Then it will be done once and for all, and it will not be used in the future source 了 , This view is wrong . The fact is that , Every time catkin_make after , To carry out source, But if you are afraid of forgetting , You can also set up a method for this workspace once and for all :
stay home Next , Hidden files found .bashrc(ctrl+h Can show hidden files ), Then add in the last line that you should always source Instructions , for example source /home/ Your username /catkin_ws/devel/setup.bash, Keep it .bashrc file , Then restart the terminal , Let the settings just take effect .
for example :
cd ~/catkin_ws/src
catkin_create_pkg test_pkg std_msgs rospy roscpp
cd ~/catkin_ws
catkin_make
source ~/catkin_ws/devel/setup.bash
among :std_msgs yes ros About message dependency ,rospy python Dependence ,cpp yes c++ Dependence
边栏推荐
猜你喜欢
随机推荐
Bluebridge cup internet of things competition basic graphic tutorial - clock selection
Yolov4 target detection backbone
The first week of summer vacation
Basic number theory -- Euler function
Is the security account given by Yixue school safe? Where can I open an account
每日一题——替换空格
Pytorch entry record
Chapter 18 using work queue manager (1)
Shift operation of complement
Business modeling of software model | vision
每日一题——输入一个日期,输出它是该年的第几天
MATLAB小技巧(28)模糊綜合評價
JS asynchronous error handling
Run菜单解析
猜谜语啦(2)
Dynamic dimensions required for input: input, but no shapes were provided. Automatically overriding
猜谜语啦(11)
Array,Date,String 对象方法
Guess riddles (6)
Redis实现高性能的全文搜索引擎---RediSearch