zoukankan      html  css  js  c++  java
  • 关于ros中的参数函数

    http://wiki.ros.org/rospy/Overview/Parameter%20Server

    rospy.get_param(param_name)

       1 global_name = rospy.get_param("/global_name")
       2 relative_name = rospy.get_param("relative_name")
       3 private_param = rospy.get_param('~private_name')
       4 default_param = rospy.get_param('default_param', 'default_value')
       5 
       6 # fetch a group (dictionary) of parameters
       7 gains = rospy.get_param('gains')
       8 p, i, d = gains['p'], gains['i'], gains['d']

    rospy.set_param(param_name, param_value)

      1 # Using rospy and raw python objects
       2 rospy.set_param('a_string', 'baz')
       3 rospy.set_param('~private_int', 2)
       4 rospy.set_param('list_of_floats', [1., 2., 3., 4.])
       5 rospy.set_param('bool_True', True)
       6 rospy.set_param('gains', {'p': 1, 'i': 2, 'd': 3})
       7 
       8 # Using rosparam and yaml strings
       9 rosparam.set_param('a_string', 'baz')
      10 rosparam.set_param('~private_int', '2')
      11 rosparam.set_param('list_of_floats', "[1., 2., 3., 4.]")
      12 rosparam.set_param('bool_True', "true")
      13 rosparam.set_param('gains', "{'p': 1, 'i': 2, 'd': 3}")
      14 
      15 rospy.get_param('gains/p') #should return 1

    rospy.has_param(param_name)

     1 if rospy.has_param('to_delete'):
       2     rospy.delete_param('to_delete')

    rospy.delete_param(param_name)

      1 try:
       2     rospy.delete_param('to_delete')
       3 except KeyError:
       4     print("value not set")
  • 相关阅读:
    魔理沙的烟火制造
    【数位DP】恨7不成妻
    Happy Equation
    实验4
    Max answer(The Preliminary Contest for ICPC China Nanchang National Invitational)
    Next K Permutation
    Hubtown(最大流)
    Compass Card Sales(模拟)
    Ghostbusters(并查集,最小生成树)
    游览器兼容性笔记
  • 原文地址:https://www.cnblogs.com/miaorn/p/13542821.html
Copyright © 2011-2022 走看看