fake_trimmable.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 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 #ifndef CARTOGRAPHER_MAPPING_INTERNAL_TESTING_FAKE_TRIMMABLE_H_
00018 #define CARTOGRAPHER_MAPPING_INTERNAL_TESTING_FAKE_TRIMMABLE_H_
00019 
00020 #include <vector>
00021 
00022 #include "cartographer/mapping/pose_graph_trimmer.h"
00023 
00024 namespace cartographer {
00025 namespace mapping {
00026 namespace testing {
00027 
00028 class FakeTrimmable : public Trimmable {
00029  public:
00030   FakeTrimmable() = default;
00031 
00032   // Populates dummy SubmapIDs.
00033   FakeTrimmable(int trajectory_id, int num_submaps) {
00034     for (int index = 0; index < num_submaps; ++index) {
00035       submap_data_.Insert(SubmapId{trajectory_id, index}, {});
00036     }
00037   }
00038   ~FakeTrimmable() override {}
00039 
00040   int num_submaps(const int trajectory_id) const override {
00041     return submap_data_.size() - trimmed_submaps_.size();
00042   }
00043 
00044   std::vector<SubmapId> GetSubmapIds(int trajectory_id) const override {
00045     std::vector<SubmapId> submap_ids;
00046     for (const auto& submap : submap_data_) {
00047       submap_ids.push_back(submap.id);
00048     }
00049     return submap_ids;
00050   }
00051 
00052   void set_submap_data(
00053       const MapById<SubmapId, PoseGraphInterface::SubmapData>& submap_data) {
00054     submap_data_ = submap_data;
00055   }
00056 
00057   MapById<SubmapId, PoseGraphInterface::SubmapData>* mutable_submap_data() {
00058     return &submap_data_;
00059   }
00060 
00061   MapById<SubmapId, PoseGraphInterface::SubmapData> GetOptimizedSubmapData()
00062       const override {
00063     return submap_data_;
00064   }
00065 
00066   void set_trajectory_nodes(
00067       const MapById<NodeId, TrajectoryNode>& trajectory_nodes) {
00068     trajectory_nodes_ = trajectory_nodes;
00069   }
00070 
00071   MapById<NodeId, TrajectoryNode>* mutable_trajectory_nodes() {
00072     return &trajectory_nodes_;
00073   }
00074 
00075   const MapById<NodeId, TrajectoryNode>& GetTrajectoryNodes() const override {
00076     return trajectory_nodes_;
00077   }
00078 
00079   void set_constraints(
00080       const std::vector<PoseGraphInterface::Constraint>& constraints) {
00081     constraints_ = constraints;
00082   }
00083 
00084   std::vector<PoseGraphInterface::Constraint>* mutable_constraints() {
00085     return &constraints_;
00086   }
00087 
00088   const std::vector<PoseGraphInterface::Constraint>& GetConstraints()
00089       const override {
00090     return constraints_;
00091   }
00092 
00093   void TrimSubmap(const SubmapId& submap_id) override {
00094     trimmed_submaps_.push_back(submap_id);
00095   }
00096 
00097   bool IsFinished(const int trajectory_id) const override { return false; }
00098 
00099   void SetTrajectoryState(
00100       int /*trajectory_id*/,
00101       PoseGraphInterface::TrajectoryState /*state*/) override {}
00102 
00103   std::vector<SubmapId> trimmed_submaps() { return trimmed_submaps_; }
00104 
00105  private:
00106   std::vector<SubmapId> trimmed_submaps_;
00107 
00108   std::vector<PoseGraphInterface::Constraint> constraints_;
00109   MapById<NodeId, TrajectoryNode> trajectory_nodes_;
00110   MapById<SubmapId, PoseGraphInterface::SubmapData> submap_data_;
00111 };
00112 
00113 }  // namespace testing
00114 }  // namespace mapping
00115 }  // namespace cartographer
00116 
00117 #endif  // CARTOGRAPHER_MAPPING_INTERNAL_TESTING_FAKE_TRIMMABLE_H_


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