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::os {
17 
19 {
20  No = 0,
21  Yes = 1
22 };
23 
25 {
31 };
32 
33 /*
34  * Services related to time -- delay, current time.
35  */
36 namespace Time {
37 
42 YARP_os_API void delay(double seconds);
43 
49 YARP_os_API double now();
50 
55 YARP_os_API void yield();
56 
61 
77 YARP_os_API void useNetworkClock(const std::string& clock, const std::string& localPortName = "");
78 
89 YARP_os_API void useCustomClock(Clock* clock);
90 
95 
100 
105 
110 
115 
121 
127 YARP_os_API bool isValid();
128 
129 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
139 YARP_DEPRECATED
140 YARP_os_API void turboBoost();
141 #endif
142 
143 } // namespace Time
144 } // namespace yarp::os
145 
146 #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
An interface to the operating system, including Port based communication.
ShouldUseSystemClock
Definition: Time.h:19
yarpClockType
Definition: Time.h:25
@ YARP_CLOCK_UNINITIALIZED
Definition: Time.h:26
@ YARP_CLOCK_CUSTOM
Definition: Time.h:30
@ YARP_CLOCK_SYSTEM
Definition: Time.h:28
@ YARP_CLOCK_NETWORK
Definition: Time.h:29
@ YARP_CLOCK_DEFAULT
Definition: Time.h:27
#define YARP_os_API
Definition: api.h:18