diff --git a/src/ros_publish.cpp b/src/ros_publish.cpp index cef0afa558f642d92c8d0c98d84d03ff6a6766cd..3bcf22b8cd0d918ec41bd18e456745d934c31229 100644 --- a/src/ros_publish.cpp +++ b/src/ros_publish.cpp @@ -206,10 +206,16 @@ namespace dynamicgraph if(bindedSignal_.find(signal) == bindedSignal_.end()) return; + if(signal == "trigger") + { + std::cerr << "The trigger signal should not be removed. Aborting." << std::endl; + return; + } + //lock the mutex to avoid deleting the signal during a call to trigger while(! mutex_.try_lock() ){} - bindedSignal_.erase (signal); signalDeregistration(signal); + bindedSignal_.erase (signal); mutex_.unlock(); } @@ -226,7 +232,19 @@ namespace dynamicgraph void RosPublish::clear () { - bindedSignal_.clear (); + std::map<std::string, bindedSignal_t>::iterator it = bindedSignal_.begin(); + for(; it!= bindedSignal_.end(); ) + { + if (it->first != "trigger") + { + rm(it->first); + it = bindedSignal_.begin(); + } + else + { + ++it; + } + } } int& RosPublish::trigger (int& dummy, int t)