rosmaster code reading

参考资源

代码路径入口

  • rosmaster command
    ros_comm/tools/rosmaster/scripts/rosmaster
  • rosmaster logic entry
    ros_comm/tools/rosmaster/src/rosmaster/main.py rosmaster_main()

implementation

核心逻辑入口在 Master class,实现在ros_comm/tools/rosmaster/src/rosmaster/master.py文件中。

启动流程为:

  1. 解析传入参数
  2. 初始化 ROSMasterHandler
  3. 初始化 XmlRpcNode(server),并启动
  4. 检查XmlRpcNode(server)状态,直到退出

ROSMasterHandler

最主要的业务逻辑都在这里,实现文件:ros_comm/tools/rosmaster/src/rosmaster/master_api.py

对外导出的方法、功能

EXTERNAL API
  1. shutdown
    Stop this server.
  2. getUri
    Get the XML-RPC URI of this server.
    通过xmlrpc server获取xmlrpc server的地址,有种先有鸡还是先有蛋的纠结。
  3. getPid
    Get the PID of this server.
PARAMETER SERVER ROUNTINES
  1. deleteParam
  2. setParam
  3. getParam
  4. searchParam
  5. subscribeParam
  6. unsubscribeParam
  7. hasParam
  8. getParamNames
NOTIFICATION ROUTINES
  1. param_update_task
SERVICE PROVIDER
  1. registerService
    Register the caller as a provider of the specified service.
  2. lookupService
  3. unregisterService
PUBLISH/SUBSCRIBE
  1. registerSubscriber
  2. unregisterSubscriber
  3. registerPublisher
  4. unregisterPublisher
GRAPH STATE APIS
  1. lookupNode
  2. getPublishedTopics
  3. getTopicTypes
  4. getSystemState

核心逻辑

  • 信息的存储检索
  • 信息的订阅通知