• Understanding ROS Services and Parameters


    service是nodes之间通信的一种方式,允许nodes send a request and recieve a response。

    • rosservice
    • rosparam

    roservice

    rosservice list         print information about active services   #展示有哪些service
    rosservice call         call the service with the provided args   #rosservice call [service] [args]
    rosservice type         print service type                        #rosservice type [service]
    rosservice find         find services by service type
    rosservice uri          print service ROSRPC uri
    

    rosparam

    rosparam allows you to store and manipulate data on the ROS Parameter Server. The Parameter Server can store integers, floats, boolean, dictionaries, and lists. rosparam uses the YAML markup language for syntax. In simple cases, YAML looks very natural: 1 is an integer, 1.0 is a float, one is a string, true is a boolean, [1, 2, 3] is a list of integers, and {a: b, c: d} is a dictionary. rosparam has many commands that can be used on parameters, as shown below:

    rosparam set            set parameter       # rosparam set /background_r 150
    rosparam get            get parameter       # rosparam get /background_g 
    rosparam load           load parameters from file
    rosparam dump           dump parameters to file
    rosparam delete         delete parameter
    rosparam list           list parameter names   
    

    dump load用法举例

    rosparam dump [file_name] [namespace]
    rosparam load [file_name] [namespace]
    
    rosparam dump params.yaml  #把所有的参数写入params.yaml
    rosparam load params.yaml copy #加载param.yaml的参数到新的namespace(新的namespace名字为copy)
    rosparam get /copy/background_b #获取上一步中的新的namespace中的参数信息
    

    在set parameter以后必须调用rosservice call /clear使其生效
    This changes the parameter value, now we have to call the clear service for the parameter change to take effect:

    rosservice call /clear
    

    rosparam用来存储及操作位于Parameter Server的数据.

  • 相关阅读:
    【Gitbook】实用配置及插件介绍
    【Git】学习记录
    【Ubuntu】使用记录
    intellij idea
    【应用】信息短时存储
    leetcode pow(x,n)实现
    SSM框架-----------SpringMVC+Spring+Mybatis框架整合详细教程
    《平凡的世界》之我看
    垃圾收集器与内存分配策略(三)
    垃圾收集器与内存分配策略(二)
  • 原文地址:https://www.cnblogs.com/sdu20112013/p/10570485.html
Copyright © 2020-2023  润新知