Apollo  6.0
Open source self driving car software
lossy_map_matrix_2d.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
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 #pragma once
18 
21 
22 namespace apollo {
23 namespace localization {
24 namespace msf {
25 
30  inline void Reset();
31  // /**@brief Load the map cell from a binary chunk.
32  // * @param <return> The size read (the real size of object).
33  // */
34  // inline unsigned int LoadBinary(unsigned char * buf);
35  // /**@brief Create the binary. Serialization of the object.
36  // * @param <buf, buf_size> The buffer and its size.
37  // * @param <return> The required or the used size of is returned.
38  // */
39  // inline unsigned int CreateBinary(unsigned char * buf, unsigned int
40  // buf_size) const;
41  // /**@brief Get the binary size of the object. */
42  // inline unsigned int GetBinarySize() const;
46  unsigned int count;
48  float intensity;
52  float altitude;
57 };
58 
60  public:
63  LossyMapMatrix2D(const LossyMapMatrix2D& matrix);
64 
65  virtual void Init(const BaseMapConfig* config);
67  virtual void Reset(const BaseMapConfig* config);
68 
69  void Init(unsigned int rows, unsigned int cols);
70  void Reset(unsigned int rows, unsigned int cols);
71 
75  virtual unsigned int LoadBinary(unsigned char* buf);
80  virtual unsigned int CreateBinary(unsigned char* buf,
81  unsigned int buf_size) const;
83  virtual unsigned int GetBinarySize() const;
85  virtual void GetIntensityImg(cv::Mat* intensity_img) const;
86 
87  inline LossyMapCell2D* operator[](int row) {
88  return map_cells_ + row * cols_;
89  }
90  inline const LossyMapCell2D* operator[](int row) const {
91  return map_cells_ + row * cols_;
92  }
93 
95 
96  protected:
98  unsigned int rows_;
100  unsigned int cols_;
103 
104  protected:
105  inline unsigned char EncodeIntensity(const LossyMapCell2D& cell) const;
106  inline void DecodeIntensity(unsigned char data, LossyMapCell2D* cell) const;
107  inline uint16_t EncodeVar(const LossyMapCell2D& cell) const;
108  inline void DecodeVar(uint16_t data, LossyMapCell2D* cell) const;
109  inline uint16_t EncodeAltitudeGround(const LossyMapCell2D& cell) const;
110  inline void DecodeAltitudeGround(uint16_t data, LossyMapCell2D* cell) const;
111  inline uint16_t EncodeAltitudeAvg(const LossyMapCell2D& cell) const;
112  inline void DecodeAltitudeAvg(uint16_t data, LossyMapCell2D* cell) const;
113  inline unsigned char EncodeCount(const LossyMapCell2D& cell) const;
114  inline void DecodeCount(unsigned char data, LossyMapCell2D* cell) const;
115  const int var_range_ = 1023; // 65535;
116  const int var_ratio_ = 4; // 256;
117  // const unsigned int _alt_range = 1023;//65535;
118  const float alt_ground_interval_ = 0.04f;
119  const uint16_t ground_void_flag_ = 0xffff;
120  const float alt_avg_interval_ = 0.04f;
121  const int count_range_ = 2; // 30;
122  mutable float alt_avg_min_;
123  mutable float alt_avg_max_;
124  mutable float alt_ground_min_;
125  mutable float alt_ground_max_;
126 };
127 
128 } // namespace msf
129 } // namespace localization
130 } // namespace apollo
unsigned int cols_
The number of columns.
Definition: lossy_map_matrix_2d.h:100
The options of the reflectance map.
Definition: base_map_config.h:32
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
LossyMapCell2D * map_cells_
The matrix data structure.
Definition: lossy_map_matrix_2d.h:102
Definition: lossy_map_matrix_2d.h:26
float intensity
The average intensity value.
Definition: lossy_map_matrix_2d.h:48
float alt_avg_min_
Definition: lossy_map_matrix_2d.h:122
float alt_avg_max_
Definition: lossy_map_matrix_2d.h:123
The data structure of the map cells in a map node.
Definition: base_map_matrix.h:28
unsigned int rows_
The number of rows.
Definition: lossy_map_matrix_2d.h:98
bool is_ground_useful
is ground altitude usefu
Definition: lossy_map_matrix_2d.h:56
float intensity_var
The variance intensity value.
Definition: lossy_map_matrix_2d.h:50
void Reset()
Reset to default value.
LossyMapCell2D()
The default constructor.
bool Init(const char *binary_name)
const LossyMapCell2D * operator[](int row) const
Definition: lossy_map_matrix_2d.h:90
LossyMapCell2D * operator[](int row)
Definition: lossy_map_matrix_2d.h:87
float altitude
The average altitude of the cell.
Definition: lossy_map_matrix_2d.h:52
float alt_ground_min_
Definition: lossy_map_matrix_2d.h:124
Definition: lossy_map_matrix_2d.h:59
unsigned int count
The number of samples in the cell.
Definition: lossy_map_matrix_2d.h:46
float alt_ground_max_
Definition: lossy_map_matrix_2d.h:125
float altitude_ground
The ground altitude of the cell.
Definition: lossy_map_matrix_2d.h:54
LossyMapCell2D & operator=(const LossyMapCell2D &ref)
Load the map cell from a binary chunk.