Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
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 ,
00101 PoseGraphInterface::TrajectoryState ) 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 }
00114 }
00115 }
00116
00117 #endif // CARTOGRAPHER_MAPPING_INTERNAL_TESTING_FAKE_TRIMMABLE_H_