Ask Your Question

How to publish a XML?

asked 2016-03-03 03:22:43 -0500

_marv gravatar image

Hi all,

I'm a noob in ROS and I have a question about how to publish a xml.

This is the background: I've got two ROS nodes in one package. One node is to calibrate a camera and the other to compute the BirdsEyeView-Transformation of a capture from a camera.

The BirdsEyeView-Transformation needs to have access to the intrinsic matrix and the distortion coeffs which are calculated in the calibration node.

For me it's really hard to get useful information about ros as nobody is there to ask and mostly the information found on internet don't really fit to my problems.

First question: The calibration node is executed only once. If I publish my distortion and intrinsic XML's one time and then the calibration node is shut down: Am I able to have access to the published XML's with the transformation node after the calibration node already has shut down?

Second question: If the XML's are still avaible after the publishing node has shut down, could you help me for writing the definition of the publisher?

Thanks in advance,


edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2016-03-03 05:58:35 -0500

Answer to first question: In the nodes that you are subscribing to the XML message you will have to store in a local variable the XML data or, more ideally, create a class/struct and fill the attributes parsing the XML (much more efficient in memory and performance).

Answer to second question: : The easiest way I can think of for XML publication is to convert it to an std::vector<char *> and then publish it in a message containing an array of uint8[] (ROS message) or directly to an string ROS message, depending on how you are loading the XML data. I prefer the first method as the serialization and deserialization seems to be more straightforward. But this is nothing related with the XML being available afterwards.

edit flag offensive delete link more


To whoever downvoted, you should say why. Otherwise it is completely useless.

Javier V. Gómez gravatar image Javier V. Gómez  ( 2016-03-04 09:58:59 -0500 )edit

answered 2016-03-04 02:23:05 -0500

_marv gravatar image

Thanks for your answer... But first I have to know if the published messages are avaiable after node shut down because if not I will do it by another way..

edit flag offensive delete link more



Please do not comment with answers. Use the comment function for commenting.

BennyRe gravatar image BennyRe  ( 2016-03-04 04:49:29 -0500 )edit

As I said in my first answer: when the callback of your subscribed is called you have to copy the data in the subscriber node. Otherwise, data is not available after publisher shutdown. Messages in the subscribers only live for the duration of the callback, so you have to do a deep copy of it.

Javier V. Gómez gravatar image Javier V. Gómez  ( 2016-03-04 10:00:57 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2016-03-03 03:22:43 -0500

Seen: 99 times

Last updated: Mar 04 '16