<div class="gmail_quote">On Wed, May 4, 2011 at 10:07 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>The problem comes when I try to write a generic subscriber: I tried with this:</div><div><br></div><div><div>                sub = new ros::Subscriber(rosNodeHandle->subscribe(url.getPath(), 1000, &RosAphModule::subscriptionCallback, this));</div>

<div><br></div><div>but this cannot be done, since the callback should be something like:</div><div><br></div><div>void RosAphModule::subscriptionCallback(const ros::Message::ConstPtr& msg)</div><div><br></div><div>that is not allowed, because ros::Message is an abstract type and the compiler says what I paste at the end of this email... moreover, I would like to know how to get the topic the message was coming from (given the ros::Message& msg in the callback, I mean).</div>

<div><br></div></div></blockquote><div><br></div><div>Hey Daniele,</div><div><br></div><div>Looks tricky indeed...   the compiler can only know which serialization method to instantiate if it knows what message type to expect via the type argument to subscribe<>.  For instance, there is no procedure by which a ros node, given an incoming message of unknown type, can look up a serialization method in a table, since this table does not exist.  If it did exist, there would be no  guarantee that it is complete, as the incoming message might have been generated by code that this node does not have access to.   Also, to do anything with this message one would then need to type-switch or something, which is quickly going to break down... there are just a lot of problems here that might be better addressed with an alternate design. </div>
<div><br></div><div>So...  can I ask you to elaborate on how this will all fit together?</div><div><br></div><div>Troy</div><div><br></div></div>