NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nimbro_utils::RosTimeTracker Class Reference

Class that facilitates the timing of multiple durations using ROS-time. More...

#include <ros_timing.h>

Public Member Functions

 RosTimeTracker (std::size_t N)
 Default constructor.
 
virtual ~RosTimeTracker ()
 Object destructor.
 
void unsetMarker (std::size_t m)
 Forget the m-th time marker if one is currently set.
 
void setMarker (std::size_t m)
 Set the m-th time marker to the current ROS time (future calls to getElapsed(m) and hasElapsed(m,T) will be evaluated relative to this marker)
 
bool haveMarker (std::size_t m) const
 Returns whether the m-th marker is currently set.
 
double getElapsed (std::size_t m) const
 Returns the current elapsed time since the m-th marker was set (returns -1.0 if the m-th marker is not set - check this if you must as getElapsed(m) < 0.0)
 
bool hasElapsed (std::size_t m, double duration) const
 Returns whether a certain time duration has elapsed since the m-th time marker was set (returns true if no m-th marker has been set)
 

Detailed Description

Class that facilitates the timing of multiple durations using ROS-time.

If the value N is passed to the constructor, then the valid index range for the time markers (i.e. argument m in all the functions) is 0 to N-1. To use a RosTimeTracker you simply need to instantiate one with its default constructor (e.g. simply add it as a member of your class and provide N in the class initialiser list). Then you can go straight to checking hasElapsed(m,T) for example, which until you actually set the marker will always return true and allow your action(s) to happen.


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