当前位置:网站首页>ROS notes (09) - query and setting of parameters
ROS notes (09) - query and setting of parameters
2022-06-28 08:03:00 【wohu1104】
Parameter server in ROS It is mainly used to realize data sharing between different nodes . The parameter server is then equivalent to a common container independent of all nodes , You can store data in this container , Called by different nodes , Of course, different nodes can also store data , The typical application scenarios of the parameter server are as follows :
When navigation is implemented , We'll do path planning , such as : Global path planning , Design an approximate path from the starting point to the target point . Local path planning , The travel path will be generated according to the current road conditions
In the above scenario , Global path planning and local path planning , The parameter server will be used :
Path planning , It is necessary to refer to the size of the trolley , We can store these size information in the parameter server , Global path planning nodes and local path planning nodes can middle note these parameters from the parameter server.
Parameter server , It is generally applicable to some application scenarios with data sharing .
1. Parametric model
As shown above , The parametric model can be seen as
ROS
The global dictionary of , Each node Node
The corresponding parameter information can be obtained from the parameter model .
For details, please refer to :http://wiki.ros.org/Parameter%20server
2. Common parameter command line
Common parameter command lines are as follows
$ rosparam
rosparam is a command-line tool for getting, setting, and deleting parameters from the ROS Parameter Server.
Commands:
rosparam set set parameter
rosparam get get parameter
rosparam load load parameters from file
rosparam dump dump parameters to file
rosparam delete delete parameter
rosparam list list parameter names
- List all current parameters
$ rosparam list
/rosdistro
/roslaunch/uris/host_wohu_pc__42765
/rosversion
/run_id
/turtlesim/background_b
/turtlesim/background_g
/turtlesim/background_r
- Display a parameter value
$ rosparam get /run_id
b37e6c1a-f0fe-11ec-92ca-00e070ce7d11
$ rosparam get /turtlesim/background_b
255
- Set a parameter value
$ rosparam set /turtlesim/background_b 100
$ rosparam get /turtlesim/background_b
100
$ rosservice call /clear "{}" # Used to make the new value of the setting effective
- Save parameters to file
$ rosparam dump config
$ ls
build config devel src
$ cat config
rosdistro: 'melodic '
roslaunch:
uris: {
host_wohu_pc__42765: 'http://wohu-pc:42765/'}
rosversion: '1.14.13 '
run_id: b37e6c1a-f0fe-11ec-92ca-00e070ce7d11
turtlesim: {
background_b: 100, background_g: 86, background_r: 69}
- Read parameters from file
$ rosparam load config
$ rosservice call /clear "{}"
- Delete parameters
$ rosparam set /aaa 100
$ rosparam get /aaa
100
$ rosparam delete /aaa
3. Parameter storage format
All parameters are stored in one YAML
Format file .
rosdistro: 'melodic
'
roslaunch:
uris: {
host_wohu_pc__42765: 'http://wohu-pc:42765/'}
rosversion: '1.14.13
'
run_id: b37e6c1a-f0fe-11ec-92ca-00e070ce7d11
turtlesim: {
background_b: 100, background_g: 86, background_r: 69}
4. Parameter setting and query code
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This routine sets / Read the parameters in the turtle routine
import sys
import rospy
from std_srvs.srv import Empty
def parameter_config():
# ROS Node initialization
rospy.init_node('parameter_config', anonymous=True)
# Read background color parameters
red = rospy.get_param('/turtlesim/background_r')
green = rospy.get_param('/turtlesim/background_g')
blue = rospy.get_param('/turtlesim/background_b')
rospy.loginfo("Get Backgroud Color[%d, %d, %d]", red, green, blue)
# Set the background color parameters
rospy.set_param("/turtlesim/background_r", 255);
rospy.set_param("/turtlesim/background_g", 255);
rospy.set_param("/turtlesim/background_b", 255);
rospy.loginfo("Set Backgroud Color[255, 255, 255]");
# Read background color parameters
red = rospy.get_param('/turtlesim/background_r')
green = rospy.get_param('/turtlesim/background_g')
blue = rospy.get_param('/turtlesim/background_b')
rospy.loginfo("Get Backgroud Color[%d, %d, %d]", red, green, blue)
# Find out /spawn After service , Create a service client , The connection name is /spawn Of service
rospy.wait_for_service('/clear')
try:
clear_background = rospy.ServiceProxy('/clear', Empty)
# Request service call , Enter request data
response = clear_background()
return response
except rospy.ServiceException, e:
print "Service call failed: %s"%e
if __name__ == "__main__":
parameter_config()
function
$ cd ~/catkin_ws
$ catkin_create_pkg parameter rospy std_msgs geometry_msgs turtlesim
$ catkin_make
$ source ./devel/setup.bash
take Python
Put the code in the following path
Carry on
$ roscore
$ rosrun turtlesim turtlesim_node
$ rosrun parameter parameter_config.py
The results change
边栏推荐
- asp. Net datalist when there are multiple data displays
- 三角变换公式
- Dataset filling data, and the use of rows and columns
- Rediscluster cluster mode capacity expansion node
- Online WPS tool
- Sword finger offer|: linked list (simple)
- Study notes 22/1/18
- asp. Net error "/" server error in the application. String or binary data would be truncated. The statement...
- Section 9: dual core startup of zynq
- asp. Net to search products and realize paging function
猜你喜欢
Section VI UART of zynq
Software testing and quality final review
云原生:云计算技术再次升级 开启全面云开发时代
SOC timer and interrupt configuration
Ambari (V) ---ambari integrated Azkaban (valid for personal test)
SQL Master slave Replication Build
MySQL row format parsing
22/02/15 study notes
Kubernetes理论基础
Jacobian matrix J commonly used in slam
随机推荐
Conversion between HJ integer and IP address
HJ质数因子
asp. Net datalist when there are multiple data displays
同花顺注册开户靠谱吗?安全吗?
云原生:云计算技术再次升级 开启全面云开发时代
Do you know TCP protocol (2)?
Safety training is the greatest benefit for employees! 2022 induction safety training for new employees
Redis one master multi slave cluster setup
asp. Net datalist to display product information and pictures
你了解TCP协议吗(一)?
Redis persistence problem and final solution
Rediscluster cluster mode capacity expansion node
ZYNQ_ IIC read / write m24m01 record board status
flex布局
HJ character count
Investment transaction and settlement of the fund
8 figures | analyze Eureka's first synchronization registry
Ambari (VI) -- ambari API use
How redis solves cache avalanche, breakdown and penetration problems
ACM notes