[ros-users] questions about nodelets

Josh Faust jfaust at willowgarage.com
Tue Nov 9 19:18:17 UTC 2010


>
>
>  * Is it OK for onInit() to return when initialization finishes? That
> looks like the nodelet_tutorial_math example, which runs onInit()
> followed by callback invocations. (I assume "yes". My
> pointcoud_nodelet works the same way. )
>

onInit() is required to return


>
>  * Are the callbacks invoked in the nodelet thread (by default),
> similar to a node? (I assume "yes".)
>

This depend on which nodehandle you use.  The one returned by
get(Private)NodeHandle() guarantees that callbacks will not happen in
multiple threads at once, but the thread they're called from may be
different from call to call.

The one returned by getMT(Private)NodeHandle() allows callbacks in multiple
threads at the same time.


>
>  * Is there any special hook for shutting down a nodelet? I don't see
> anything like an onExit() method.
>

The destructor.


>
>  * Can a device driver run its entire main loop in the onInit() method
> using "while (ros::ok()) { ... }"?
>

No, onInit() needs to return.  If you need to do some kind of polling loop
you need to start your own thread.


>
>  * Is it OK that onInit() only returns when ros::ok() becomes false in
> that case?
>
>  * Does this loop need to call ros::spinOnce()? Even if it has no
> subscriptions?
>
>  * What happens if library classes used by both node and nodelet
> versions call ROS_INFO() or other ROS services? Are there things to
> avoid in those classes?
>

This is fine.

Josh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20101109/d0354fa1/attachment-0003.html>


More information about the ros-users mailing list