12 #include <ros/service_client.h>
15 namespace nimbro_utils
38 markerTime = ros::Time::now();
42 double getElapsed()
const {
return (iHaveMarker ? (ros::Time::now() - markerTime).toSec() : -1.0); }
43 bool hasElapsed(
double duration)
const {
return !iHaveMarker || (iHaveMarker && ((ros::Time::now() - markerTime).toSec() >= duration)); }
73 markerTime =
new ros::Time[N];
74 iHaveMarker =
new bool[N];
77 for(std::size_t i = 0;i < N;i++)
79 markerTime[i].fromSec(0);
80 iHaveMarker[i] =
false;
97 if(m < N) iHaveMarker[m] =
false;
105 markerTime[m] = ros::Time::now();
106 iHaveMarker[m] =
true;
110 bool haveMarker(std::size_t m)
const {
return (m < N ? iHaveMarker[m] :
false); }
115 if(m < N)
return (iHaveMarker[m] ? (ros::Time::now() - markerTime[m]).toSec() : -1.0);
122 if(m < N)
return !iHaveMarker[m] || (iHaveMarker[m] && ((ros::Time::now() - markerTime[m]).toSec() >= duration));
128 ros::Time* markerTime;
180 : failRetryDelay(failRetryDelay)
181 , reissueDelay(reissueDelay)
199 ret = m_srv.call<T>(srv_data);
214 const double failRetryDelay;
215 const double reissueDelay;
216 ros::ServiceClient m_srv;
bool callService()
Call the required service with the request data stored in the data class member.
Definition: ros_timing.h:189
bool callService(T &srv_data)
Call the required service with the request data stored in srv_data.
Definition: ros_timing.h:191
RosTimeTracker(std::size_t N)
Default constructor.
Definition: ros_timing.h:67
double getElapsed() const
Returns the current elapsed time since the marker was set (returns -1.0 if no marker has been set - c...
Definition: ros_timing.h:42
bool hasElapsed(double duration) const
Returns whether a certain time duration has elapsed since the time marker was set (returns true if no...
Definition: ros_timing.h:43
void setMarker()
Set the time marker to the current ROS time (future calls to getElapsed() and hasElapsed() will be ev...
Definition: ros_timing.h:35
Class that facilitates the timing of multiple durations using ROS-time.
Definition: ros_timing.h:63
Provides basic functionality for controlling calls to ROS services.
Definition: ros_timing.h:170
void unsetMarker()
Forget any time marker that may have been set previously.
Definition: ros_timing.h:34
Class that facilitates the timing of durations using ROS-time.
Definition: ros_timing.h:27
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...
Definition: ros_timing.h:100
T data
Request variable (can choose to use this instead of providing your own in the calling scope of callSe...
Definition: ros_timing.h:210
virtual ~RosTimeTracker()
Object destructor.
Definition: ros_timing.h:85
void unsetMarker(std::size_t m)
Forget the m-th time marker if one is currently set.
Definition: ros_timing.h:94
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 no...
Definition: ros_timing.h:112
bool haveMarker(std::size_t m) const
Returns whether the m-th marker is currently set.
Definition: ros_timing.h:110
RosServiceCaller(double reissueDelay, double failRetryDelay)
Default constructor.
Definition: ros_timing.h:179
void setServiceClient(const ros::ServiceClient &SC)
Set function for the ROS ServiceClient used by this RosServiceCaller
Definition: ros_timing.h:185
RosTimeMarker()
Default constructor.
Definition: ros_timing.h:31
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 ...
Definition: ros_timing.h:119
bool haveMarker() const
Returns whether a marker is currently set.
Definition: ros_timing.h:41