SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
smacc2::ISmaccUpdatable Class Referenceabstract

#include <smacc_updatable.hpp>

Inheritance diagram for smacc2::ISmaccUpdatable:
Inheritance graph
Collaboration diagram for smacc2::ISmaccUpdatable:
Collaboration graph

Public Member Functions

 ISmaccUpdatable ()
 
 ISmaccUpdatable (rclcpp::Duration duration)
 
void executeUpdate (rclcpp::Node::SharedPtr node)
 
void setUpdatePeriod (rclcpp::Duration duration)
 

Protected Member Functions

virtual void update ()=0
 

Private Attributes

std::optional< rclcpp::Duration > periodDuration_
 
std::optional< rclcpp::Time > lastUpdate_
 

Detailed Description

Definition at line 32 of file smacc_updatable.hpp.

Constructor & Destructor Documentation

◆ ISmaccUpdatable() [1/2]

smacc2::ISmaccUpdatable::ISmaccUpdatable ( )

Definition at line 25 of file smacc_updatable.cpp.

25{}

◆ ISmaccUpdatable() [2/2]

smacc2::ISmaccUpdatable::ISmaccUpdatable ( rclcpp::Duration  duration)
explicit

Definition at line 27 of file smacc_updatable.cpp.

27: periodDuration_(duration) {}
std::optional< rclcpp::Duration > periodDuration_

Member Function Documentation

◆ executeUpdate()

void smacc2::ISmaccUpdatable::executeUpdate ( rclcpp::Node::SharedPtr  node)

Definition at line 31 of file smacc_updatable.cpp.

32{
33 bool triggerUpdateMethod = true;
35 {
36 auto now = node->get_clock()->now();
37
38 if (!lastUpdate_)
39 {
40 lastUpdate_ = now;
41 }
42
43 auto elapsed = now - *lastUpdate_;
44 triggerUpdateMethod = elapsed > *periodDuration_;
45 if (triggerUpdateMethod)
46 {
47 this->lastUpdate_ = now;
48 }
49 }
50
51 if (triggerUpdateMethod)
52 {
53 this->update();
54 }
55}
virtual void update()=0
std::optional< rclcpp::Time > lastUpdate_

References lastUpdate_, periodDuration_, and update().

Here is the call graph for this function:

◆ setUpdatePeriod()

void smacc2::ISmaccUpdatable::setUpdatePeriod ( rclcpp::Duration  duration)

Definition at line 29 of file smacc_updatable.cpp.

29{ periodDuration_ = duration; }

References periodDuration_.

◆ update()

virtual void smacc2::ISmaccUpdatable::update ( )
protectedpure virtual

Member Data Documentation

◆ lastUpdate_

std::optional<rclcpp::Time> smacc2::ISmaccUpdatable::lastUpdate_
private

Definition at line 46 of file smacc_updatable.hpp.

Referenced by executeUpdate().

◆ periodDuration_

std::optional<rclcpp::Duration> smacc2::ISmaccUpdatable::periodDuration_
private

Definition at line 45 of file smacc_updatable.hpp.

Referenced by executeUpdate(), and setUpdatePeriod().


The documentation for this class was generated from the following files: