landmark_data.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2017 The Cartographer Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
20 
21 namespace cartographer {
22 namespace sensor {
23 
24 proto::LandmarkData ToProto(const LandmarkData& landmark_data) {
25  proto::LandmarkData proto;
26  proto.set_timestamp(common::ToUniversal(landmark_data.time));
27  for (const auto& observation : landmark_data.landmark_observations) {
28  auto* item = proto.add_landmark_observations();
29  item->set_id(observation.id);
30  *item->mutable_landmark_to_tracking_transform() =
31  transform::ToProto(observation.landmark_to_tracking_transform);
32  item->set_translation_weight(observation.translation_weight);
33  item->set_rotation_weight(observation.rotation_weight);
34  }
35  return proto;
36 }
37 
38 LandmarkData FromProto(const proto::LandmarkData& proto) {
39  LandmarkData landmark_data;
40  landmark_data.time = common::FromUniversal(proto.timestamp());
41  for (const auto& item : proto.landmark_observations()) {
42  landmark_data.landmark_observations.push_back({
43  item.id(),
44  transform::ToRigid3(item.landmark_to_tracking_transform()),
45  item.translation_weight(),
46  item.rotation_weight(),
47  });
48  }
49  return landmark_data;
50 }
51 
52 } // namespace sensor
53 } // namespace cartographer
proto::FixedFramePoseData ToProto(const FixedFramePoseData &pose_data)
FixedFramePoseData FromProto(const proto::FixedFramePoseData &proto)
transform::Rigid3d ToRigid3(const proto::Rigid3d &rigid)
Definition: transform.cc:71
Time FromUniversal(const int64 ticks)
Definition: time.cc:34
proto::Rigid2d ToProto(const transform::Rigid2d &transform)
Definition: transform.cc:48
int64 ToUniversal(const Time time)
Definition: time.cc:36
std::vector< LandmarkObservation > landmark_observations
Definition: landmark_data.h:41


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58