How to publish a XML?
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,
Marvin
Asked by _marv on 2016-03-03 04:22:43 UTC
Answers
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 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.
Asked by Javier V. Gómez on 2016-03-03 06:58:35 UTC
Comments
To whoever downvoted, you should say why. Otherwise it is completely useless.
Asked by Javier V. Gómez on 2016-03-04 10:58:59 UTC
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..
Asked by _marv on 2016-03-04 03:23:05 UTC
Comments
Please do not comment with answers. Use the comment function for commenting.
Asked by BennyRe on 2016-03-04 05:49:29 UTC
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.
Asked by Javier V. Gómez on 2016-03-04 11:00:57 UTC
Comments