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/sensor/landmark_data.h"
00018
00019 #include "cartographer/transform/transform.h"
00020
00021 namespace cartographer {
00022 namespace sensor {
00023
00024 proto::LandmarkData ToProto(const LandmarkData& landmark_data) {
00025 proto::LandmarkData proto;
00026 proto.set_timestamp(common::ToUniversal(landmark_data.time));
00027 for (const auto& observation : landmark_data.landmark_observations) {
00028 auto* item = proto.add_landmark_observations();
00029 item->set_id(observation.id);
00030 *item->mutable_landmark_to_tracking_transform() =
00031 transform::ToProto(observation.landmark_to_tracking_transform);
00032 item->set_translation_weight(observation.translation_weight);
00033 item->set_rotation_weight(observation.rotation_weight);
00034 }
00035 return proto;
00036 }
00037
00038 LandmarkData FromProto(const proto::LandmarkData& proto) {
00039 LandmarkData landmark_data;
00040 landmark_data.time = common::FromUniversal(proto.timestamp());
00041 for (const auto& item : proto.landmark_observations()) {
00042 landmark_data.landmark_observations.push_back({
00043 item.id(),
00044 transform::ToRigid3(item.landmark_to_tracking_transform()),
00045 item.translation_weight(),
00046 item.rotation_weight(),
00047 });
00048 }
00049 return landmark_data;
00050 }
00051
00052 }
00053 }