submaps.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016 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 
17 #ifndef CARTOGRAPHER_MAPPING_SUBMAPS_H_
18 #define CARTOGRAPHER_MAPPING_SUBMAPS_H_
19 
20 #include <memory>
21 #include <vector>
22 
23 #include "Eigen/Geometry"
28 #include "cartographer/mapping/proto/serialization.pb.h"
29 #include "cartographer/mapping/proto/submap_visualization.pb.h"
31 #include "glog/logging.h"
32 
33 namespace cartographer {
34 namespace mapping {
35 
36 // Converts the given probability to log odds.
37 inline float Logit(float probability) {
38  return std::log(probability / (1.f - probability));
39 }
40 
43 
44 // Converts a probability to a log odds integer. 0 means unknown, [kMinLogOdds,
45 // kMaxLogOdds] is mapped to [1, 255].
46 inline uint8 ProbabilityToLogOddsInteger(const float probability) {
47  const int value = common::RoundToInt((Logit(probability) - kMinLogOdds) *
48  254.f / (kMaxLogOdds - kMinLogOdds)) +
49  1;
50  CHECK_LE(1, value);
51  CHECK_GE(255, value);
52  return value;
53 }
54 
55 // An individual submap, which has a 'local_pose' in the local map frame, keeps
56 // track of how many range data were inserted into it, and sets the
57 // 'finished_probability_grid' to be used for loop closing once the map no
58 // longer changes.
59 class Submap {
60  public:
61  Submap(const transform::Rigid3d& local_submap_pose)
62  : local_pose_(local_submap_pose) {}
63  virtual ~Submap() {}
64 
65  virtual void ToProto(proto::Submap* proto,
66  bool include_probability_grid_data) const = 0;
67  virtual void UpdateFromProto(const proto::Submap& proto) = 0;
68 
69  // Fills data into the 'response'.
70  virtual void ToResponseProto(
71  const transform::Rigid3d& global_submap_pose,
72  proto::SubmapQuery::Response* response) const = 0;
73 
74  // Pose of this submap in the local map frame.
76 
77  // Number of RangeData inserted.
78  int num_range_data() const { return num_range_data_; }
81  }
82 
83  // Whether the submap is finished or not.
84  bool finished() const { return finished_; }
86 
87  private:
89  int num_range_data_ = 0;
90  bool finished_ = false;
91 };
92 
93 } // namespace mapping
94 } // namespace cartographer
95 
96 #endif // CARTOGRAPHER_MAPPING_SUBMAPS_H_
virtual void ToProto(proto::Submap *proto, bool include_probability_grid_data) const =0
const float kMinLogOdds
Definition: submaps.h:42
int RoundToInt(const float x)
Definition: port.h:41
constexpr float kMinProbability
void set_num_range_data(const int num_range_data)
Definition: submaps.h:79
void set_finished(bool finished)
Definition: submaps.h:85
const float kMaxLogOdds
Definition: submaps.h:41
constexpr float kMaxProbability
Submap(const transform::Rigid3d &local_submap_pose)
Definition: submaps.h:61
float Logit(float probability)
Definition: submaps.h:37
const transform::Rigid3d local_pose_
Definition: submaps.h:88
uint8 ProbabilityToLogOddsInteger(const float probability)
Definition: submaps.h:46
transform::Rigid3d local_pose() const
Definition: submaps.h:75
virtual void ToResponseProto(const transform::Rigid3d &global_submap_pose, proto::SubmapQuery::Response *response) const =0
virtual void UpdateFromProto(const proto::Submap &proto)=0
int num_range_data() const
Definition: submaps.h:78
uint8_t uint8
Definition: port.h:34


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