nodelets what to take care of?
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?