src
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
13
void
mrpt_bridge::convert
(
const
ros::Time
& src, mrpt::system::TTimeStamp& des)
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
20
void
mrpt_bridge::convert
(
const
mrpt::system::TTimeStamp& src,
ros::Time
& des)
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
}
time.h
TimeBase< Time, Duration >::sec
uint32_t sec
TimeBase< Time, Duration >::nsec
uint32_t nsec
mrpt_bridge::convert
bool convert(const mrpt_msgs::ObservationRangeBeacon &_msg, const mrpt::poses::CPose3D &_pose, mrpt::obs::CObservationBeaconRanges &_obj)
ros::Time
mrpt_bridge
Author(s): Markus Bader
, Raphael Zack
autogenerated on Sun Mar 6 2022 03:48:10