ros学习笔记
ROS文件系统
1.文件系统工具
1.1 rospack
rospack允许获取软件包相关信息
a.find 可以找到文件位置
b.depends1可以寻找依赖(一级依赖)depend为全部依赖
1.2 roscd
roscd 允许直接切换目录到某个软件包或软件包集合
注意智能切换已经包含在ROS_PACKAGE_PATH里的
roscd log 可以切换到ros日志
2.软件包
2.1 软件包的构成
1.符合catkin规范的package.xml文件
2.catkin版本的CMakeLists.txt
2.2创建软件包
catkin_create_pkg <package_name> [depend1] [depend2] [depend3]
含义:构建软件包并天剑依赖
cd ~/catkin_ws
catkin_make
source ./devel/setup.bash
通过catkin_make构建软件包并source一下配置文件
2.3 自定义 package.xml
2.3.1 描述标签
2.3.2 维护者标签
<maintainer email="you@yourdomain.tld">Your Name</maintainer>
2.3.3 依赖项标签
<!-- 依赖的构建工具,这是必须的 -->
<buildtool_depend>catkin</buildtool_depend>
<!-- 指定构建此软件包所需的软件包 -->
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>geometry_msgs</build_depend>
<!-- 指定根据这个包构建库所需要的包 -->
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<build_export_depend>geometry_msgs</build_export_depend>
<!-- 运行该程序包中的代码所需的程序包 -->
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>message_runtime</exec_depend>
2.4 解释CMakeLists.txt
# 设置构建所需要的软件包
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
geometry_msgs
message_generation
)
## System dependencies are found with CMake's conventions
# 默认添加系统依赖
# find_package(Boost REQUIRED COMPONENTS system)
## Uncomment this if the package has a setup.py. This macro ensures
################################################
## Declare ROS messages, services and actions ##
## 声明 ROS 消息、服务、动作 ##
################################################
# Generate messages in the 'msg' folder
# 在“msg”文件夹中生成消息
add_message_files(
FILES
Topic.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
# 生成消息、服务时的依赖包
generate_messages(
DEPENDENCIES
geometry_msgs
std_msgs
)
################################################
## Declare ROS dynamic reconfigure parameters ##
## 声明 ROS 动态参数配置 ##
################################################
## Generate dynamic reconfigure parameters in the 'cfg' folder
## 在“cfg”文件夹中生成动态重新配置参数
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )
###################################
## catkin specific configuration ##
## catkin 特定配置 ##
###################################
# 运行时依赖
catkin_package(
INCLUDE_DIRS include
LIBRARIES hello_vscode
CATKIN_DEPENDS roscpp rospy std_msgs geometry_msgs
DEPENDS system_lib
message_runtime
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
# 添加头文件路径,当前程序包的头文件路径位于其他文件路径之前
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
3.ros节点
3.1 客户端库:rospy,roscpp(可以让不同编程语言的节点相互通信)
3.2 rosrun 直接运行软件包内的节点
rosrun [package_name] [node_name]
额外补充:命令行重新分配名称(以turtlesim为例)
$ rosrun turtlesim turtlesim_node __name:=my_turtle
3.3 rqt_graph (用来查看ros话题动态图)
rosrun rqt_graph rqt_graph
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)