YARP
Yet Another Robot Platform
Time.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2021 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, const std::string& localPortName = "");
82 
93 YARP_os_API void useCustomClock(Clock* clock);
94 
99 
104 
109 
114 
119 
125 
131 YARP_os_API bool isValid();
132 
133 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
143 YARP_DEPRECATED
144 YARP_os_API void turboBoost();
145 #endif
146 
147 } // namespace Time
148 } // namespace os
149 } // namespace yarp
150 
151 #endif // YARP_OS_TIME_H
yarp::rosmsg::std_msgs::Time Time
Definition: Time.h:24
yarpClockType getClockType()
Definition: Time.cpp:280
bool isNetworkClock()
Check if YARP is providing network time.
Definition: Time.cpp:270
void useSystemClock()
Configure YARP to use system time (this is the default).
Definition: Time.cpp:147
bool isClockInitialized()
Check if YARP clock is initialized.
Definition: Time.cpp:260
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:317
void yield()
The calling thread releases its remaining quantum upon calling this function.
Definition: Time.cpp:141
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:124
void useNetworkClock(const std::string &clock, const std::string &localPortName="")
Configure YARP to read time from a specified topic.
Definition: Time.cpp:187
void delay(double seconds)
Wait for a certain number of seconds.
Definition: Time.cpp:114
void useCustomClock(Clock *clock)
Configure YARP clients to use a custom clock source provided by the user.
Definition: Time.cpp:230
bool isCustomClock()
Check if YARP is using a user-defined custom time.
Definition: Time.cpp:275
bool isSystemClock()
Check if YARP is providing system time.
Definition: Time.cpp:265
void turboBoost()
For OS where it makes sense sets the scheduler to be called more often.
Definition: Time.cpp:135
std::string clockTypeToString(yarpClockType type)
Converts clock type enum into string.
Definition: Time.cpp:285
ShouldUseSystemClock
Definition: Time.h:23
yarpClockType
Definition: Time.h:29
@ YARP_CLOCK_UNINITIALIZED
Definition: Time.h:30
@ YARP_CLOCK_CUSTOM
Definition: Time.h:34
@ YARP_CLOCK_SYSTEM
Definition: Time.h:32
@ YARP_CLOCK_NETWORK
Definition: Time.h:33
@ YARP_CLOCK_DEFAULT
Definition: Time.h:31
The main, catch-all namespace for YARP.
Definition: environment.h:25
#define YARP_os_API
Definition: api.h:19