probability_grid.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_2D_PROBABILITY_GRID_H_
18 #define CARTOGRAPHER_MAPPING_2D_PROBABILITY_GRID_H_
19 
20 #include <vector>
21 
26 
27 namespace cartographer {
28 namespace mapping {
29 
30 // Represents a 2D grid of probabilities.
31 class ProbabilityGrid : public Grid2D {
32  public:
33  explicit ProbabilityGrid(const MapLimits& limits);
34  explicit ProbabilityGrid(const proto::Grid2D& proto);
35 
36  // Sets the probability of the cell at 'cell_index' to the given
37  // 'probability'. Only allowed if the cell was unknown before.
38  void SetProbability(const Eigen::Array2i& cell_index,
39  const float probability);
40 
41  // Applies the 'odds' specified when calling ComputeLookupTableToApplyOdds()
42  // to the probability of the cell at 'cell_index' if the cell has not already
43  // been updated. Multiple updates of the same cell will be ignored until
44  // FinishUpdate() is called. Returns true if the cell was updated.
45  //
46  // If this is the first call to ApplyOdds() for the specified cell, its value
47  // will be set to probability corresponding to 'odds'.
48  bool ApplyLookupTable(const Eigen::Array2i& cell_index,
49  const std::vector<uint16>& table);
50 
51  // Returns the probability of the cell with 'cell_index'.
52  float GetProbability(const Eigen::Array2i& cell_index) const;
53 
54  virtual proto::Grid2D ToProto() const override;
55  virtual std::unique_ptr<Grid2D> ComputeCroppedGrid() const override;
56  virtual bool DrawToSubmapTexture(
57  proto::SubmapQuery::Response::SubmapTexture* const texture,
58  transform::Rigid3d local_pose) const override;
59 };
60 
61 } // namespace mapping
62 } // namespace cartographer
63 
64 #endif // CARTOGRAPHER_MAPPING_2D_PROBABILITY_GRID_H_
virtual std::unique_ptr< Grid2D > ComputeCroppedGrid() const override
void SetProbability(const Eigen::Array2i &cell_index, const float probability)
virtual bool DrawToSubmapTexture(proto::SubmapQuery::Response::SubmapTexture *const texture, transform::Rigid3d local_pose) const override
ProbabilityGrid(const MapLimits &limits)
float GetProbability(const Eigen::Array2i &cell_index) const
virtual proto::Grid2D ToProto() const override
const MapLimits & limits() const
Definition: grid_2d.h:41
bool ApplyLookupTable(const Eigen::Array2i &cell_index, const std::vector< uint16 > &table)


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