YARP
Yet Another Robot Platform
Time.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_TIME_H
11 #define YARP_OS_TIME_H
12 
13 #include <yarp/os/Clock.h>
14 #include <yarp/os/NetworkClock.h>
15 #include <yarp/os/SystemClock.h>
16 
17 #include <string>
18 
19 namespace yarp {
20 namespace os {
21 
23 {
24  No = 0,
25  Yes = 1
26 };
27 
29 {
35 };
36 
37 /*
38  * Services related to time -- delay, current time.
39  */
40 namespace Time {
41 
46 YARP_OS_API void delay(double seconds);
47 
53 YARP_OS_API double now();
54 
59 YARP_OS_API void yield();
60 
65 
81 YARP_OS_API void useNetworkClock(const std::string& clock, std::string localPortName = "");
82 
93 YARP_OS_API void useCustomClock(Clock* clock);
94 
99 
104 
109 
114 
120 
126 YARP_OS_API bool isValid();
127 
128 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
129 
139 YARP_OS_API void turboBoost();
140 #endif
141 
142 } // namespace Time
143 } // namespace os
144 } // namespace yarp
145 
146 #endif // YARP_OS_TIME_H
bool isNetworkClock()
Check if YARP is providing network time.
Definition: Time.cpp:263
#define YARP_OS_API
Definition: api.h:19
void useSystemClock()
Configure YARP to use system time (this is the default).
Definition: Time.cpp:139
ShouldUseSystemClock
Definition: Time.h:22
The main, catch-all namespace for YARP.
Definition: numeric.h:47
bool isCustomClock()
Check if YARP is using a user-defined custom time.
Definition: Time.cpp:267
void yield()
The calling thread releases its remaining quantum upon calling this function.
Definition: Time.cpp:134
#define YARP_DEPRECATED
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
Definition: compiler.h:2837
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:119
void useNetworkClock(const std::string &clock, std::string localPortName="")
Configure YARP to read time from a specified topic.
Definition: Time.cpp:179
yarp::rosmsg::std_msgs::Time Time
Definition: Time.h:24
void turboBoost()
For OS where it makes sense sets the scheduler to be called more often.
Definition: Time.cpp:128
yarpClockType
Definition: Time.h:28
yarpClockType getClockType()
Definition: Time.cpp:271
std::string clockTypeToString(yarpClockType type)
Converts clock type enum into string.
Definition: Time.cpp:276
void delay(double seconds)
Wait for a certain number of seconds.
Definition: Time.cpp:111
void useCustomClock(Clock *clock)
Configure YARP clients to use a custom clock source provided by the user.
Definition: Time.cpp:231
bool isSystemClock()
Check if YARP is providing system time.
Definition: Time.cpp:259
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:308