Classes | Namespaces | Functions
time_utils.hpp File Reference

Utilities for working with time. More...

#include <ctime>
#include <string>
#include <cras_cpp_common/expected.hpp>
#include <ros/duration.h>
#include <ros/rate.h>
#include <ros/time.h>
Include dependency graph for time_utils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  cras::DurationType< T, >
 
struct  cras::DurationType< ros::SteadyTime >
 
struct  cras::DurationType< ros::Time >
 
struct  cras::DurationType< ros::WallTime >
 

Namespaces

 cras
 
 ros
 

Functions

template<typename D1 , typename D2 , typename ::std::enable_if_t< ::std::is_same< D1, ::ros::Duration >::value||::std::is_same< D1, ::ros::WallDuration >::value > * = nullptr, typename ::std::enable_if_t< ::std::is_same< D2, ::ros::Duration >::value||::std::is_same< D2, ::ros::WallDuration >::value > * = nullptr>
D1 cras::convertDuration (const D2 &duration)
 
template<typename T1 , typename T2 , typename ::std::enable_if_t< ::std::is_same< T1, ::ros::Time >::value||::std::is_same< T1, ::ros::WallTime >::value||::std::is_same< T1, ::ros::SteadyTime >::value > * = nullptr, typename ::std::enable_if_t< ::std::is_same< T2, ::ros::Time >::value||::std::is_same< T2, ::ros::WallTime >::value||::std::is_same< T2, ::ros::SteadyTime >::value > * = nullptr>
T1 cras::convertTime (const T2 &time)
 
double cras::frequency (const ::ros::Rate &rate, bool maxCycleTimeMeansZero=false)
 Return the frequency represented by the given rate. More...
 
double cras::frequency (const ::ros::WallRate &rate, bool maxCycleTimeMeansZero=false)
 Return the frequency represented by the given rate. More...
 
::cras::expected<::ros::Time, ::std::string > cras::fromStructTm (const ::tm &time)
 
int cras::getYear (const ::ros::SteadyTime &time)
 Get the year represented by the given ROS time when interpreted as UTC time. More...
 
int cras::getYear (const ::ros::Time &time)
 Get the year represented by the given ROS time when interpreted as UTC time. More...
 
int cras::getYear (const ::ros::WallTime &time)
 Get the year represented by the given ROS time when interpreted as UTC time. More...
 
::ros::Time cras::nowFallbackToWall ()
 Return current ROS time if it has already been initialized, or current wall time. More...
 
::ros::Duration ros::operator* (const ::ros::Duration &val1, const ::ros::Duration &val2)
 Multiply two durations. The units of the result are [s^2]. More...
 
::ros::WallDuration ros::operator* (const ::ros::WallDuration &val1, const ::ros::WallDuration &val2)
 Multiply two durations. The units of the result are [s^2]. More...
 
::ros::Duration ros::operator/ (const ::ros::Duration &numerator, const ::ros::Duration &denominator)
 Divide duration val1 by val2. The result is unitless. More...
 
::ros::WallDuration ros::operator/ (const ::ros::WallDuration &numerator, const ::ros::WallDuration &denominator)
 Divide duration val1 by val2. The result is unitless. More...
 
bool ros::operator== (const ::ros::Rate &r1, const ::ros::Rate &r2)
 Test two rates for equality. More...
 
bool ros::operator== (const ::ros::WallRate &r1, const ::ros::WallRate &r2)
 Test two rates for equality. More...
 
::ros::Duration cras::remainingTime (const ::ros::Time &query, const ::ros::Duration &timeout)
 Return remaining time to timeout from the query time. More...
 
::ros::Duration cras::remainingTime (const ::ros::Time &query, double timeout)
 Return remaining time to timeout from the query time. More...
 
::ros::Rate cras::safeRate (double frequency)
 Return a rate representing the given frequency. If the frequency is zero or too small, return min/max representable rate. More...
 
::ros::WallRate cras::safeWallRate (double frequency)
 Return a rate representing the given frequency. If the frequency is zero or too small, return min/max representable rate. More...
 
::ros::SteadyTime cras::saturateAdd (const ::ros::SteadyTime &time, const ::ros::WallDuration &duration)
 Add the given duration to the given time, but saturate the result instead of throwing exception on overflow. More...
 
::ros::Time cras::saturateAdd (const ::ros::Time &time, const ::ros::Duration &duration)
 Add the given duration to the given time, but saturate the result instead of throwing exception on overflow. More...
 
::ros::WallTime cras::saturateAdd (const ::ros::WallTime &time, const ::ros::WallDuration &duration)
 Add the given duration to the given time, but saturate the result instead of throwing exception on overflow. More...
 
inline ::tm cras::toStructTm (const ::ros::SteadyTime &time)
 Convert the given ROS time to C tm struct representing UTC time. More...
 
::tm cras::toStructTm (const ::ros::Time &time)
 Convert the given ROS time to C tm struct representing UTC time. More...
 
inline ::tm cras::toStructTm (const ::ros::WallTime &time)
 Convert the given ROS time to C tm struct representing UTC time. More...
 

Detailed Description

Utilities for working with time.

Author
Martin Pecka SPDX-License-Identifier: BSD-3-Clause SPDX-FileCopyrightText: Czech Technical University in Prague

Definition in file time_utils.hpp.



cras_cpp_common
Author(s): Martin Pecka
autogenerated on Tue Nov 26 2024 03:49:04