ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Use central definition database (XML) across multiple nodes?

asked 2013-07-08 06:40:01 -0600

Hendrik Wiese gravatar image

updated 2013-07-08 07:42:12 -0600

I've got an XML file in my project containing data that shall be addressable globally by any node that is running in my ROS. What's the royal road to achieve this? Is setting up an srv that serves that data on request the ideal way?

//additional information

It's relatively simple data that's mainly accessed via XPath. It consists of a tree whose branches are used to convert a path like description of an ID into a byte sequence. Each individually named node has an attribute 'id'. I use XPath to retrieve the sequence of IDs of a leaf node up to it's farthest ancestor one layer below the root node.


An XPath of /IDTree/Node1/Subnode1/Subsubnode1 shall be converted to the byte sequence [0x01,0x01,0x01]. Additionally, this conversion should work in both directions.

The XML data for this would look like that for instance:

  <Node1 id="0x01">
    <Subnode1 id="0x01">
      <Subsubnode1 id="0x01" />

The names of the nodes aren't specified anywhere. Only the structure which is always three layers deep below the root node and every node must have its id attribute set appropriately.

The real tree is way bigger and stored in an XML file called idtree.xml which I've placed in the root folder of my catkin workspace.

I'd like to be able to make this conversion anywhere in my ROS project. I guess a service is the ideal way for this, am I right?

edit retag flag offensive close merge delete



If you're interesting in queries like what's the byte sequence along Node1, then yes, that sounds like a service.

dornhege gravatar image dornhege  ( 2013-07-09 01:36:46 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-07-08 07:04:44 -0600

dornhege gravatar image

I guess it depends...

  • If the data is somewhat simple, the best way might be to put it on the param server.

  • If processing and reading the data takes considerable effort either in computation time or in code, and/or if the data should somehow be converted, your solution of a node that provides this data as a service certainly works.

  • Another option is to put either a URL to the xml file or the actual xml contents on the param server for other nodes to read. In either case, each node needs to parse in the xml data by itself. Both solutions are natively supported by the param server.

    • For the first solution, a package relative URL like package://my_data_pkg/xml/stuff.xml is customary. The resource_retriever package can also load that directly into memory. Alternatively the ROS API provides ways to resolve the package path locally.

    • The second solution can be done directly by the param server, similar how a robot_description is usually loaded as a textfile.

edit flag offensive delete link more


I'll extend my question by a description of the data that I'd like to address.

Hendrik Wiese gravatar image Hendrik Wiese  ( 2013-07-08 07:32:44 -0600 )edit

answered 2013-07-09 02:43:52 -0600

Hendrik Wiese gravatar image

It is now implemented as a service, running like a charm. So I accept a service as the way to go in this particular case.

edit flag offensive delete link more

Question Tools


Asked: 2013-07-08 06:40:01 -0600

Seen: 224 times

Last updated: Jul 09 '13