当前位置:网站首页>ROS series (III): introduction to ROS architecture
ROS series (III): introduction to ROS architecture
2022-04-23 03:37:00 【Yi Lanjun】
0 ROS framework
Just ROS In terms of its own implementation , Its architecture is divided into three layers :
- file system
ROS File system level refers to the view on the hard disk ROS The organization of source code . - Calculation chart
ROS Different processes in distributed system need data interaction , The computing graph can represent the data interaction process in the form of point-to-point network , Important concepts in calculation diagram : node (Node)、 news (message)、 Communication mechanism _ The theme (topic)、 Communication mechanism _ service (service). - The open source community
ROS There are many open source communities , Include ROS WIKI、ROS Answer etc. .
1 ROS file system
ROS File system level refers to on the hard disk ROS The organization of source code , Its structure can be roughly as shown in the figure below :
The specific meaning of the representative is as follows :
WorkSpace --- Custom workspace
|--- build: Compilation space , To hold CMake and catkin Cache information for 、 Configuration information and other intermediate files .
|--- devel: Development space , Used to store the target file generated after compilation , Including header files 、 dynamic & Static link library 、 Executable documents, etc .
|--- src: Source code
|-- package: Function pack (ROS Basic unit ) Contain multiple nodes 、 Libraries and profiles , All the letters of the package name are lowercase , Only letters 、 Numbers and underscores make up
|-- CMakeLists.txt Configure Compilation Rules , Such as source files 、 Dependencies 、 Target file
|-- package.xml Package information , such as : Package name 、 edition 、 author 、 Dependencies ...( The previous version was manifest.xml)
|-- scripts Storage python file
|-- src Storage C++ Source file
|-- include The header file
|-- msg Message communication format file
|-- srv Service communication format file
|-- action Action format file
|-- launch Multiple nodes can be run at one time
|-- config Configuration information
|-- CMakeLists.txt: Basic configuration of compilation
Next, we mainly introduce package.xml And CMakeLists.txt These two profiles .
1.1 package.xml
This file defines the properties of the package , For example, package name , Version number , author , Maintainers and others catkin Package dependencies .
<?xml version="1.0"?>
<!-- Format : It used to be 1, Recommended format 2 -->
<package format="2">
<!-- Package name -->
<name>demo01_hello_vscode</name>
<!-- edition -->
<version>0.0.0</version>
<!-- Description information -->
<description>The demo01_hello_vscode package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="[email protected]">Jane Doe</maintainer> -->
<!-- maintenance staff -->
<maintainer email="[email protected]">xuzuo</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 -->
<!-- License information ,ROS The core component defaults to 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/demo01_hello_vscode</url> -->
<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Authors do not have to be maintainers, but could be -->
<!-- Example: -->
<!-- <author email="[email protected]">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: -->
<!-- <test_depend>gtest</test_depend> -->
<!-- Use doc_depend for packages you need only for building documentation: -->
<!-- <doc_depend>doxygen</doc_depend> -->
<!-- Dependent build tools , It's a must -->
<buildtool_depend>catkin</buildtool_depend>
<!-- Specify the packages required to build this package -->
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<!-- Specify the package required to build the library based on this package -->
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<!-- The package needed to run the code in this package -->
<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>
1.2 CMakelists.txt
file CMakeLists.txt yes CMake Input for building the system , Used to build software packages .
cmake_minimum_required(VERSION 3.0.2) # what is needed cmake edition
project(demo01_hello_vscode) # Package name , Will be ${
PROJECT_NAME} Method call
## 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
# Set up the software package needed for the build
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)
## System dependencies are found with CMake's conventions
# Add system dependency by default
# 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
# start-up python Module support
# catkin_python_setup()
################################################
## Declare ROS messages, services and actions ##
## Statement ROS news 、 service 、 action ... ##
################################################
## 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
# add_message_files(
# FILES
# Message1.msg
# Message2.msg
# )
## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )
## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )
## Generate added messages and services with any dependencies listed here
# Generate messages 、 Service dependent packages
# generate_messages(
# DEPENDENCIES
# std_msgs
# )
################################################
## Declare ROS dynamic reconfigure parameters ##
## Statement ROS Dynamic parameter configuration ##
################################################
## 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 Specific configuration ##
###################################
## 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
# Runtime dependency
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES demo01_hello_vscode
# 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
# Add the header file path , The header file path of the current package precedes other file paths
include_directories(
# include
${
catkin_INCLUDE_DIRS}
)
## Declare a C++ library
# Statement C++ library
# add_library(${
PROJECT_NAME}
# src/${
PROJECT_NAME}/demo01_hello_vscode.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
# To add a library cmake Target dependence
# 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
# Statement C++ Executable file
add_executable(Hello_VSCode src/Hello_VSCode.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"
# rename c++ Executable file
# set_target_properties(${
PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
## Add cmake target dependencies of the executable
## same as for the library above
# Add executable file cmake Target dependence
add_dependencies(Hello_VSCode ${
${
PROJECT_NAME}_EXPORTED_TARGETS} ${
catkin_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against
# Specify the library 、 Link library of executable files
target_link_libraries(Hello_VSCode
${
catkin_LIBRARIES}
)
#############
## Install ##
## 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
# Set the executable script for installation
catkin_install_python(PROGRAMS
scripts/Hi.py
DESTINATION ${
CATKIN_PACKAGE_BIN_DESTINATION}
)
## Mark executables for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
# 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_demo01_hello_vscode.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 ROS File system related commands
ROS File systems are essentially operating system files , We can use Linux Command to manipulate these files , however , stay ROS For better user experience ,ROS Specifically provides something similar to Linux The order of , These commands are compared to Linux Native command , More introduction 、 Efficient . File operations , It's nothing more than adding, deleting, modifying, checking and executing , Next , Let's start from these five dimensions , To introduce ROS Some common commands of file system .
2.1 increase
catkin_create_pkg Custom package name Dependency package === Create a new ROS Function pack
sudo apt install xxx === install ROS Function pack
2.2 Delete
sudo apt purge xxx ==== Delete a feature pack
2.3 check
rospack list === List all feature packs
rospack find Package name === Find out if a feature package exists , If present, return to the installation path
roscd Package name === Enter a function package
rosls Package name === List the files under a package
apt search xxx === Search for a feature pack
2.4 Change
rosed Package name file name === Modify the function pack file
2.5 perform
roscore
Use roscore Will start :
ros master
ros Parameter server
rosout Log nodes
rosrun
rosrun Package name Executable file name === Run the specified ROS node
eg:rosrun turtlesim turtlesim_node
roslaunch
roslaunch Package name launch file name === Execute... Under a package launch file
3 ROS Calculation chart
3.1 Introduction to the calculation chart
Previously introduced ROS File structure , It's on disk ROS The storage structure of the program , Is static , and ros After the program runs , Different nodes are intricate ,ROS Provides a practical tool rqt_graph A dynamic graph used to display the current system operation .
ROS Different processes in distributed system need data interaction , The computing graph can represent the data interaction process in the form of point-to-point network .rqt_graph yes rqt Part of the package .
3.2 Calculation diagram demonstration
Start three terminals first , Enter the following commands respectively :
terminal 1 type :roscore
terminal 2 type :rosrun turtlesim turtlesim_node( The graphical interface will pop up )
terminal 3 type :rosrun turtlesim turtle_teleop_key( stay 3 Can be controlled by keyboard 2 The movement of the tortoise in )
Start another terminal , Input
rqt_graph
You can see the network topology diagram similar to the following figure , The diagram can show the relationship between different nodes .
版权声明
本文为[Yi Lanjun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220602231900.html
边栏推荐
- 2022 团体程序设计天梯赛 模拟赛 L2-4 哲哲打游戏 (25 分)
- Abstract classes, interfaces and common keywords
- vscode删除卸载残余
- Using swagger in. Net5
- Batch download of files ---- compressed and then downloaded
- Cmake qmake simple knowledge
- Leetcode 617 merge binary tree
- Variables, constants, operators
- The art of concurrent programming (3): an in-depth understanding of the principle of synchronized
- Redis (17) -- redis cache related problem solving
猜你喜欢
PyMOL usage
Wechat applet cloud database value assignment to array error
L3-011 direct attack Huanglong (30 points)
Create virtual machine
Visual programming - Experiment 1
Seekbar custom style details
Unity knowledge points (common core classes)
Download and configuration of idea
"Visual programming" test paper
Instructions for fastmock
随机推荐
JS, bind the event for a label with input, and then bind the stand-alone event in the parent element. The event is executed twice and solved
Download and configuration of idea
What to pay attention to when writing the first code
Use of rotary selector wheelpicker
Key point detection of human hand based on mediapipe
Three types of jump statements
When migrating tslib_ setup: No such file or directory、ts_ open: No such file or director
Opencv4 QR code recognition test
Unity knowledge points (ugui 2)
第四次作业
Chapter VI, Section III pointer
Now is the best time to empower industrial visual inspection with AI
深度學習筆記(二)——激活函數原理與實現
. net webapi access authorization mechanism and process design (header token + redis)
Supersocket is Use in net5 - startup
Unity Basics
Paddlepaddle does not support arm64 architecture.
打卡:4.23 C语言篇 -(1)初识C语言 - (12)结构体
PyMOL usage
[microservices] (x) -- Unified gateway