YARP
Yet Another Robot Platform
yarp::os::Time Namespace Reference

Functions

void delay (double seconds)
 Wait for a certain number of seconds. More...
 
double now ()
 Return the current time in seconds, relative to an arbitrary starting point. More...
 
void yield ()
 The calling thread releases its remaining quantum upon calling this function. More...
 
void useSystemClock ()
 Configure YARP to use system time (this is the default). More...
 
void useNetworkClock (const std::string &clock, const std::string &localPortName="")
 Configure YARP to read time from a specified topic. More...
 
void useCustomClock (Clock *clock)
 Configure YARP clients to use a custom clock source provided by the user. More...
 
bool isClockInitialized ()
 Check if YARP clock is initialized. More...
 
bool isSystemClock ()
 Check if YARP is providing system time. More...
 
bool isNetworkClock ()
 Check if YARP is providing network time. More...
 
bool isCustomClock ()
 Check if YARP is using a user-defined custom time. More...
 
yarpClockType getClockType ()
 
std::string clockTypeToString (yarpClockType type)
 Converts clock type enum into string. More...
 
bool isValid ()
 Check if time is valid (non-zero). More...
 
void turboBoost ()
 For OS where it makes sense sets the scheduler to be called more often. More...
 

Function Documentation

◆ clockTypeToString()

std::string yarp::os::Time::clockTypeToString ( yarpClockType  type)

Converts clock type enum into string.

Parameters
typeConvert specified enum into string.

Definition at line 285 of file Time.cpp.

◆ delay()

◆ getClockType()

yarpClockType yarp::os::Time::getClockType ( )
Returns
enum type with the current clock type used

Definition at line 280 of file Time.cpp.

◆ isClockInitialized()

bool yarp::os::Time::isClockInitialized ( )

Check if YARP clock is initialized.

Definition at line 260 of file Time.cpp.

◆ isCustomClock()

bool yarp::os::Time::isCustomClock ( )

Check if YARP is using a user-defined custom time.

Definition at line 275 of file Time.cpp.

◆ isNetworkClock()

bool yarp::os::Time::isNetworkClock ( )

Check if YARP is providing network time.

Definition at line 270 of file Time.cpp.

◆ isSystemClock()

bool yarp::os::Time::isSystemClock ( )

Check if YARP is providing system time.

Definition at line 265 of file Time.cpp.

◆ isValid()

bool yarp::os::Time::isValid ( )

Check if time is valid (non-zero).

If a network clock is in use and no timestamp has yet been received, this method will return false.

Definition at line 317 of file Time.cpp.

◆ now()

double yarp::os::Time::now ( )

Return the current time in seconds, relative to an arbitrary starting point.

Returns
the time in seconds
Examples
framerate/main.cpp.

Definition at line 124 of file Time.cpp.

◆ turboBoost()

void yarp::os::Time::turboBoost ( )

For OS where it makes sense sets the scheduler to be called more often.

This sets the scheduler to be run to the maximum possible rate based on the capability of the hardware. Specifically, on Microsoft Windows, high resolution scheduling is used.

Deprecated:
Since YARP 3.0.0

Definition at line 135 of file Time.cpp.

◆ useCustomClock()

void yarp::os::Time::useCustomClock ( Clock clock)

Configure YARP clients to use a custom clock source provided by the user.

The Clock source must implement the yarp::os::Clock interface. This function check clock->isValid() to verify the source is working properly.

Possible causes of failure are: clock pointer invalid or isValid() false.

Throws assert in case of failure

Definition at line 230 of file Time.cpp.

◆ useNetworkClock()

void yarp::os::Time::useNetworkClock ( const std::string &  clock,
const std::string &  localPortName = "" 
)

Configure YARP to read time from a specified topic.

The same effect can also be achieved using the YARP_CLOCK environment variable. Topic should provide two integers, time in seconds followed by residual in nanoseconds. If yarp is configured according to Using YARP with ROS, then ROS /clock topic will work.

See also
yarp::os::NetworkClock

return true on success, false on failure. Possible causes of failure are invalid port name or address conflict.

Throws assert in case of failure

Definition at line 187 of file Time.cpp.

◆ useSystemClock()

void yarp::os::Time::useSystemClock ( )

Configure YARP to use system time (this is the default).

Definition at line 147 of file Time.cpp.

◆ yield()

void yarp::os::Time::yield ( )

The calling thread releases its remaining quantum upon calling this function.

Definition at line 141 of file Time.cpp.