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/SystemClock.h>
15 #include <yarp/os/NetworkClock.h>
16 
17 #include <string>
18 
19 namespace yarp {
20 namespace os {
21 
22 enum class ShouldUseSystemClock { No = 0, Yes = 1 };
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, std::string localPortName="");
78 
89 YARP_OS_API void useCustomClock(Clock *clock);
90 
95 
100 
105 
110 
116 
122 YARP_OS_API bool isValid();
123 
124 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
125 
135 YARP_OS_API void turboBoost();
136 #endif
137 
138 } // namespace Time
139 } // namespace os
140 } // namespace yarp
141 
142 #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:2829
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:24
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