time.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "mrpt_bridge/time.h"
11 #include <cmath> // std::fmod
12 
14 {
15  // Use the signature of time_tToTimestamp() that accepts "double" with the
16  // fractional parts of seconds:
17  des = mrpt::system::time_tToTimestamp(src.sec + src.nsec * 1e-9);
18 }
19 
21 {
22  // Convert to "double-version of time_t", then extract integer and
23  // fractional parts:
24  const double t = mrpt::system::timestampTotime_t(src);
25  des.sec = static_cast<uint64_t>(t);
26  des.nsec = static_cast<uint64_t>(std::fmod(t, 1.0) * 1e9 + 0.5 /*round*/);
27 }
uint64_t TTimeStamp
GLdouble GLdouble t
GLuint src
bool convert(const mrpt_msgs::ObservationRangeBeacon &_msg, const mrpt::poses::CPose3D &_pose, mrpt::obs::CObservationBeaconRanges &_obj)
Definition: beacon.cpp:24
mrpt::system::TTimeStamp BASE_IMPEXP time_tToTimestamp(const double t)
double BASE_IMPEXP timestampTotime_t(const mrpt::system::TTimeStamp t)


mrpt_bridge
Author(s): Markus Bader , Raphael Zack
autogenerated on Fri Feb 28 2020 03:22:14