当前位置:网站首页>ROS dynamic parameters
ROS dynamic parameters
2022-08-02 00:18:00 【2021 Nqq】
客户端实现 dr.cfg
本质上是Python文件
#! /usr/bin/env python
"""
Dynamic parameter client:
1. 导包
2. Create a parameter producer
3. Add parameters to the generator
4. 配置节点,并退出
"""
# Import the function package corresponding to the parameter server
from dynamic_reconfigure.parameter_generator_catkin import *
# 2. Create a parameter producer
gen = ParameterGenerator()
# 3. Add parameters to the generator
# add(name, paramtype, level, description, default=None, min=None, max=None, edit_method="")
gen.add("int_param",int_t,0,"整数参数",10,1,100)
# 4. 配置节点,并退出
# generate(pkgname, nodename, name)
exit(gen.generate("demo02_dr","dr_client","dr"))
Dynamic parameter server C++
/* Dynamic parameter server process: 1. 包含头文件 2. 初始化操作 3. 创建服务端对象 4. The callback function parses the modified parameters 5. spin() */
#include"ros/ros.h"
#include"dynamic_reconfigure/server.h"
#include"demo02_dr/drConfig.h"
void cb(demo02_dr::drConfig &config, uint32_t level)
{
ROS_INFO("The modified integer data is: %d",config.int_param);
}
int main(int argc, char *argv[])
{
// 2. 初始化操作
setlocale(LC_ALL,"");
ros::init(argc,argv,"dr_server");
// 3. 创建服务端对象
dynamic_reconfigure::Server<demo02_dr::drConfig> server;
// 4. The callback function parses the modified parameters
// void setCallback(const boost::function<void (demo02_dr::drConfig &, uint32_t level)> &callback)
server.setCallback(boost::bind(&cb,_1,_2));
// 5. spin()
ros::spin();
return 0;
}
Dynamic parameter server Python
#! /usr/bin/env python
""" Dynamic parameter server: Print directly when the parameter is modified 实现流程: 1.导包 2.初始化 ros 节点 3.创建服务端对象 4.Callback function parsing function 5.spin """
import rospy
from dynamic_reconfigure.server import Server
from demo02_dr.cfg import drConfig
# 回调函数
def cb(config,level):
rospy.loginfo("python Dynamic parameter service resolution:%d,%.2f,%d,%s,%d",
config.int_param,
config.double_param,
config.bool_param,
config.string_param,
config.list_param
)
return config
if __name__ == "__main__":
# 2.初始化 ros 节点
rospy.init_node("dr_server_p")
# 3.创建服务端对象
# Server(type, callback, namespace="")
# type是类型 callback 回调函数
server = Server(drConfig,cb)
# 4.Callback function parsing function
# 5.spin
rospy.spin()
边栏推荐
- easy-excel 解决百万数据导入导出,性能很强
- An overview of the most useful DeFi tools
- 玩转NFT夏季:这份工具宝典值得收藏
- NFT工具合集
- Axure教程-新手入门基础(小白强烈推荐!!!)
- 使用 Zadig 交付云原生微服务应用
- 认识USB、Type-C、闪电、雷电接口
- 460. LFU 缓存
- After an incomplete recovery, the control file has been created or restored, the database must be opened with RESETLOGS, interpreting RESETLOGS.
- DOM 事件及事件委托
猜你喜欢

Excel表格数据导入MySQL数据库

TCL: Pin Constraints Using the tcl Scripting Language in Quartus

Unknown CMake command “add_action_files“

Arduino 基础语法

GIF making - very simple one-click animation tool

面试必问的HashCode技术内幕

短视频SEO搜索运营获客系统功能介绍

SphereEx Miao Liyao: Database Mesh R&D Practice under Cloud Native Architecture

协作乐高 All In One:DAO工具大全

接地气讲解TCP协议和网络程序设计
随机推荐
Unknown CMake command “add_action_files“
JSP 如何获取request对象中的路径信息呢?
08-SDRAM:汇总
一篇永久摆脱Mysql时区错误问题,idea数据库可视化插件配置
22. The support vector machine (SVM), gaussian kernel function
基于数据驱动的变电站巡检机器人自抗扰控制
单片机遥控开关系统设计(结构原理、电路、程序)
06-SDRAM :SDRAM控制模块
【Leetcode】473. Matchsticks to Square
easy-excel 解决百万数据导入导出,性能很强
Axure tutorial - the new base (small white strongly recommended!!!)
Study Notes: The Return of Machine Learning
一个有些意思的项目--文件夹对比工具(一)
接地气讲解TCP协议和网络程序设计
面试高频考题解法——栈的压入弹出序列、有效的括号、逆波兰表达式求值
els 长条变形
SphereEx Miao Liyao: Database Mesh R&D Practice under Cloud Native Architecture
Zadig 面向开发者的自测联调子环境技术方案详解
EasyExcel的简单读取操作
security CSRF漏洞保护