@@ -143,11 +143,11 @@ namespace dynamicgraph
143
143
sotNOSIGNAL,
144
144
MAKE_SIGNAL_STRING(name, true , " int" , " trigger" )),
145
145
rate_ (ROS_JOINT_STATE_PUBLISHER_RATE),
146
- lastPublicated_ ()
146
+ nextPublication_ ()
147
147
{
148
148
149
149
try {
150
- lastPublicated_ = ros::Time::now ();
150
+ nextPublication_ = ros::Time::now ();
151
151
} catch (const std::exception& exc) {
152
152
throw std::runtime_error (" Failed to call ros::Time::now ():" +
153
153
std::string (exc.what ()));
@@ -220,7 +220,6 @@ namespace dynamicgraph
220
220
}
221
221
222
222
// lock the mutex to avoid deleting the signal during a call to trigger
223
- while (! mutex_.try_lock () ){}
224
223
signalDeregistration (signal);
225
224
bindedSignal_.erase (signal);
226
225
mutex_.unlock ();
@@ -258,11 +257,10 @@ namespace dynamicgraph
258
257
{
259
258
typedef std::map<std::string, bindedSignal_t>::iterator iterator_t ;
260
259
261
- ros::Duration dt = ros::Time::now () - lastPublicated_;
262
- if (dt < rate_)
260
+ if (ros::Time::now () <= nextPublication_)
263
261
return dummy;
264
262
265
- lastPublicated_ = ros::Time::now ();
263
+ nextPublication_ = ros::Time::now () + rate_ ;
266
264
267
265
while (! mutex_.try_lock () ){}
268
266
for (iterator_t it = bindedSignal_.begin ();
0 commit comments