landmark_data.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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 }  // namespace sensor
00053 }  // namespace cartographer


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35