YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
yarp::os::Time Namespace Reference

Functions

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

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 275 of file Time.cpp.

◆ delay()

void yarp::os::Time::delay ( double  seconds)

Wait for a certain number of seconds.

This may be fractional.

Parameters
secondsthe duration of the delay, in seconds
Examples
dev/motortest/motortest.cpp, os/make_count/make_count.cpp, os/periodicthread/periodicthread.cpp, os/portable_pair/portable_pair.cpp, os/simple_sender/simple_sender.cpp, and os/threads/threads.cpp.

Definition at line 111 of file Time.cpp.

◆ getClockType()

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

Definition at line 270 of file Time.cpp.

◆ isClockInitialized()

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

Check if YARP clock is initialized.

Definition at line 250 of file Time.cpp.

◆ isCustomClock()

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

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

Definition at line 265 of file Time.cpp.

◆ isNetworkClock()

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

Check if YARP is providing network time.

Definition at line 260 of file Time.cpp.

◆ isSystemClock()

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

Check if YARP is providing system time.

Definition at line 255 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 307 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

Definition at line 121 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 220 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 177 of file Time.cpp.

◆ useSystemClock()

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

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

Definition at line 137 of file Time.cpp.

◆ yield()

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

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

Definition at line 131 of file Time.cpp.