ROS加载yaml文件设置嵌套字典参数

参考:https://answers.ros.org/question/197304/creatingparsing-a-dictionary-of-dictionary-params/

官网:http://wiki.ros.org/roslaunch/XML/rosparam

官网解读:

The load command is considered additive: if you declare a dictionary or namespace of parameters, those parameters will be added to any other parameters declared for that namespace. Similarly, load commands can override parameters previously declared.

The <rosparam> tag can either reference a YAML file or contain raw YAML text. If the YAML text defines a dictionary, the param attribute may be omitted.

<launch>
    <node pkg="beginner_tutorials" type="v1.py" name="" output="screen" respawn="true">
        <param name="launchpath" value="/home/haypin/pytest/launchdir"/>
        <rosparam command="load" file="$(find beginner_tutorials)/launch/mydict.yaml" />
        <rosparam param="a_list">[3,1,4,1,5,9,2,6]</rosparam>
    </node>
    <!-- <node pkg="beginner_tutorials" type="SubYamlOrder.py" name="tacticSub" output="screen" respawn="true"/> -->
</launch>
ob_extract: 
  board: 
    adjacent_dis_min: 0.1 
    len: 
      min: 0.2                
      max: 0.3                
if DEBUG:
    param_ob_extract = rospy.get_param("~ob_extract")  #~替代/node_name/,不用再加/
    print(type(param_ob_extract))             #已经是个Python字典dict了

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值