Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "cartographer_ros/time_conversion.h"
00018
00019 #include <chrono>
00020
00021 #include "cartographer/common/time.h"
00022 #include "gtest/gtest.h"
00023 #include "ros/ros.h"
00024
00025 namespace cartographer_ros {
00026 namespace {
00027
00028 TEST(TimeConversion, testToRos) {
00029 std::vector<int64_t> values = {0, 1469091375, 1466481821, 1462101382,
00030 1468238899};
00031 for (int64_t seconds_since_epoch : values) {
00032 ::ros::Time ros_now;
00033 ros_now.fromSec(seconds_since_epoch);
00034 ::cartographer::common::Time cartographer_now(
00035 ::cartographer::common::FromSeconds(
00036 seconds_since_epoch +
00037 ::cartographer::common::kUtsEpochOffsetFromUnixEpochInSeconds));
00038 EXPECT_EQ(cartographer_now, ::cartographer_ros::FromRos(ros_now));
00039 EXPECT_EQ(ros_now, ::cartographer_ros::ToRos(cartographer_now));
00040 }
00041 }
00042
00043 }
00044 }