56 #ifndef _GAMS_POSE_STAMPED_H_ 57 #define _GAMS_POSE_STAMPED_H_ 64 #include "madara/knowledge/containers/DoubleVector.h" 65 #include "madara/knowledge/containers/NativeDoubleVector.h" 69 namespace gams {
namespace pose {
71 using madara::utility::Clock;
72 using madara::utility::TimeValue;
73 using madara::utility::Duration;
74 using madara::utility::SecondsDuration;
78 (x.time(), x.time(TimeValue{})));
85 template<
typename T,
typename... Args>
87 typename std::enable_if<supports_timestamp<T>::value, TimeValue>::type
92 template<
typename T,
typename... Args>
94 typename std::enable_if<!supports_timestamp<T>::value, TimeValue>::type
101 template<
typename Base>
125 template<
typename... Args>
128 template<
typename Arg,
typename... Args,
129 typename std::enable_if<!std::is_same<typename std::decay<Arg>::type,
130 TimeValue>::value &&
sizeof...(Args) >= 1,
void*>::type =
nullptr>
131 Stamped(Arg&& arg, Args&&... args)
132 :
Base((Arg &)arg, ((Args &)args)...),
135 template<
typename Arg,
136 typename std::enable_if<!std::is_same<typename std::decay<Arg>::type,
137 TimeValue>::value,
void*>::type =
nullptr>
157 template<
typename... Args>
160 template<
typename... Args,
161 typename std::enable_if<(
sizeof...(Args) >= 1),
void*>::type =
nullptr>
162 Stamped(TimeValue time, Args&&... args)
163 :
Base(std::forward<Args>(args)...),
time_(time) {}
175 namespace sc = std::chrono;
176 return sc::duration_cast<Duration>(
177 time_.time_since_epoch()).count();
183 time_ = TimeValue(dur);
189 namespace sc = std::chrono;
190 return sc::duration_cast<SecondsDuration>(
191 time_.time_since_epoch()).count();
196 namespace sc = std::chrono;
197 SecondsDuration dur(v);
198 Duration ndur(sc::duration_cast<Duration>(dur));
199 time_ = TimeValue(ndur);
207 template<
typename Base>
208 inline std::ostream &operator<<(std::ostream &o, const Stamped<Base> &v)
210 return o << v <<
"@" << v.time();
double secs(double v)
Set time as seconds since std::steady_clock epoch.
Internal class implementing coordinates stamped with timestamp.
Stamped(TimeValue time)
Construct using a TimeValue object.
TimeValue time(TimeValue v)
Set time from std::chrono based TimeValue.
MADARA_MAKE_VAL_SUPPORT_TEST(nano_timestamp, x,(x.nanos(), x.nanos(0UL)))
Type trait to detect stamped types.
Contains all GAMS-related tools, classes and code.
Stamped()=default
Default Constructor.
uint64_t nanos() const
Get time as nanos since std::steady_clock epoch.
TimeValue time() const
Get time as std::chrono based TimeValue.
double secs() const
Get time as seconds since std::steady_clock epoch.
uint64_t nanos(uint64_t v)
Set time as nanos since std::steady_clock epoch.