Triclops SDK Function Breaks ros::NodeHandle
Hello everyone,
I have a problem incorporating Point Grey Research's Triclops SDK into ROS. I've created a simple test ROS package that illustrates this problem based on the simple C++ publisher shown in the following tutorial: http://wiki.ros.org/ROS/Tutorials/Wri... . Here is the code:
#include "ros/ros.h"
#include "std_msgs/String.h"
#include "triclops.h"
#include <sstream>
/**
* Function to handle error checking for the Triclops SDK
*/
void triclopsErrorHandler(const char* function_name, TriclopsError te) {
if(te != TriclopsErrorOk) {
std::cout << "TRICLOPS_ERROR: " << function_name << " reported " << triclopsErrorToString(te) << "." << std::endl;
exit(1);
}
}
/**
* This tutorial demonstrates simple sending of messages over the ROS system.
*/
int main(int argc, char **argv)
{
ros::init(argc, argv, "talker");
ros::NodeHandle n;
ros::Publisher chatter_pub = n.advertise<std_msgs::string>("chatter", 1000);
ros::Rate loop_rate(10);
int count = 0;
TriclopsContext shortContext;
TriclopsError te;
// THE FOLLOWING LINE BREAKS ROS UNLESS IT'S COMMENTED OUT
te = triclopsGetDefaultContextFromFile(&shortContext, "../short.cal");
triclopsErrorHandler("triclopsGetDefaultContextFromFile", te);
while (ros::ok())
{
std_msgs::String msg;
std::stringstream ss;
ss << "hello world " << count;
msg.data = ss.str();
ROS_INFO("%s", msg.data.c_str());
chatter_pub.publish(msg);
ros::spinOnce();
loop_rate.sleep();
++count;
}
return 0;
}
Whenever the following line:
> te = triclopsGetDefaultContextFromFile(&shortContext, "../short.cal");
is NOT commented, I get the following segfault in gdb:
$ gdb ./bin/testTriclops
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http: gnu.org="" gpl.html="" licenses="">
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http: bugs.launchpad.net="" gdb-linaro="">...
Reading symbols from /home/andrew-am3p/fuerte_workspace/sandbox/testTriclops/bin/testTriclops...done.
(gdb) run
Starting program: /home/andrew-am3p/fuerte_workspace/sandbox/testTriclops/bin/testTriclops
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
testTriclops: malloc.c:2451: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long) ((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Program received signal SIGABRT, Aborted.
0xb7fdd424 in __kernel_vsyscall ()
(gdb) bt
#0 0xb7fdd424 in __kernel_vsyscall ()
#1 0xb7b5f1df in raise () from /lib/i386-linux-gnu/libc.so.6
#2 0xb7b62825 in abort () from /lib/i386-linux-gnu/libc.so.6
#3 0xb7ba6469 in ?? () from /lib/i386-linux-gnu/libc.so.6
#4 0xb7ba9293 in ?? () from /lib/i386-linux-gnu/libc.so.6
#5 0xb7baadec in malloc () from /lib/i386-linux-gnu/libc.so.6
#6 0xb7deb627 in operator new(unsigned int) () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#7 0xb7f92124 in ros::initInternalTimerManager() () from /opt/ros/fuerte/lib/libroscpp.so
#8 0xb7f74e65 in ros::start() () from /opt/ros/fuerte/lib/libroscpp.so ...
I seem to recall this is because PointGrey statically links in some libraries that ROS also uses, and you get all sorts of bizarre symbol conflicts. It's been a while since I have looked at this, though.
the point grey triclops library is a static library (triclops.a) so this makes sense...in the cmake I had to put link_libraries(triclops) so that the triclops libraries were linked first and so ROS didn't depend on it. Would this have prevented the issue you're talking about?