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/ground_truth/relations_text_file.h"
00018
00019 #include <fstream>
00020
00021 #include "cartographer/common/time.h"
00022 #include "cartographer/transform/rigid_transform.h"
00023 #include "cartographer/transform/transform.h"
00024 #include "glog/logging.h"
00025
00026 namespace cartographer {
00027 namespace ground_truth {
00028
00029 namespace {
00030
00031 common::Time UnixToCommonTime(double unix_time) {
00032 constexpr int64 kUtsTicksPerSecond = 10000000;
00033 return common::FromUniversal(common::kUtsEpochOffsetFromUnixEpochInSeconds *
00034 kUtsTicksPerSecond) +
00035 common::FromSeconds(unix_time);
00036 }
00037
00038 }
00039
00040 proto::GroundTruth ReadRelationsTextFile(
00041 const std::string& relations_filename) {
00042 proto::GroundTruth ground_truth;
00043 std::ifstream relations_stream(relations_filename.c_str());
00044 double unix_time_1, unix_time_2, x, y, z, roll, pitch, yaw;
00045 while (relations_stream >> unix_time_1 >> unix_time_2 >> x >> y >> z >>
00046 roll >> pitch >> yaw) {
00047 const common::Time common_time_1 = UnixToCommonTime(unix_time_1);
00048 const common::Time common_time_2 = UnixToCommonTime(unix_time_2);
00049 const transform::Rigid3d expected =
00050 transform::Rigid3d(transform::Rigid3d::Vector(x, y, z),
00051 transform::RollPitchYaw(roll, pitch, yaw));
00052 auto* const new_relation = ground_truth.add_relation();
00053 new_relation->set_timestamp1(common::ToUniversal(common_time_1));
00054 new_relation->set_timestamp2(common::ToUniversal(common_time_2));
00055 *new_relation->mutable_expected() = transform::ToProto(expected);
00056 }
00057 CHECK(relations_stream.eof());
00058 return ground_truth;
00059 }
00060
00061 }
00062 }