<div class="gmail_quote">On Thu, May 5, 2011 at 2:31 AM, Daniele Calisi <span dir="ltr"><<a href="mailto:daniele.calisi@gmail.com">daniele.calisi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div><div></div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div>You are saying that the DEserialization method (I can do what I want with the publisher, the problem exists only with the subscriber) is instantiated during the building process and not dynamically at run-time (i.e., ROS uses C++ templating facilities). </div>
</div></blockquote></div></div></div></blockquote><div><br></div><div>Yeah:  </div><div><br></div><div><div>void chatterCallback(const std_msgs::String::ConstPtr& msg)</div><div>{</div><div>  ROS_INFO("I heard: [%s]", msg->data.c_str());</div>
<div>}</div></div><div><br></div><div>ros::NodeHandle n;</div><div><div>ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);</div></div><div><br></div><div>Here subscribe() deduces the type of the message from the signature of the callback.  This type is used to instantiate code that deserializes messages, in this case of type std_msgs::String.  </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div>This could be good for efficiency reasons (how much?), but I do not see the point of not having the serializers/deserializers table. </div></div></blockquote></div></div></div></blockquote><div>
<br></div><div>Of course you are welcome to construct one.  </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div><div class="h5">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div>Of course you can build a node with a publisher that uses serialization method A and a node with a subscriber, for the same object, with a serialization method B (e.g., a different version of the same object) and things are going to fail. Unmarshalling are usually done (by Data Distribution Services and some other middleware software) by checking object name, version, etc. and then decide how to deserialize. Here it seems that ROS can check this meta information, but only to decide if it is going to use the right deserializer or not. </div>
</div></blockquote></div></div></div></blockquote><div><br></div><div>I think you've got that right.  Topics only contain one type of message... that's just the model ROS uses. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div>Moreover, how subclassing is working here? If I send an object of class A to a subscriber of class B : public A, what happens?</div>
</div></blockquote></div></div></div></blockquote><div><br></div><div>Hmm, message types don't inherit from each other.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div>I think that, since you are just receiving a stream of bytes from the network, it's up to the subscriber to convert that stream to what is right. </div></div></blockquote><div><br></div><div>
Yeah.  The current API establishes which converter you'll use when the subscriber is created.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote">
<div>Finally, you are always "type-converting" a stream of bytes to an object, I do not see the point of fearing this conversion, being that done statically at building time, or dynamically with an smart unmarshalling system.</div>
</div></blockquote><div><br></div><div>Fearing the conversion?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote">
<div><br></div><div>What am I missing here?</div><div><br></div></div></blockquote><div><br></div><div>Not sure.</div><div><br></div><div>Troy</div><div><br></div><div><br></div><div><br></div><div> </div></div>