[ros-users] Non-blocking version of ros::init()?
Ruben Smits
ruben.smits at mech.kuleuven.be
Sun Sep 12 12:59:50 UTC 2010
On Saturday 11 September 2010 20:03:48 Josh Faust wrote:
> init() shouldn't be blocking -- if it does it's a bug. It's designed this
> way so you can call ros::master::check(). Creation of the first
> NodeHandle or calling start() should be what's blocking.
Ok, sorry for the mistake, it was indeed ros::start() that blocked my code. I
changed it into the following:
bool loadRTTPlugin(RTT::TaskContext* c){
log(Info)<<"Initializing ROS node"<<endlog();
if(!ros::isInitialized()){
int argc=0;
char* argv[0];
ros::init(argc,argv,"rtt",ros::init_options::AnonymousName);
if(ros::master::check())
ros::start();
else{
log(Error)<<"No ros::master available"<<endlog();
return false;
}
}
static ros::AsyncSpinner spinner(1); // Use 1 threads
spinner.start();
log(Info)<<"ROS node spinner started"<<endlog();
return true;
}
But now I get the the following assertion:
0.719 [ ERROR ][DeploymentComponent::import] No ros::master available
0.719 [ ERROR ][DeploymentComponent::import] Failed to load RTT Plugin
'ros_integration': plugin refused to load into this process. Unloading.
deployer-gnulinux: /usr/include/boost/thread/pthread/mutex.hpp:50: void
boost::mutex::lock(): Assertion `!pthread_mutex_lock(&m)' failed.
Program received signal SIGABRT, Aborted.
0x00007ffff4caca75 in *__GI_raise (sig=<value optimized out>)
at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
in ../nptl/sysdeps/unix/sysv/linux/raise.c
(gdb) bt
#0 0x00007ffff4caca75 in *__GI_raise (sig=<value optimized out>)
at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007ffff4cb05c0 in *__GI_abort () at abort.c:92
#2 0x00007ffff4ca5941 in *__GI___assert_fail (
assertion=0x7ffff124f7e5 "!pthread_mutex_lock(&m)",
file=<value optimized out>, line=50,
function=0x7ffff124f9a0 "void boost::mutex::lock()") at assert.c:81
#3 0x00007ffff12453db in boost::mutex::lock (loc=0x7ffff1beea20,
name=..., level=ros::console::levels::Debug)
at /usr/include/boost/thread/pthread/mutex.hpp:50
#4 boost::unique_lock<boost::mutex>::lock (loc=0x7ffff1beea20, name=...,
level=ros::console::levels::Debug)
at /usr/include/boost/thread/locks.hpp:338
#5 unique_lock (loc=0x7ffff1beea20, name=...,
level=ros::console::levels::Debug)
at /usr/include/boost/thread/locks.hpp:224
#6 ros::console::initializeLogLocation (loc=0x7ffff1beea20, name=...,
level=ros::console::levels::Debug)
at /opt/ros/cturtle/ros/core/rosconsole/src/rosconsole/rosconsole.cpp:6---
Type <return> to continue, or q <return> to quit---
10
#7 0x00007ffff1923e4a in ros::atexitCallback ()
at /opt/ros/cturtle/ros/core/roscpp/src/libros/init.cpp:149
#8 0x00007ffff4cb2630 in __cxa_finalize (d=0x7ffff1bee000)
at cxa_finalize.c:56
#9 0x00007ffff18f23d6 in __do_global_dtors_aux ()
from /opt/ros/cturtle/ros/core/roscpp/lib/libros.so
#10 0x0000000000000015 in ?? ()
#11 0x00007fffffffc8d0 in ?? ()
#12 0x00007ffff19abc81 in _fini ()
from /opt/ros/cturtle/ros/core/roscpp/lib/libros.so
#13 0x0000000000000032 in ?? ()
#14 0x00007ffff7df0972 in _dl_close_worker (map=<value optimized out>)
at dl-close.c:271
#15 0x0000000000680f80 in ?? ()
Another question:
Would it be possible to start my own master if none is available? Can it be
done using ros::master::init()?
Ruben
> Josh
>
> On Sat, Sep 11, 2010 at 7:53 AM, Ruben Smits
> <ruben.smits at mech.kuleuven.be<mailto:ruben.smits at mech.kuleuven.be>> wrote:
> Hi,
>
> I would like to know if there is a way to call ros::init and not block
> untill a ros::master is available but just return an error or the like if
> a ros::master is not available so that my code can continue.
>
> Ruben
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org<mailto:ros-users at code.ros.org>
> https://code.ros.org/mailman/listinfo/ros-users
More information about the ros-users
mailing list