[ros-users] Problems with subscriber and spinOnce
Ugo Cupcic
ugo at shadowrobot.com
Thu Feb 17 10:24:27 UTC 2011
Hi,
Your subscriber should be instantiated outside of your loop:
int main(int argc, char **argv)
{
init(argc, argv, "testPlayer");
NodeHandle n;
Subscriber sub;
sub = n.subscribe("scan", 1000, &testPlayer::callBack, &test);
Rate loop_rate(5);
testPlayer test;
while ( ok() ) {
spinOnce();
loop_rate.sleep();
}
return 0;
}
This should work normally.
Cheers,
Ugo
On Thu, Feb 17, 2011 at 10:20 AM, Aslund <sebastian.aslund at gmail.com> wrote:
> Hey everyone
>
> 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.
>
> My code is:
>
>
> Regards
>
> Sebastian Aslund
>
>
>
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
>
--
Ugo Cupcic | Shadow Robot Company | ugo at shadowrobot.com
Software Engineer | 251 Liverpool Road |
need a Hand? | London N1 1LX | +44 20 7700 2487
http://www.shadowrobot.com/hand/ @shadowrobot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20110217/6990c3cc/attachment-0003.html>
More information about the ros-users
mailing list