另外参考链接:
ROS动态参数配置:dynparam命令行工具的使用(示例+代码)_肥肥胖胖是太阳的博客-CSDN博客
参数服务器实现的功能:更改参数后,不须要重新编译,节点启动时生效;
动态调参实现的功能:更改参数后,不须要重新编译,无需重新启动节点;
这个一元堆栈包含dynamic_reconfigure包,它提供了一种方式,可以在任何时侯修改节点参数,而无需重新启动节点。
目前服务器参数详解,dynamic_reconfigure的重点是提供一种标准方式,将节点参数的子集公开给外部重新配置。顾客机程序,比如GUIs,可以查询节点的可构建参数集,包括它们的名称、类型和范围,并向用户提供订制的插口。这对于硬件驱动程序非常有用,但具有更广泛的适用性。
源代码:
(branch:master)
git https://github.com/ros/dynamic_reconfigure.git
第一部份:动态调参的应用
1.dynparam命令行工具
dynparam工具支持节点的命令行重新配置,以及将它们的配置加载和轮询到文件中。要运行dynparam服务器参数详解,输入:
$
rosrun dynamic_reconfigure dynparam COMMAND
当前支持的命令是:
dynparam list : list configurable nodes
dynparam get : get node configuration
dynparam set : configure node
dynparam set_from_parameters : copy configuration from parameter server
dynparam dump : dump configuration to file
dynparam load : load configuration from file
具体指令如下
1.列举所有可以动态调参的节点
$
rosrun dynamic_reconfigure dynparam list
范例:
firefly@firefly:~$ rosrun dynamic_reconfigure dynparam list
/amcl
/move_base
/move_base/TrajectoryPlannerROS
/move_base/global_costmap
/move_base/global_costmap/inflation_layer
/move_base/global_costmap/obstacle_layer
/move_base/local_costmap
/move_base/local_costmap/inflation_layer
/move_base/local_costmap/obstacle_layer
/velocity_smoother
2.获取一个可以动态调参的节点的动态参数配置
$
rosrun dynamic_reconfigure dynparam get /node
范例:
firefly@firefly:~$ rosrun dynamic_reconfigure dynparam get /move_base/local_costmap/inflation_layer
{'inflate_unknown': False, 'cost_scaling_factor': 20.0, 'inflation_radius': 0.28, 'enabled': True, 'groups': {'cost_scaling_factor': 20.0, 'parent': 0, 'inflation_radius': 0.28, 'groups': {}, 'id': 0, 'name': 'Default', 'parameters': {}, 'enabled': True, 'state': True, 'inflate_unknown': False, 'type': ''}}
firefly@firefly:~$ rosrun dynamic_reconfigure dynparam get /move_base/TrajectoryPlannerROS
{'max_vel_theta': 1.0, 'vtheta_samples': 20, 'min_vel_x': 0.0, 'heading_lookahead': 0.325, 'restore_defaults': False, 'heading_scoring': False, 'min_vel_theta': -1.0, 'angular_sim_granularity': 0.025, 'holonomic_robot': False, 'acc_lim_x': 0.2, 'acc_lim_y': 0.0, 'heading_scoring_timestep': 0.8, 'dwa': True, 'oscillation_reset_dist': 0.1, 'escape_vel': -0.1, 'sim_time': 2.5, 'y_vels': '-0.3,-0.1,0.1,-0.3', 'simple_attractor': False, 'acc_lim_theta': 1.8, 'min_in_place_vel_theta': 0.05, 'gdist_scale': 0.3, 'groups': {'max_vel_theta': 1.0, 'simple_attractor': False, 'y_vels': '-0.3,-0.1,0.1,-0.3', 'parent': 0, 'acc_lim_theta': 1.8, 'min_in_place_vel_theta': 0.05, 'dwa': True, 'vtheta_samples': 20, 'min_vel_theta': -1.0, 'heading_lookahead': 0.325, 'gdist_scale': 0.3, 'groups': {}, 'heading_scoring': False, 'min_vel_x': 0.0, 'id': 0, 'angular_sim_granularity': 0.025, 'holonomic_robot': False, 'name': 'Default', 'parameters': {}, 'acc_lim_x': 0.2, 'acc_lim_y': 0.0, 'escape_reset_theta': 1.57079632679, 'restore_defaults': False, 'occdist_scale': 0.8, 'vx_samples': 8, 'heading_scoring_timestep': 0.8, 'state': True, 'sim_time': 2.5, 'pdist_scale': 0.8, 'max_vel_x': 0.2, 'sim_granularity': 0.025, 'type': '', 'escape_reset_dist': 0.1, 'oscillation_reset_dist': 0.1, 'escape_vel': -0.1}, 'escape_reset_theta': 1.57079632679, 'occdist_scale': 0.8, 'vx_samples': 8, 'pdist_scale': 0.8, 'max_vel_x': 0.2, 'sim_granularity': 0.025, 'escape_reset_dist': 0.1}
3.给一个节点的动态参数形参value
单个参数
$
rosrun dynamic_reconfigure dynparam set /node parameter_name value
or多个参数(setnode_nameyaml_dictionary)
$
rosrun dynamic_reconfigure dynparam set wge100_camera "{'camera_url':'foo', 'brightness':58}"
范例:
rosrun dynamic_reconfigure dynparam set /move_base/local_costmap/inflation_layer inflation_radius 0.01
4.从参数服务器加载数据
rosrun dynamic_reconfigure dynparam set_from_parameters /node
5.将动态参数配置存到yaml配置文件中
rosrun dynamic_reconfigure dynparam set_from_parameters /node
6.从yaml配置文件中加载配置动态参数
$
rosrun dynamic_reconfigure dynparam load /node dump.yaml
第二部份:动态参数服务的构建
2.在C++程序中应用dynamic_reconfigure
安装dynamic_reconfigure软件包
sudo apt-get install -y ros-kinetic-dynamic-reconfigure
在参数服务器中添加参数
使用dynamic_reconfigure动态调节节点参数
暂无评论内容