当前位置:网站首页>ROS系列(四):ROS通信机制系列(6):参数服务器实操
ROS系列(四):ROS通信机制系列(6):参数服务器实操
2022-04-22 06:04:00 【亦岚君】
需求描述: 修改turtlesim乌龟显示节点窗体的背景色,已知背景色是通过参数服务器的方式以 rgb 方式设置的。
结果演示:

实现流程:
- 通过ros命令获取参数。
- 编码实现服参数设置节点。
- 启动 roscore、turtlesim_node 与参数设置节点,查看运行结果。
1 参数名获取
获取参数列表:
rosparam list
响应结果:
/turtlesim/background_b
/turtlesim/background_g
/turtlesim/background_r
2 参数修改(C++)
/* 注意命名空间的使用。 */
#include "ros/ros.h"
int main(int argc, char *argv[])
{
ros::init(argc,argv,"haha");
ros::NodeHandle nh("turtlesim");
//ros::NodeHandle nh;
// ros::param::set("/turtlesim/background_r",0);
// ros::param::set("/turtlesim/background_g",0);
// ros::param::set("/turtlesim/background_b",0);
nh.setParam("background_r",0);
nh.setParam("background_g",0);
nh.setParam("background_b",0);
return 0;
}
3 运行
- 首先,启动 roscore;
- 然后启动背景色设置节点;
- 最后启动乌龟显示节点;
- 最终执行结果与演示结果类似。
PS: 注意节点启动顺序,如果先启动乌龟显示节点,后启动背景色设置节点,那么颜色设置不会生效。
4 其他方式修改参数
方式1:修改小乌龟节点的背景色(终端代码实现)
rosparam set /turtlesim/background_b 自定义数值
rosparam set /turtlesim/background_g 自定义数值
rosparam set /turtlesim/background_r 自定义数值
方式2:启动节点时,直接设置参数
rosrun turtlesim turtlesim_node _background_r:=100 _background_g=0 _background_b=0
版权声明
本文为[亦岚君]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_44498476/article/details/124332040
边栏推荐
- ERROR: Could not find a version that satisfies the requirement win32gui
- 向服务器中 添加文件
- 微生物菌群宏基因组研究技术分享
- 美团设置渠道包 walle 方式
- How do I clear floating?
- 使用keras框架编写三层神经网络解决房价预测问题
- 数据密集型应用系统设计专题
- 【AI视野·今日NLP 自然语言处理论文速览 第二十八期】Wed, 1 Dec 2021
- 2020即将结束,特殊又难忘。
- Encapsulate wechat applet to obtain longitude and latitude + permission determination + guidance authorization in real time (no 30 second delay)
猜你喜欢

肠-肝轴:宿主-微生物群相互作用影响肝癌发生

检索式问答系统baseline

细菌感染和抗生素使用

CLion+OpenCV 识别身份证号码---检测身份证号码

spark小案例——RDD,sparkSQL

【AI视野·今日Robot 机器人论文速览 第二十九期】Mon, 14 Feb 2022

pip3安装requests库-最全踩坑整理

手把手教你一小时设计基于matlab的信号发生器GUI界面(2)

win10完美安装cuda11.x + pytorch 1.9 (血流成河贴┭┮﹏┭┮)让你的torch.cuda.is_available()变成True!

肠道核心菌属——毛螺菌属(Lachnospira)
随机推荐
手把手教你一小时设计基于matlab的信号发生器GUI界面(1)
Win10启动VMware虚拟机开机秒蓝屏问题完美解决
api集中管理
常用的各种工具类 状态栏 缓存 转化 获取app信息 剪切板 文件操作 加解密操作
2018年的最后一天,迎接2019。
glide 4.0 之后 和圆角裁剪CenterCrop冲突
How is the diversity of flora formed, the relationship with health, and how to improve it?
自定义switch控件
Simple use of Excel PivotTable
Encapsulate wechat applet to obtain longitude and latitude + permission determination + guidance authorization in real time (no 30 second delay)
微生物菌群宏基因组研究技术分享
生成订单核销二维码,扫码完成核销
计数排序(C语言实现)------学习笔记
Two-stage目标检测技术发展(一)R-CNN和SPP-Net
解决seq2seq+attention机器翻译中的技术小难题
2020即将结束,特殊又难忘。
The app enters for the first time and pops up the service agreement and privacy policy
基于CRF的医疗实体识别baseline
Jetpack--Lifecycle使用和源码解析
Comparative analysis of slope and aspect between ArcMap tin and grid DEM