@@ -143,11 +143,11 @@ namespace dynamicgraph
143143 sotNOSIGNAL,
144144 MAKE_SIGNAL_STRING(name, true , " int" , " trigger" )),
145145 rate_ (ROS_JOINT_STATE_PUBLISHER_RATE),
146- lastPublicated_ ()
146+ nextPublication_ ()
147147 {
148148
149149 try {
150- lastPublicated_ = ros::Time::now ();
150+ nextPublication_ = ros::Time::now ();
151151 } catch (const std::exception& exc) {
152152 throw std::runtime_error (" Failed to call ros::Time::now ():" +
153153 std::string (exc.what ()));
@@ -220,7 +220,6 @@ namespace dynamicgraph
220220 }
221221
222222 // lock the mutex to avoid deleting the signal during a call to trigger
223- while (! mutex_.try_lock () ){}
224223 signalDeregistration (signal);
225224 bindedSignal_.erase (signal);
226225 mutex_.unlock ();
@@ -258,11 +257,10 @@ namespace dynamicgraph
258257 {
259258 typedef std::map<std::string, bindedSignal_t>::iterator iterator_t ;
260259
261- ros::Duration dt = ros::Time::now () - lastPublicated_;
262- if (dt < rate_)
260+ if (ros::Time::now () <= nextPublication_)
263261 return dummy;
264262
265- lastPublicated_ = ros::Time::now ();
263+ nextPublication_ = ros::Time::now () + rate_ ;
266264
267265 while (! mutex_.try_lock () ){}
268266 for (iterator_t it = bindedSignal_.begin ();
0 commit comments