登录
/
注册
首页
论坛
其它
首页
科技
业界
安全
程序
广播
Follow
关于
每日签到
每天签到奖励2圆-6圆
发帖说明
VIP申请
登录
/
注册
账号
自动登录
找回密码
密码
登录
立即注册
搜索
搜索
关闭
CSDN热搜
程序园
精品问答
技术交流
资源下载
本版
帖子
用户
软件
问答
教程
代码
写记录
写博客
VIP申请
VIP网盘
网盘
联系我们
每日签到
道具
勋章
任务
设置
我的收藏
退出
腾讯QQ
微信登录
返回列表
首页
›
业界区
›
业界
›
【ROS教程】ROS文件系统和基础架构
【ROS教程】ROS文件系统和基础架构
[ 复制链接 ]
叭遭段
2025-6-9 09:36:26
@
目录
1.工作空间目录
1.1 package.xml
2.启动节点的方式
2.1 一次启动一个
2.2 一次启动多个
3.ROS常用命令
3.1 增
3.2 查
3.3 执行
3.3.1 加载环境变量
3.3.2 运行节点
3.4 查看计算图
4.创建功能包
4.1 选择工作目录
4.2 创建功能包目录
4.3 建立功能包
1.工作空间目录
WorkSpace --- 自定义的工作空间
|--- build:编译空间,用于存放CMake和catkin的缓存信息、配置信息和其他中间文件。
|--- devel:开发空间,用于存放编译后生成的目标文件,包括头文件、动态&静态链接库、可执行文件等。
|--- src:源码
|-- package:功能包(ROS基本单元)包含多个节点、库与配置文件,包名所有字母小写,只能由字母、数字与下划线组成
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch>|-- CMakeLists.txt:配置编译规则,比如源文件、依赖项、目标文件
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch>|-- package.xml:包信息,比如:包名、版本、作者、依赖项...(以前版本是 manifest.xml)
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch>|-- scripts:存储python文件
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch>|-- src:存储C++源文件
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch>|-- include:头文件
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch>|-- msg:消息通信格式文件
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch>|-- srv:服务通信格式文件
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch>|-- action:动作格式文件
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch>|-- launch:可一次性运行多个节点
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch>|-- config:配置信息
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch>|-- CMakeLists.txt:编译的基本配置
复制代码
1.1 package.xml
固定格式
<?xml version="1.0"?>
<package format="2">
<name><the name of package></name>
<version>0.0.0</version>
<description>The <the name of package> package</description>
<maintainer email="*">XXX</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_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>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<export>
</export>
</package>
复制代码
2.启动节点的方式
2.1 一次启动一个
rosrun <the name of package> <the name of executable file>
复制代码
executable file:对于C语言,这个文件就是CMakeLists.txt中用add_executable生成的可执行文件;对于python,这个文件就是CMakeLists.txt中用catkin_install_python指向的文件
对应语法:
add_executable(<the name of executable file>
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch> src/<the name of the source>.cpp
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch> )
catkin_install_python(PROGRAMS scripts/<the name of the source>.py
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch> DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch> )
复制代码
2.2 一次启动多个
如果想要一次性启动一个包里的多个节点,而不是一行行地输入rosrun指令...
我们需要一个launch文件,它的固定格式是这样的:
<launch>
<node pkg="helloworld" type="demo_hello" name="hello" output="screen" />
<node pkg="turtlesim" type="turtlesim_node" name="t1"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="key1" />
</launch>
复制代码
node:包含的某个节点
pkg:功能包
type:被运行的节点文件
name:为节点命名
output:设置日志的输出目标
然后,在终端输入:
roslaunch <the name of package> <the name of launch file>
复制代码
3.ROS常用命令
3.1 增
创建新的ROS功能包:
catkin_create_pkg 自定义包名 依赖包
复制代码
3.2 查
列出所有功能包:
rospack list
复制代码
查找某个功能包是否存在,如果存在返回安装路径:
rospack find 包名
复制代码
3.3 执行
3.3.1 加载环境变量
先进入工作目录,然后:
source ./devel/setup.bash
复制代码
3.3.2 运行节点
roscore:ROS的系统先决条件节点和程序的集合,必须运行 roscore 才能使 ROS 节点进行通信。
新开一个终端并输入
:
roscore #用法一
roscore -p xxxx #用法二,指定端口号
复制代码
roscore 将启动:
ros master
ros 参数服务器
rosout 日志节点
3.4 查看计算图
在节点正在运行的情况下
,终端输入:
rosrun rqt_graph rqt_graph
复制代码
4.创建功能包
4.1 选择工作目录
首先,选择一个路径作为工作目录。这里我选择了如下路径作为工作目录
4.2 创建功能包目录
mkdir src
复制代码
然后,
在工作空间目录下
:
catkin_make
复制代码
src目录下会多出一个锁定的CMakeLists.txt文件,不用管它。
4.3 建立功能包
先进入src目录
cd src
复制代码
然后使用ROS提供的指令直接创建功能包即可:
catkin_create_pkg <the name of your package> roscpp rospy std_msgs message_generatio
复制代码
roscpp、rospy、std_msgs、message_generatio是你所需要的依赖,你可以自由决定想要哪些依赖
本文由博客一文多发平台 OpenWrite 发布!
来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
ROS
教程
文件
统和
基础
相关帖子
[RPC/序列化] Proto 文件的语法解读
C语言之文件流常用标准库函数
C#零基础入门系列(八)——数组
FSO文件浏览器asp大马
salesforce零基础学习(一百四十四)External Client App浅谈
与io相关的文件和目录
Flink 与Flink可视化平台StreamPark教程(开篇)
改进基础要素,解放医疗AI生产力
推送软件文件
webshell防删文件
vip免费申请,1年只需15美金$
回复
使用道具
举报
提升卡
置顶卡
沉默卡
喧嚣卡
变色卡
千斤顶
照妖镜
相关推荐
业界
[RPC/序列化] Proto 文件的语法解读
0
515
骆贵
2025-08-29
业界
C语言之文件流常用标准库函数
0
128
辜酗徇
2025-09-04
安全
C#零基础入门系列(八)——数组
0
87
祝安芙
2025-09-05
程序
FSO文件浏览器asp大马
0
38
新程序
2025-09-05
业界
salesforce零基础学习(一百四十四)External Client App浅谈
0
760
琉艺戕
2025-09-07
安全
与io相关的文件和目录
0
735
钨哄魁
2025-09-08
安全
Flink 与Flink可视化平台StreamPark教程(开篇)
0
745
奚娅琼
2025-09-08
业界
改进基础要素,解放医疗AI生产力
0
273
事值
2025-09-09
软件
推送软件文件
0
8
新程序
2025-09-09
软件
webshell防删文件
0
4
新程序
2025-09-11
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
立即注册
回复
本版积分规则
回帖并转播
回帖后跳转到最后一页
浏览过的版块
安全
签约作者
程序园优秀签约作者
发帖
叭遭段
2025-6-9 09:36:26
关注
0
粉丝关注
13
主题发布
板块介绍填写区域,请于后台编辑
财富榜{圆}
敖可
9984
杭环
9988
凶契帽
9988
4
氛疵
9988
5
黎瑞芝
9988
6
猷咎
9986
7
里豳朝
9986
8
肿圬后
9986
9
蝓俟佐
9984
10
虽裘侪
9984
查看更多