Hi,<br><br>Your subscriber should be instantiated outside of your loop:<br><br>int main(int argc, char **argv)<br>{<br>        init(argc, argv, "testPlayer");<br>        NodeHandle n;<br><br>        Subscriber sub;<br>

        sub = n.subscribe("scan", 1000, &testPlayer::callBack, &test);<br><br>        Rate loop_rate(5);<br><br>        testPlayer test;<br>
<br>        while ( ok() ) {<br><br>            spinOnce();<br><br>            loop_rate.sleep();<br>        }<br><br>  return 0;<br>
}<br><br>This should work normally.<br><br>Cheers,<br><br>Ugo<br><br><br><div class="gmail_quote">On Thu, Feb 17, 2011 at 10:20 AM, Aslund <span dir="ltr"><<a href="mailto:sebastian.aslund@gmail.com">sebastian.aslund@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hey everyone<br><br>I got a small problem writting a subscriber using the spinOnce command instead of the spin() used in the tutorial. I do not receive anything from the subscription, but I know topics are being published. rviz is showing that the data is published and if I rewrite the code to use spin() like in the tutorial, then I get plenty of information. I have tried to search the problem but did not find anything useful and I hope someone here can see the problem. <br>

<br>My code is: <br><br><br>Regards<br><br>Sebastian Aslund<br><br><br>
<br>_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
<a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Ugo Cupcic | Shadow Robot Company | <a href="mailto:ugo@shadowrobot.com" target="_blank">ugo@shadowrobot.com</a> <br>Software Engineer | 251 Liverpool Road | <br>need a Hand? | London N1 1LX | +44 20 7700 2487 <br>
<a href="http://www.shadowrobot.com/hand/" target="_blank">http://www.shadowrobot.com/hand/</a> @shadowrobot <br><br>