YARP
Yet Another Robot Platform
Time.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_OS_TIME_H
8 #define YARP_OS_TIME_H
9 
10 #include <yarp/os/Clock.h>
11 #include <yarp/os/NetworkClock.h>
12 #include <yarp/os/SystemClock.h>
13 
14 #include <string>
15 
16 namespace yarp {
17 namespace os {
18 
20 {
21  No = 0,
22  Yes = 1
23 };
24 
26 {
32 };
33 
34 /*
35  * Services related to time -- delay, current time.
36  */
37 namespace Time {
38 
43 YARP_os_API void delay(double seconds);
44 
50 YARP_os_API double now();
51 
56 YARP_os_API void yield();
57 
62 
78 YARP_os_API void useNetworkClock(const std::string& clock, const std::string& localPortName = "");
79 
90 YARP_os_API void useCustomClock(Clock* clock);
91 
96 
101 
106 
111 
116 
122 
128 YARP_os_API bool isValid();
129 
130 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
140 YARP_DEPRECATED
141 YARP_os_API void turboBoost();
142 #endif
143 
144 } // namespace Time
145 } // namespace os
146 } // namespace yarp
147 
148 #endif // YARP_OS_TIME_H
yarp::rosmsg::std_msgs::Time Time
Definition: Time.h:21
yarpClockType getClockType()
Definition: Time.cpp:277
bool isNetworkClock()
Check if YARP is providing network time.
Definition: Time.cpp:267
void useSystemClock()
Configure YARP to use system time (this is the default).
Definition: Time.cpp:144
bool isClockInitialized()
Check if YARP clock is initialized.
Definition: Time.cpp:257
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:314
void yield()
The calling thread releases its remaining quantum upon calling this function.
Definition: Time.cpp:138
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:121
void useNetworkClock(const std::string &clock, const std::string &localPortName="")
Configure YARP to read time from a specified topic.
Definition: Time.cpp:184
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:227
bool isCustomClock()
Check if YARP is using a user-defined custom time.
Definition: Time.cpp:272
bool isSystemClock()
Check if YARP is providing system time.
Definition: Time.cpp:262
void turboBoost()
For OS where it makes sense sets the scheduler to be called more often.
Definition: Time.cpp:132
std::string clockTypeToString(yarpClockType type)
Converts clock type enum into string.
Definition: Time.cpp:282
ShouldUseSystemClock
Definition: Time.h:20
yarpClockType
Definition: Time.h:26
@ YARP_CLOCK_UNINITIALIZED
Definition: Time.h:27
@ YARP_CLOCK_CUSTOM
Definition: Time.h:31
@ YARP_CLOCK_SYSTEM
Definition: Time.h:29
@ YARP_CLOCK_NETWORK
Definition: Time.h:30
@ YARP_CLOCK_DEFAULT
Definition: Time.h:28
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_os_API
Definition: api.h:18