当前位置:网站首页>19、 ROS parameter name setting
19、 ROS parameter name setting
2022-07-28 14:53:00 【Rock magnon】
List of articles
1. brief introduction
stay ROS in , Parameter names may have duplicate names , He's not like the topic with the same name , It can be solved by remapping . however , You can add different prefixes , To distinguish between different parameters
- classification :
- overall situation : Level with namespace
- relative : Level with node name
- private : Children of the node name
- Implementation method :
- rosrun command
- launch file
- coded
2. Implementation method
2.1 rosrun Set parameters : Parameter names use private mode
- Format :rosrun Package name The node name _ Parameter name := Parameter values
- Code implementation :
rosrun turtlesim turtlesim_node _A:=100 - Running results :
rosparam list /turtlesim/A
2.2 launch File settings parameters
- type :
- stay node Out of label : Global parameter
- stay node tag : Private parameters
- Code implementation :
<!-- Set parameters --> <launch> <!-- Format 1: overall situation --> <param name="radius" value="10" /> <!-- Format 2: Local --> <node pkg="turtlesim" type="turtlesim_node" name="t1" ns="xxx"> <param name="radius" value="20" /> </node> </launch> - Running results :
bash1: start-up launch file roslaunch launch_test_01 param_rename.launch bash2: Check the parameter list rosparam list /radius /xxx/t1/radius
2.3 Code setting parameters
2.3.1 C++ Realization
- Code implementation :
#include"ros/ros.h" int main(int argc,char *argv[]){ ros::init(argc,argv,"topic_name"); ros::NodeHandle nh; /* Use ros::param To set parameters */ // 1. overall situation ros::param::set("/radiusA",100); // 2. relative ros::param::set("radiusB",100); // 3. private ros::param::set("~radiusC",100); /* Use NodeHandle Set parameters */ // 1. overall situation nh.setParam("/A",100); // 2. relative nh.setParam("B",100); // 3. private ros::NodeHandle nh1("~"); nh1.setParam("C",100); return 0; } - Running results :
bash1: Operation node , And add the namespace rosrun rename_01 topic_name __ns:=xxx bash2: Check the parameter list rosparam list /A /radiusA /xxx/B /xxx/radiusB /xxx/topic_name/C /xxx/topic_name/radiusC
2.3.2 Python Realization
- Code implementation :
#! /usr/bin/env python from ast import Str import rospy from std_msgs.msg import String if __name__ == "__main__": rospy.init_node("topic_name_p") # 1. overall situation rospy.set_param("/p1",100) # 2. relative rospy.set_param("py2",100) # 3. private rospy.set_param("~py3",100) - Running results :
bash1: Start node , And add the namespace rosrun rename_01 topic_name_p.py __ns:=xxx bash2: Check the parameter list rosparam list /p1 /xxx/py2 /xxx/topic_name_p/py3
边栏推荐
- 八、picker用法 下拉框选择效果
- Multi merchant mall system function disassembly lecture 17 - platform side order list
- 【七夕】七夕孤寡小青蛙究极版?七夕节最终章!
- 如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
- Swiftui layout - size (top)
- QT hex, decimal, qbytearray, qstring data conversion
- pix2pix
- Redis-配置文件讲解
- VTK annotation class widget vtkborderwidget
- The second pre class exercise
猜你喜欢

Cv:: mat conversion to qimage error

ScottPlot入门教程:获取和显示鼠标处的数值
C # read INI file and key value pair operation

@DS('slave') 多数据源兼容事务问题解决方案

C语言实现简单学生成绩管理系统的方法

Installing redis in Linux

八、picker用法 下拉框选择效果

Read the introduction tutorial of rainbow

国产数据库的红利还能“吃”多久?

2022 safety officer-a certificate operation certificate examination question bank simulated examination platform operation
随机推荐
Switch the cloud synchronization status of core data in real time
C# 读取ini文件、键值对操作
用 Table 在 SwiftUI 下创建表格
企鹅一面:为什么不建议使用SELECT * ?
2022 high altitude installation, maintenance, removal of examination question bank and online simulated examination
Namespace conflict problem
I am using a blog creation tool
Robot mathematics foundation 3D space position representation space position
Installing MySQL on Linux
如何只降3D相机不降UI相机的分辨率
QT environment cannot run error set
@Solution to DS ('slave') multi data source compatible transaction problem
How to perform batch operations in core data
OKR and grad
Animation mechanism of swiftui
Focus on differentiated product design, intelligent technology efficiency improvement and literacy education around new citizen Finance
SwiftUI 布局 —— 尺寸( 上 )
九、uni-popup用法 下拉框底部弹窗效果
VTK annotation class widget vtkborderwidget
Hcip day 10