0
$\begingroup$

Rosanswers logo

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.

Example:

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:

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

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?


Originally posted by Hendrik Wiese on ROS Answers with karma: 1145 on 2013-07-08

Post score: 1


Original comments

Comment by dornhege on 2013-07-09:
If you're interesting in queries like what's the byte sequence along Node1, then yes, that sounds like a service.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by dornhege with karma: 31395 on 2013-07-08

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Hendrik Wiese on 2013-07-08:
I'll extend my question by a description of the data that I'd like to address.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.