ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

nodelets what to take care of?

asked 2014-03-14 07:21:52 -0500

Wolf gravatar image

I have two classes, image publisher and image processor. Both classes start internal boost::threads for camera and sensor drivers, image processing worker threads. Both classes take long in their constructor, initializing cameras, sensor (RIIA -> image publisher), self calibration, initializing GPU (image processor).

Both run nice and smooth if they are in separate nodes, where the main just calls ros::init, creates a boost::shared_ptr with class instance, and then ros::spin()s:

int main( int argc, char** argv )
{
   ros::init( argc, argv, "name" )

   boost::shared_ptr<ImageProcessor> lp_proc = boost::shared_ptr<ImageProcessor>( new ImageProcessor()  );

   ros::spin();

   return 0;
}

Again everything runs nice and smooth in nodes. But both classes heavily interact (exchanging images at 100 Hz) so I'd like to put them in nodelets. I just added an boost::shared pointer to the inheriting class and create the instance in onInit() look like:

class MyNodeletClass : public nodelet::Nodelet
{
   private:
     boost::shared_ptr<ImageProcessor> lp_proc;
    public:
        virtual void onInit()
        {
            lp_proc = boost::shared_ptr<ImageProcessor>( new ImageProcessor() );
        }
};

However, if in a nodelet the nodes occasionally crash with memory corruptions, failed service calls, etc. Is there something to be very aware of when putting nodes in nodelets? Or maybe is there a timeout for the onInit until which a nodelet after loading has to get responsive? Might be a problem as my constructors occasionally take quite long?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-03-18 04:17:09 -0500

Wolf gravatar image

updated 2014-03-18 04:17:32 -0500

As expected: Was my own mistake! I had a race condition in the destructor of one of my classes. This occasionally caused the nodelet manager to crash on unload, thereby leaving some process residuals somewhere. On relaunch this residuals caused the nodelets to crash....

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-03-14 07:21:52 -0500

Seen: 549 times

Last updated: Mar 18 '14