Assertion Failed when trying to publish on a ROS topic
Hello there,
I'm building a generic bridge from YARP to ROS and I'm facing a little issue when dealing with the ROS->YARP side of the bridge. I basically launch two std::thread, and each thread either writes or read data using a POSIX pipe. The issue is that I'm getting a pretty weird error when trying to initialize the ROS node inside the "writing" thread. My program goes something like this :
bool FRBridge::run()
{
std::thread tWrite(&FRBridge::writeData,this);
std::thread tRead(&FRBridge::readRosData,this);
tWrite.join();
tRead.join();
return true;
}
bool FRImageBridge::writeData()
{
close(fd[P_READ]);
if ( (fromRosPipe = fdopen(fd[P_WRITE],"w")) == NULL )
{
cerr << "Fdopen (Write)" << endl;
return false;
}
int argc = 0;
char **argv = NULL;
ros::init(argc,argv,"rossender");
ros::NodeHandle n; // Program gets stuck here
ros::Subscriber sub = n.subscribe(topicName, 10, &FRImageBridge::imageCallback,this);
ros::spin();
return true;
}
I have just kept the important info, please disregard the fact that the function called by a thread is from a child class. At run-time, I get this :
[FATAL] [1371562311.637421310]: ASSERTION FAILED file = /tmp/buildd/ros-groovy-roscpp-1.9.44-0precise-20130325-1240/src/libros/xmlrpc_manager.cpp line = 133 cond = bound
followed by a SIGABRT... Can I not initialize a ROS node after the beginning of the program ? I get some debugging output before
ros::NodeHandle n;
but not after...
Thanks a lot for your help !