cloud/internal/testing/test_helpers.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2018 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 
19 namespace cartographer {
20 namespace cloud {
21 namespace testing {
22 
23 template <>
24 DataPredicateType BuildDataPredicateEquals<proto::AddImuDataRequest>(
25  const proto::AddImuDataRequest &proto) {
26  return [proto](const sensor::Data &data) {
27  const auto *dispatchable =
28  dynamic_cast<const sensor::Dispatchable<sensor::ImuData> *>(&data);
29  CHECK_NOTNULL(dispatchable);
30  return google::protobuf::util::MessageDifferencer::Equals(
31  sensor::ToProto(dispatchable->data()), proto.imu_data()) &&
32  dispatchable->GetSensorId() == proto.sensor_metadata().sensor_id();
33  };
34 }
35 
36 template <>
37 DataPredicateType BuildDataPredicateEquals<proto::AddFixedFramePoseDataRequest>(
38  const proto::AddFixedFramePoseDataRequest &proto) {
39  return [proto](const sensor::Data &data) {
40  const auto *dispatchable =
42  &data);
43  CHECK_NOTNULL(dispatchable);
44  return google::protobuf::util::MessageDifferencer::Equals(
45  sensor::ToProto(dispatchable->data()),
46  proto.fixed_frame_pose_data()) &&
47  dispatchable->GetSensorId() == proto.sensor_metadata().sensor_id();
48  };
49 }
50 
51 template <>
52 DataPredicateType BuildDataPredicateEquals<proto::AddOdometryDataRequest>(
53  const proto::AddOdometryDataRequest &proto) {
54  return [proto](const sensor::Data &data) {
55  const auto *dispatchable =
56  dynamic_cast<const sensor::Dispatchable<sensor::OdometryData> *>(&data);
57  CHECK_NOTNULL(dispatchable);
58  return google::protobuf::util::MessageDifferencer::Equals(
59  sensor::ToProto(dispatchable->data()), proto.odometry_data()) &&
60  dispatchable->GetSensorId() == proto.sensor_metadata().sensor_id();
61  };
62 }
63 
64 template <>
65 DataPredicateType BuildDataPredicateEquals<proto::AddLandmarkDataRequest>(
66  const proto::AddLandmarkDataRequest &proto) {
67  return [proto](const sensor::Data &data) {
68  const auto *dispatchable =
69  dynamic_cast<const sensor::Dispatchable<sensor::LandmarkData> *>(&data);
70  CHECK_NOTNULL(dispatchable);
71  return google::protobuf::util::MessageDifferencer::Equals(
72  sensor::ToProto(dispatchable->data()), proto.landmark_data()) &&
73  dispatchable->GetSensorId() == proto.sensor_metadata().sensor_id();
74  };
75 }
76 
77 template <>
78 DataPredicateType BuildDataPredicateEquals<proto::AddRangefinderDataRequest>(
79  const proto::AddRangefinderDataRequest &proto) {
80  return [proto](const sensor::Data &data) {
81  const auto *dispatchable =
83  &data);
84  CHECK_NOTNULL(dispatchable);
85  return google::protobuf::util::MessageDifferencer::Equals(
86  sensor::ToProto(dispatchable->data()),
87  proto.timed_point_cloud_data()) &&
88  dispatchable->GetSensorId() == proto.sensor_metadata().sensor_id();
89  };
90 }
91 
93  const google::protobuf::Message *proto) {
94  return [proto](const google::protobuf::Message &message) {
95  return google::protobuf::util::MessageDifferencer::Equals(*proto, message);
96  };
97 }
98 
99 } // namespace testing
100 } // namespace cloud
101 } // namespace cartographer
std::function< bool(const google::protobuf::Message &)> ProtoPredicateType
proto::FixedFramePoseData ToProto(const FixedFramePoseData &pose_data)
ProtoPredicateType BuildProtoPredicateEquals(const google::protobuf::Message *proto)
std::function< bool(const sensor::Data &)> DataPredicateType


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