SMACC
Loading...
Searching...
No Matches
smacc
src
smacc
smacc_updatable.cpp
Go to the documentation of this file.
1
#include <
smacc/smacc_updatable.h
>
2
3
namespace
smacc
4
{
5
6
ISmaccUpdatable::ISmaccUpdatable
()
7
: lastUpdate_(0)
8
{
9
}
10
11
ISmaccUpdatable::ISmaccUpdatable
(ros::Duration duration)
12
: lastUpdate_(0),
13
periodDuration_(duration)
14
{
15
}
16
17
void
ISmaccUpdatable::setUpdatePeriod
(ros::Duration duration)
18
{
19
periodDuration_
= duration;
20
}
21
22
void
ISmaccUpdatable::executeUpdate
()
23
{
24
bool
update
=
true
;
25
if
(
periodDuration_
)
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
}
smacc::ISmaccUpdatable::ISmaccUpdatable
ISmaccUpdatable()
Definition:
smacc_updatable.cpp:6
smacc::ISmaccUpdatable::executeUpdate
void executeUpdate()
Definition:
smacc_updatable.cpp:22
smacc::ISmaccUpdatable::update
virtual void update()=0
smacc::ISmaccUpdatable::setUpdatePeriod
void setUpdatePeriod(ros::Duration duration)
Definition:
smacc_updatable.cpp:17
smacc::ISmaccUpdatable::periodDuration_
boost::optional< ros::Duration > periodDuration_
Definition:
smacc_updatable.h:28
smacc::ISmaccUpdatable::lastUpdate_
ros::Time lastUpdate_
Definition:
smacc_updatable.h:29
smacc
Definition:
callback_counter_semaphore.h:17
smacc_updatable.h
Generated by
1.9.5