ROS中launch文件和参数设置
launch文件标签说明
turtle.launch
node标签
<launch>
<!--ns表示在指定命名空间运行节点(可以理解为改rostopic list中的节点名称),交互的节点间要在同一ns下,下面这俩必须在同ns下--><!-- pkg包名 type节点名 name自定义名 output输出方式 respawn起死回生 respawn_delay起死回生所需要的时间,默认0 --><node pkg="turtlesim" type="turtlesim_node" name="turtletest" output="screen" respawn="true" respawn_delay="3" ns="turtle"/><!--required是必需的,死后全死--><node pkg="turtlesim" type="turtle_teleop_key" name="mycontrol" required="true" output="screen" ns="turtle"/>
</launch>
turtlekeyboard.launch
node&remap¶m&arg&group&rosparam
<launch>
<!--rosrun teleop_twist_keyboard teleop_twist_keyboard.py启动时topic是/cmd_vel
想要转化话题名称就在后面添加参数 /cmd_vel:=/turtle1/cmd_vel 就将topic从/cmd_vel转化成了/turtle1/cmd_vel--><rosparam command="load" file="$(find launchpackage)/launch/rosparamtest.yaml"/><!--remap标签teleop_twist_keyboard teleop_twist_keyboard.py节点话题为cmd_vel,
所以为了让两种方式都能控制turtletest,就将下面的两个节点话题都变成cmd_vel-->
<!--ns参数限制node节点名称和话题两个地方
就是在ns=turtle name=turtletest 下的param为:/turtle/turtletest/background_r
下的topic 位置是/turtle/turtle1/pose 移动话题是:/turtle/turtle1/cmd_vel <=> /cmd_vel remap转换了--><node pkg="turtlesim" type="turtlesim_node" name="turtletest_1" output="screen" respawn="true" respawn_delay="3" ns="turtle"><remap from="/turtle/turtle1/cmd_vel" to="/cmd_vel"/><param name="canshu" type="int" value="10"/><!--rosparam list 存在 /turtletest/canshu--></node><node pkg="turtlesim" type="turtle_teleop_key" name="mycontrol" required="true" output="screen" ns="turtle"><remap from="/turtle/turtle1/cmd_vel" to="/cmd_vel"/></node><node pkg="turtlesim" type="turtlesim_node" name="turtletest_2" output="screen" respawn="true" respawn_delay="3" ns="turtle"><remap from="/turtle/turtle1/cmd_vel" to="/cmd_vel"/></node><!--执行顺序可能在设置rosparam前运行了,所以不行,一般令写launch文件(rosparamtest.launch)--><!--<rosparam command="dump" file="$(find launchpackage)/launch/rosparamtestoutput.yaml"/> --><group ns="grouptest"><!--该标签下的所有话题和参数均在grouptest下--><node pkg="turtlesim" type="turtlesim_node" name="groupturtle" /></group><!--范型参数--><arg name="argcanshu" default="0.2"/><param name="thisarg" value="$(arg argcanshu)"/>
</launch>
rosparmtest.launch
rosparam->load
<!--提前运行turtlekeyboard.launch-->
<launch><!--保存和删除 rosparam标签只有三个参数 保存:dump 删除:delete 加载:load 添加是使用param标签 详见turtlekeyboard.launch文件--><rosparam command="dump" file="$(find launchpackage)/launch/rosparamtestoutput.yaml"/><rosparam command="delete" param="/turtle/turtletest/background_r"/>
</launch>
turtlecopyfile.launch
include
<launch><!--file="$(find 包名)/launch/launch文件名"--><include file="$(find launchpackage)/launch/turtle.launch" />
</launch>
终端启动时设置参数
run运行时可以用动态参数
roslaunch launchpackage turtlekeyboard.launch argcanshu:=0.3
若仅仅使用rosrun启动节点设置参数,后需要添加 _arg:=4 表示在当前node节点下设置私有参数arg=4,注意有下划线,和启动launch文件有区别
rosrun turtlesim turtlesim_node _arg:=4
话题权限
rosrun设置
rosrun turtlesim turtlesim_node _arg:=100
arg参数是私有权限
launch文件设置参数
通过 launch 文件设置参数的方式,可以在 node 标签外,或 node 标签中通过 param 或 rosparam 来设置参数。在 node 标签外设置的参数是全局性质的,参考的是 / ,在 node 标签中设置的参数是私有性质的,参考的是 /命名空间/节点名称(ns/name)。
C++程序设置
#include "ros/ros.h"
int main(int argc, char *argv[])
{ros::param::set("/set_A", 100); //全局,和命名空间以及节点名称无关ros::param::set("set_B", 100); //相对,参考命名空间ros::param::set("~set_C", 100); //私有,参考命名空间与节点名称ros::NodeHandle nh;nh.setParam("/nh_A", 100); //全局,和命名空间以及节点名称无关nh.setParam("nh_B", 100); //相对,参考命名空间ros::NodeHandle nh_private("~");nh_private.setParam("nh_C", 100); //私有,参考命名空间与节点名称/*运行时,假设设置的 namespace 为 xxx,节点名称为 yyy,使用 rosparam list 查看:/set_A/xxx/set_B/xxx/yyy/set_C/nh_A/xxx/nh_B/xxx/yyy/nh_C*/return 0;
}
ROS中launch文件和参数设置相关推荐
- ROS中launch文件的编写
ROS中launch文件的编写 launch文件介绍 ROS系统里的组成单位是节点(node),在启动ROS时需要启动所有的node,如果手动一一启动会是一项十分繁琐的事情,因此ROS通过launch ...
- ROS中launch文件使用笔记
1. 常用标签 <launch> <!--根标签--> <node> <!--需要启动的node及其参数--> <include> < ...
- ros中launch文件使用与虚拟机中使用Livox avia
在home目录创建工作空间,并创建src,将要安装的代码解压放在src中,编译ros项目 ROS入门(四)编译ROS程序包_小鱼儿飞呀飞的博客-CSDN博客_ros包编译 使用launch前要 `so ...
- ROS中yaml文件编写格式
目录 键值对 键值对书写格式 键值对的引用 强制类型转换 字符串 时间与日期 已知偏移时区和当地时间 已知UTC世界时间 数组 普通数组 键值对数组 数组的引用 多维数组 命名空间 命名空间下普通变量 ...
- linux开机启动roscore,树莓派ubuntuMate系统中开机自启动ROS的launch文件
0x00 为何需要开机自启动launch文件 在ROS开发后期阶段由于功能已经趋于稳定,因此就需要系统在一上电启动后就自动把ROS下的各节点程序加载运行,这样就省去了我们还得手动输入roslaunch ...
- darknet 框架中.cfg文件的参数详解,以yolov3为例
参考:darknet中cfg文件里参数的理解_zerojava0的博客-CSDN博客 参考:[Darknet源码 ]cfg文件参数详解_橘子都吃不起!的博客-CSDN博客 1.基础参数解释 batch ...
- 9.使用rosed在ROS中编辑文件
使用rosed在ROS中编辑文件(rawmeat:http://wiki.ros.org/ROS/Tutorials/UsingRosEd) 注意:本教程翻译于2018.9.17,由wiki.ros. ...
- 【RK3399Pro学习笔记】十五、ROS中launch启动文件的使用方法
目录 Launch文件语法 <launch><launch><launch> <node><node><node> 参数设置 & ...
- ROS系统中launch文件无法启动
方法一:LAUNCH文件无法启动,权限问题,开权限. 方法二: source devel/setup.bash
- Ros学习——launch文件解析
launch文件的重点是:节点(node)元素的集合. roslaunch 则是让所有的节点共享同一个终端. 1.标签(元素)说明 1. group标签 2. node标签 <group ns= ...
最新文章
- python 图像分析自然纹理方向与粗细代码_python skimage图像处理(二)
- python基础:购物车的简单实现
- ORA-24324 ORA-24323 ORA-01090
- 高能街访 | 为什么他们都纷纷为深圳打Call?
- python中transform用法_Python Wand transform()用法及代码示例
- aws python sns_使用AWS Lambd从AWS SNS读取时修改JSON消息
- 并发执行linux命令结果混乱,Shell脚本--并发执行
- [转载] [转载] numpy功能快速查找
- SqlServer批量更新两关联表的数据
- h文件中报错 unterminated conditional directive的原因
- paip.提升效率---源码生成流程图工具
- 态势感知——活跃IP段探测脚本集合【多语言】
- 怎么做PPT 课件代做 驼峰设计
- 扒一扒“WEBP格式”的图片
- 【寻找最佳小程序】02期:腾讯旅游首款小工具“旅行小账本”——创意及研发过程大起底...
- 红蜻蜓抓图软件测试简历,红蜻蜓抓图精灵
- 在ubuntu11.10上安装6款顶级漂亮的BURG主题
- Linux系统概念复习
- 现在Python就业很难吗?百万程序员都在关心的问题
- gan 总结 数据增强_深度学习中的数据增强(下)
热门文章
- 基于Multisim的波形发生器
- 3种竞争力分析的简单途径
- C语言报错:「error」Id returned 1 exit status
- configure: error: --with-openssl was given but OpenSSL could not be detected 解决方法(Curl交叉编译到Arm板)
- html侧边导航栏,浮动侧边导航栏的基本布局
- html水平导航栏代码连接状态,水平导航栏1.html
- cqyz oj | 【训练题】铲雪车问题
- 阿里云推出云呼叫中心,助力企业强势打造端到端的一站式热线服务
- 2019JAVA面试题附答案-精心整理-很全面面试大大节省时间
- 智能门锁电路图_智能门锁原理一览 你pick哪一种?