[ros-users] Nodelets

Tully Foote tfoote at willowgarage.com
Sun Dec 5 08:31:22 UTC 2010


Hi Nick,
Replies below.

On Sat, Dec 4, 2010 at 3:24 PM, Nicholas Butko <nbutko at ucsd.edu> wrote:

>
> On Dec 3, 2010, at 6:36 PM, Radu Bogdan Rusu wrote:
>
> >
> > On 12/02/2010 01:54 PM, Patrick Bouffard wrote:
> >> Cool. One way to go would be a tutorial on how to transform a node
> >> into a nodelet. It seems to be a fairly simple recipe, modulo the
> >> blocking and threading stuff:
> >> - add the necessary #includes
> >> - get rid of int main()
> >> - subclass nodelet::Nodelet
> >> - move code from constructor to onInit()
> >> - add the PLUGINLIB_DECLARE_CLASS macro
> >> - add the<nodelet>  item in the<export>  part of the package manifest
> >> - create the .xml file to define the nodelet as a plugin
> >> - make the necessary changes to CMakeLists.txt (comment out a
> >> rosbuild_add_executable, add a rosbuild_add_library)
> >
> > Great, I added this as a starting point to
> http://www.ros.org/wiki/nodelet/Tutorials/Porting%20nodes%20to%20nodelets.
> > Can we all please fill in the page when we get a chance with more
> content?
>
> Is there a nodelet equivalent of a "while (ros::ok()) {}" loop?
>

Nodelet's do not have a main thread, and currently do not have a voluntary
shutdown method.  They will run until destructed on unload.  This is
ticketed for an enhancement https://code.ros.org/trac/ros-pkg/ticket/4431


>
> I am trying to move some computer vision code to nodelets. The idea is to
> have one camera nodelet serving frames, and everybody else grabbing and
> processing them.
>

That is one of the goals of the nodelet design.  You can see my other
ros-users post about how to add an nodelet::Loader class to your node and
then you can just load into that manager.
http://code.ros.org/lurker/message/20101205.074703.0991b0ae.en.html


>
> From the "nodelet" examples, it looks like all work is typically done in
> onInit() and in subscriber callbacks.


onInit is not supposed to block and will cause problems if it does.

So, to implement a camera server, I'd either have to never finish
> initializing (is this okay?) or to set up an extra node that sends "wakeup"
> messages every 30 ms or so, and grab frames in the callback.
>
> Is there a way to set up a "callMeEvery30MS" callback function in a
> nodelet? Or even a "callAndLetMeRunForeverWhileOtherThreadsDoTheirThing()"
> callback function that could then run an infinite loop?
>

If you want periodic operations.  The ros::Timer object will give you
periodic callbacks.
http://www.ros.org/doc/api/roscpp/html/classros_1_1Timer.html

Tully
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20101205/9786be70/attachment-0003.html>


More information about the ros-users mailing list