当前位置:网站首页>ROS参数服务器
ROS参数服务器
2022-06-11 00:25:00 【Mbot】
先在工作空间下创建一个功能包
catkin_create_pkg test_param std_msgs roscpp rospy
在功能包下创建一个param文件夹
在param文件夹下创建一个param.yaml文件
内容如下:
string: dsad3421
num1: 564.65
num2: 87896
sub_param_set:
string: cvvx
num: 423
sub_sub_param_set:
string: gfdg
num: 767
然后将参数载入:
先运行
roscore
再在param文件夹目录下运行
rosparam load param.yaml
rosparam list
结果如下:
可以用rosparam get和rosparam set来获取和设置参数值
在功能包的src目录下创建test_param.cpp
填入以下内容:
#include <string>
#include <ros/ros.h>
int main(int argc, char **argv)
{
int aaa;
// ROS节点初始化
ros::init(argc, argv, "parameter_config");
// 创建节点句柄
ros::NodeHandle node;
ros::param::get("/sub_param/num", aaa);
ROS_INFO("aaa=%d\n", aaa);
return 0;
}
在功能包的CMakeLists.txt中加入:
add_executable(test_param src/test_param.cpp)
target_link_libraries(test_param ${catkin_LIBRARIES})
然后catkin_make编译后运行
rosrun test_param test_param
结果如下,在运行这个节点的时候,必须用rosparam load 加载参数文件后,ROS里面才能get到参数的值,我这里之前使用rosparam set设置过参数/sub_param/num的值为456,所以这里get的值为456,如果没有set,则这个值就是参数文件中的值
边栏推荐
- Beijing Mentougou District high tech enterprise cultivation support standard, with a subsidy of 100000 yuan
- Understanding of multithreading
- 如何下载网页照片
- CSRF attack
- SAS principal component analysis (finding correlation matrix, eigenvalue, unit eigenvector, principal component expression, contribution rate and cumulative contribution rate, and data interpretation)
- How about compound interest insurance and financial products? Can I buy it?
- Configurable custom implementation 1 Implementation interface, 2 Custom configuration 3 Default configuration
- 负数+0+正数
- Record several Oracle parameters DB_ files,Cursor_ sharing ,open_ cursor
- Throttling and anti chattering of functions
猜你喜欢
![[VBA Script] extract the information and pending status of all annotations in the word document](/img/dc/0db51d092cde019cef4113796e4882.png)
[VBA Script] extract the information and pending status of all annotations in the word document

如何下载网页照片

網絡基礎(1)-----認識網絡

Yanrong looks at how to realize the optimal storage solution of data Lake in a hybrid cloud environment

记录打包GoogleChrome浏览器插件

Application of object storage S3 in distributed file system

Basic introduction of graph and depth first traversal and breadth first traversal

項目_基於網絡爬蟲的疫情數據可視化分析

Conda安装Pytorch后numpy出现问题

nodejs中使用mySql数据库
随机推荐
对象存储 S3 在分布式文件系统中的应用
深圳中国专利奖申报流程介绍,补贴100万
北京昌平区高新技术企业培育支持标准,补贴10万
快递鸟系统对接
负数+0+正数
Introduction to support standards for specialized, special and new manufacturing enterprises in Chaoyang District, Beijing, with a subsidy of 1million yuan
Introduction and creation of Huffman tree
Introduction to the subsidy fund for leading technological innovation of Beijing enterprises, with a subsidy of 5million yuan
async await
北京延庆区高新技术企业培育支持标准,补贴10万
深圳中国专利奖政策支持介绍,补贴100万
Project_ Visual analysis of epidemic data based on Web Crawler
Yunna provincial administrative unit fixed assets management system
Support standard for cultivation of high-tech enterprises in Changping District, Beijing, with a subsidy of 100000 yuan
北京中国专利奖政策支持介绍,补贴100万
Beijing Pinggu District high tech enterprise cultivation support standard, with a subsidy of 100000 yuan
Beijing Fangshan District high tech enterprise cultivation support standard, with a subsidy of 100000 yuan
[paper reading] fixmatch: simplifying semi supervised learning with consistency and confidence
Record the packaging of the googlechrome browser plug-in
Beijing Mentougou District high tech enterprise cultivation support standard, with a subsidy of 100000 yuan