Merge pull request #146 from ros2/fix_timer

Change behavior of timer on construction
This commit is contained in:
Jackie Kay 2015-11-06 09:29:06 -08:00
commit 361faf650d

View file

@ -97,9 +97,8 @@ public:
GenericTimer(std::chrono::nanoseconds period, CallbackType callback) GenericTimer(std::chrono::nanoseconds period, CallbackType callback)
: TimerBase(period, callback), loop_rate_(period) : TimerBase(period, callback), loop_rate_(period)
{ {
/* Subtracting the loop rate period ensures that the callback gets triggered /* Set last_triggered_time_ so that the timer fires at least one period after being created. */
on the first call to check_and_trigger. */ last_triggered_time_ = Clock::now();
last_triggered_time_ = Clock::now() - period;
} }
/// Default destructor. /// Default destructor.