当前位置:网站首页>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
边栏推荐
- QT qbuttongroup realizes single selection and multiple selection
- 8、 Picker usage drop-down box selection effect
- Unittest executes runtestcase prompt <_ io. Textiowrapper name= '< stderr>' mode=W encoding=UTF-8 > solution
- Product Manager
- 看了就会的 Rainbond 入门教程
- 国产数据库的红利还能“吃”多久?
- Floating point data type in C language (did you learn to waste it)
- Installing redis in Linux
- Store and guarantee rancher data based on Minio objects
- SwiftUI 布局 —— 尺寸( 下 )
猜你喜欢

Summarize the knowledge points of the ten JVM modules. If you don't believe it, you still don't understand it
![[thread safety] what risks may multithreading bring?](/img/79/112ab7e586b0bceb296dfddb2728be.png)
[thread safety] what risks may multithreading bring?
Some problems encountered in the development of Excel VBA, solutions, and continuous updates

ScottPlot入门教程:获取和显示鼠标处的数值

VTK annotation class widget vtkborderwidget

Hcip day 12

十、时间戳

Brief introduction and use of mqtt entry level

Interviewer: what are the usage scenarios of ThreadLocal? How to avoid memory leakage?

58 sub station Anju, broker marketing management platform login interface encryption reverse
随机推荐
Hcip day 12
C language related programming exercises
数字化转型安全问题频发,山石网科助力数字政府建设
Creating, deleting and viewing Anaconda virtual environment
String转为long 类型报错原因:要转为long必须是int、double、float型[通俗易懂]
Digital transformation security issues occur frequently, and Shanshi Netcom helps build a digital government
@Solution to DS ('slave') multi data source compatible transaction problem
2022 melting welding and thermal cutting examination questions and online simulation examination
卡方分布和伽马函数(Chi-Square Distribution)
Error reason for converting string to long type: to convert to long type, it must be int, double, float type [easy to understand]
Switch the cloud synchronization status of core data in real time
Thoughts on the construction of some enterprise data platforms
When Xcode writes swiftui code, it is a small trap that compiles successfully but causes the preview to crash
C# 获取当前路径7种方法
RPC (remote procedure call protocol) telecommunication framework
How to perform batch operations in core data
9、 Uni popup usage popup effect at the bottom of the drop-down box
如何在 Core Data 中进行批量操作
看了就会的 Rainbond 入门教程
468 product planning and promotion plan (150 copies)