SMACC
Loading...
Searching...
No Matches
smacc_updatable.cpp
Go to the documentation of this file.
2
3namespace smacc
4{
5
7 : lastUpdate_(0)
8{
9}
10
11ISmaccUpdatable::ISmaccUpdatable(ros::Duration duration)
12 : lastUpdate_(0),
13 periodDuration_(duration)
14{
15}
16
17void ISmaccUpdatable::setUpdatePeriod(ros::Duration duration)
18{
19 periodDuration_ = duration;
20}
21
23{
24 bool update = true;
26 {
27 auto now = ros::Time::now();
28 auto elapsed = now - this->lastUpdate_;
29 update = elapsed > *periodDuration_;
30 if(update)
31 {
32 this->lastUpdate_ = now;
33 }
34 }
35
36 if (update)
37 {
38 this->update();
39 }
40}
41}
virtual void update()=0
void setUpdatePeriod(ros::Duration duration)
boost::optional< ros::Duration > periodDuration_