日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > windows >内容正文

windows

ROS文件系统

發(fā)布時(shí)間:2025/4/16 windows 64 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ROS文件系统 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

文章目錄

  • 參考鏈接
  • 1.文件系統(tǒng)結(jié)構(gòu)
  • 2. 工作空間src目錄
    • 2.1 CMakeLists.txt文件
    • 2.2 功能包目錄結(jié)構(gòu)
      • 2.2.1 CMakeLists.txt文件
      • 2.2.2 package.xml文件

參考鏈接

(1) 機(jī)器人操作系統(tǒng)入門(mén)(二)ROS文件系統(tǒng):添加鏈接描述

(2) 詳解ROS文件系統(tǒng):添加鏈接描述

1.文件系統(tǒng)結(jié)構(gòu)

ROS文件系統(tǒng)指的是ROS源代碼的組織形式,其結(jié)構(gòu)大致如下圖:

默認(rèn)包含三個(gè)文件夾:

src/: ROS的catkin軟件包(C++源代碼包)
build/: catkin(CMake)的緩存信息和中間文件
devel/: 生成的目標(biāo)文件(包括頭文件,動(dòng)態(tài)鏈接庫(kù),靜態(tài)鏈接庫(kù),可執(zhí)行文件等)、環(huán)境變量

在編譯過(guò)程中,這三者關(guān)系如下

build和devel由catkin系統(tǒng)自動(dòng)生成、管理,我們?nèi)粘5拈_(kāi)發(fā)一般不會(huì)去涉及,而主要用到的是src文件夾,我們寫(xiě)的ROS程序、網(wǎng)上下載的ROS源代碼包都存放在這里。

在編譯時(shí),catkin編譯系統(tǒng)會(huì)遞歸的查找和編譯src/下的每一個(gè)源代碼包

2. 工作空間src目錄

2.1 CMakeLists.txt文件

在工作空間catkin_ws/src目錄下執(zhí)行catkin_init_workspace 初始化工作空間時(shí),生成的CMakeLists.txt為功能包編譯配置,此文件的詳細(xì)解析見(jiàn)添加鏈接描述

2.2 功能包目錄結(jié)構(gòu)

|--- src: 源碼|-- package:功能包(ROS基本單元)包含多個(gè)節(jié)點(diǎn)、庫(kù)與配置文件,包名所有字母小寫(xiě),只能由字母、數(shù)字與下劃線組成|-- CMakeLists.txt 配置編譯規(guī)則,比如源文件、依賴項(xiàng)、目標(biāo)文件|-- package.xml 包信息,比如:包名、版本、作者、依賴項(xiàng)...(以前版本是 manifest.xml)|-- scripts 存儲(chǔ)python文件|-- src 存儲(chǔ)C++源文件|-- include 頭文件|-- msg 消息通信格式文件|-- srv 服務(wù)通信格式文件|-- action 動(dòng)作格式文件|-- launch 可一次性運(yùn)行多個(gè)節(jié)點(diǎn) |-- config 配置信息|-- CMakeLists.txt: 編譯的基本配置


比如上圖的helloworld功能包,比較簡(jiǎn)單,下面以helloworld功能包來(lái)描述一個(gè)包的結(jié)構(gòu)

2.2.1 CMakeLists.txt文件

(1) CMakeLists.txt作用
CMakeLists.txt原本是Cmake編譯系統(tǒng)的規(guī)則文件,而Catkin編譯系統(tǒng)基本沿用了CMake的編譯風(fēng)格,只是針對(duì)ROS工程添加了一些宏定義。所以在寫(xiě)法上,catkin的CMakeLists.txt與CMake的基本一致。

這個(gè)文件直接規(guī)定了這個(gè)package要依賴哪些package,要編譯生成哪些目標(biāo),如何編譯等等流程。所以CMakeLists.txt非常重要,它指定了由源碼到目標(biāo)文件的規(guī)則,catkin編譯系統(tǒng)在工作時(shí)首先會(huì)找到每個(gè)package下的CMakeLists.txt,然后按照規(guī)則來(lái)編譯構(gòu)建。

(2) CMakeLists.txt語(yǔ)法

cmake_minimum_required(VERSION 3.0.2)#所需cmake版本 project(helloworld) #包名稱,會(huì)被 ${PROJECT_NAME} 的方式調(diào)用## Compile as C++11, supported in ROS Kinetic and newer # add_compile_options(-std=c++11)## Find catkin macros and libraries ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## is used, also find other catkin packages #設(shè)置構(gòu)建所需要的軟件包 find_package(catkin REQUIRED COMPONENTSroscpp# rospy #我這里如果沒(méi)有注釋掉rospy,編譯出錯(cuò),目前還不知道具體原因,因?yàn)槲矣肅++,暫時(shí)沒(méi)用python,先這么處理。std_msgs )## System dependencies are found with CMake's conventions #默認(rèn)添加系統(tǒng)依賴 # find_package(Boost REQUIRED COMPONENTS system)## Uncomment this if the package has a setup.py. This macro ensures ## modules and global scripts declared therein get installed ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html # 啟動(dòng) python 模塊支持 # catkin_python_setup()################################################ ## Declare ROS messages, services and actions ## ## 聲明 ROS 消息、服務(wù)、動(dòng)作... ## ################################################## To declare and build messages, services or actions from within this ## package, follow these steps: ## * Let MSG_DEP_SET be the set of packages whose message types you use in ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). ## * In the file package.xml: ## * add a build_depend tag for "message_generation" ## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET ## * If MSG_DEP_SET isn't empty the following dependency has been pulled in ## but can be declared for certainty nonetheless: ## * add a exec_depend tag for "message_runtime" ## * In this file (CMakeLists.txt): ## * add "message_generation" and every package in MSG_DEP_SET to ## find_package(catkin REQUIRED COMPONENTS ...) ## * add "message_runtime" and every package in MSG_DEP_SET to ## catkin_package(CATKIN_DEPENDS ...) ## * uncomment the add_*_files sections below as needed ## and list every .msg/.srv/.action file to be processed ## * uncomment the generate_messages entry below ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)## Generate messages in the 'msg' folder #生成自定義msg文件 # add_message_files( # FILES # Message1.msg # Message2.msg # )## Generate services in the 'srv' folder #生成自定義srv文件 # add_service_files( # FILES # Service1.srv # Service2.srv # )## Generate actions in the 'action' folder #生成自定義action文件 # add_action_files( # FILES # Action1.action # Action2.action # )## Generate added messages and services with any dependencies listed here # 生成消息、服務(wù)時(shí)的依賴包 # generate_messages( # DEPENDENCIES # std_msgs # )################################################ ## Declare ROS dynamic reconfigure parameters ## ## 聲明 ROS 動(dòng)態(tài)參數(shù)配置 ## ################################################## To declare and build dynamic reconfigure parameters within this ## package, follow these steps: ## * In the file package.xml: ## * add a build_depend and a exec_depend tag for "dynamic_reconfigure" ## * In this file (CMakeLists.txt): ## * add "dynamic_reconfigure" to ## find_package(catkin REQUIRED COMPONENTS ...) ## * uncomment the "generate_dynamic_reconfigure_options" section below ## and list every .cfg file to be processed## Generate dynamic reconfigure parameters in the 'cfg' folder # generate_dynamic_reconfigure_options( # cfg/DynReconf1.cfg # cfg/DynReconf2.cfg # )################################### ## catkin specific configuration ## ## catkin 特定配置## ################################### ## The catkin_package macro generates cmake config files for your package ## Declare things to be passed to dependent projects ## INCLUDE_DIRS: uncomment this if your package contains header files ## LIBRARIES: libraries you create in this project that dependent projects also need ## CATKIN_DEPENDS: catkin_packages dependent projects also need ## DEPENDS: system dependencies of this project that dependent projects also need #生成當(dāng)前package的cmake配置,供依賴本包的其他軟件包調(diào)用 catkin_package( # INCLUDE_DIRS include # LIBRARIES helloworld # CATKIN_DEPENDS roscpp rospy std_msgs # DEPENDS system_lib )########### ## Build ## ############# Specify additional locations of header files ## Your package locations should be listed before other locations # 指定頭文件路徑,當(dāng)前功能包的頭文件路徑位于其他文件路徑之前 include_directories( # include${catkin_INCLUDE_DIRS} )## Declare a C++ library # 聲明 C++ 庫(kù) # add_library(${PROJECT_NAME} # src/${PROJECT_NAME}/helloworld.cpp # )## Add cmake target dependencies of the library ## as an example, code may need to be generated before libraries ## either from message generation or dynamic reconfigure #添加庫(kù)的cmake目標(biāo)以來(lái);定義目標(biāo)文件依賴于的其他目標(biāo)文件,確保其他目標(biāo)已被構(gòu)建 # add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})## Declare a C++ executable ## With catkin_make all packages are built within a single CMake context ## The recommended prefix ensures that target names across packages don't collide # 聲明 C++ 可執(zhí)行文件,這里是hwadd_executable(hw src/helloworld.cpp)## Rename C++ executable without prefix ## The above recommended prefix causes long target names, the following renames the ## target back to the shorter version for ease of user use ## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node" #重命名c++可執(zhí)行文件 # set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")## Add cmake target dependencies of the executable ## same as for the library above #添加可執(zhí)行文件的 cmake 目標(biāo)依賴 # add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})## Specify libraries to link a library or executabletarget against#指定庫(kù)、可執(zhí)行文件的鏈接庫(kù),這里是為可執(zhí)行文件hw指定鏈接的庫(kù),${catkin_LIBRARIES} 是ROS的基本庫(kù):catkin庫(kù)。把生成的可執(zhí)行文件和catkin庫(kù)鏈接到一起。target_link_libraries(hw${catkin_LIBRARIES})############# ## Install ## ############## all install targets should use catkin DESTINATION variables # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html## Mark executable scripts (Python etc.) for installation ## in contrast to setup.py, you can choose the destination #設(shè)置用于安裝的可執(zhí)行腳本 # catkin_install_python(PROGRAMS # scripts/my_python_script # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} # )## Mark executables for installation ## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html # 安裝目標(biāo)文件到本地系統(tǒng) # install(TARGETS ${PROJECT_NAME}_node # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} # )## Mark libraries for installation ## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html # install(TARGETS ${PROJECT_NAME} # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} # RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} # )## Mark cpp header files for installation # install(DIRECTORY include/${PROJECT_NAME}/ # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} # FILES_MATCHING PATTERN "*.h" # PATTERN ".svn" EXCLUDE # )## Mark other files for installation (e.g. launch and bag files, etc.) # install(FILES # # myfile1 # # myfile2 # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} # )############# ## Testing ## ############### Add gtest based cpp test target and link libraries # catkin_add_gtest(${PROJECT_NAME}-test test/test_helloworld.cpp) # if(TARGET ${PROJECT_NAME}-test) # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) # endif()## Add folders to be run by python nosetests # catkin_add_nosetests(test)

2.2.2 package.xml文件

package.xml也是一個(gè)catkin的package必備文件,它是這個(gè)軟件包的描述文件
(1) package.xml作用
pacakge.xml包含了package的名稱、版本號(hào)、內(nèi)容描述、維護(hù)人員、軟件許可、編譯構(gòu)建工具、編譯依賴、運(yùn)行依賴等信息。 實(shí)際上rospack find、rosdep等命令之所以能快速定位和分析出package的依賴項(xiàng)信息,就是直接讀取了每一個(gè)pacakge中的package.xml文件。它為用戶提供了快速了解一個(gè)pacakge的渠道。

(2) package.xml語(yǔ)法
pacakge.xml遵循xml標(biāo)簽文本的寫(xiě)法,由于版本更迭原因,現(xiàn)在有兩種格式并存(format1與format2),不過(guò)區(qū)別不大,我們現(xiàn)在用的是format2格式的。

<?xml version="1.0"?> <!-- 格式: 以前是 1,推薦使用格式 2 --> <package format="2"> <!-- 包名 --><name>helloworld</name><!-- 版本號(hào) --><version>0.0.0</version><!-- 功能包的描述信息 --><description>The helloworld package</description><!-- One maintainer tag required, multiple allowed, one person per tag --><!-- Example: --><!-- 維護(hù)人員信息,可以多個(gè),每個(gè)人一個(gè)tag --><!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> --><maintainer email="kandi@todo.todo">kandi</maintainer><!-- One license tag required, multiple allowed, one license per tag --><!-- Commonly used license strings: --><!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 --><!-- 許可證信息,ROS核心組件默認(rèn) BSD --><license>TODO</license><!-- Url tags are optional, but multiple are allowed, one per tag --><!-- Optional attribute type can be: website, bugtracker, or repository --><!-- Example: --><!-- <url type="website">http://wiki.ros.org/helloworld</url> --><!-- Author tags are optional, multiple are allowed, one per tag --><!-- Authors do not have to be maintainers, but could be --><!-- Example: --><!-- <author email="jane.doe@example.com">Jane Doe</author> --><!-- 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 against 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: --><!-- 測(cè)試用例依賴項(xiàng) --><!-- <test_depend>gtest</test_depend> --><!-- Use doc_depend for packages you need only for building documentation: --><!-- 文檔依賴項(xiàng) --><!-- <doc_depend>doxygen</doc_depend> --><!-- 依賴的編譯構(gòu)建工具,這是必須的,通常為catkin --><buildtool_depend>catkin</buildtool_depend><!-- 編譯的依賴項(xiàng),如roscpp功能包 --><build_depend>roscpp</build_depend><build_depend>rospy</build_depend><build_depend>std_msgs</build_depend><!-- 導(dǎo)出的依賴項(xiàng) --><build_export_depend>roscpp</build_export_depend><build_export_depend>rospy</build_export_depend><build_export_depend>std_msgs</build_export_depend><!-- 運(yùn)行時(shí)的依賴項(xiàng) --><exec_depend>roscpp</exec_depend><exec_depend>rospy</exec_depend><exec_depend>std_msgs</exec_depend><!-- The export tag contains other, unspecified, tags --><export><!-- Other tools can request additional information be placed here --></export> </package> 《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專(zhuān)家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的ROS文件系统的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。