Apollo 11.0
自动驾驶开放平台
lossless_map_matrix.h
浏览该文件的文档.
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
19#include <vector>
20
21#include "cyber/common/log.h"
24
25namespace apollo {
26namespace localization {
27namespace msf {
28
31#define IDL_CAR_NUM_RESERVED_MAP_LAYER 2U
32
37 inline void Reset();
39 void AddSample(const float new_altitude, const float new_intensity);
45 unsigned int LoadBinary(unsigned char* buf);
50 unsigned int CreateBinary(unsigned char* buf, unsigned int buf_size) const;
52 unsigned int GetBinarySize() const;
53
55 float intensity;
59 float altitude;
63 unsigned int count;
64};
65
71 void Reset();
74 void SetValueLayer(double altitude, unsigned char intensity,
75 double altitude_thres = 10.0);
80 void SetValue(double altitude, unsigned char intensity);
84 unsigned int LoadBinary(unsigned char* buf);
89 unsigned int CreateBinary(unsigned char* buf, unsigned int buf_size) const;
91 unsigned int GetBinarySize() const;
92
96 unsigned int GetLayerId(double altitude) const;
101 void GetValue(std::vector<unsigned char>* values) const;
103 void GetVar(std::vector<float>* vars) const;
105 void GetAlt(std::vector<float>* alts) const;
107 void GetAltVar(std::vector<float>* alt_vars) const;
109 void GetCount(std::vector<unsigned int>* counts) const;
111 inline unsigned char GetValue() const {
112 return static_cast<unsigned char>(map_cells[0].intensity);
113 }
115 inline float GetVar() const { return map_cells[0].intensity_var; }
117 inline float GetAlt() const { return map_cells[0].altitude; }
119 inline float GetAltVar() const { return map_cells[0].altitude_var; }
121 inline unsigned int GetCount() const { return map_cells[0].count; }
124 LosslessMapSingleCell& GetLayer(unsigned int layer_id) {
125 DCHECK_LT(layer_id, layer_num);
126 return map_cells[layer_id];
127 }
130 const LosslessMapSingleCell& GetLayer(unsigned int layer_id) const {
131 DCHECK_LT(layer_id, layer_num);
132 return map_cells[layer_id];
133 }
134
136 unsigned int layer_num;
141};
142
144 public:
148
149 virtual void Init(const BaseMapConfig* config);
151 virtual void Reset(const BaseMapConfig* config);
152
153 void Init(unsigned int rows, unsigned int cols);
154 void Reset(unsigned int rows, unsigned int cols);
155
159 virtual unsigned int LoadBinary(unsigned char* buf);
164 virtual unsigned int CreateBinary(unsigned char* buf,
165 unsigned int buf_size) const;
167 virtual unsigned int GetBinarySize() const;
169 virtual void GetIntensityImg(cv::Mat* intensity_img) const;
170
172 inline const LosslessMapCell& GetMapCell(unsigned int row,
173 unsigned int col) const {
174 DCHECK_LT(row, rows_);
175 DCHECK_LT(col, cols_);
176 return map_cells_[row * cols_ + col];
177 }
179 inline LosslessMapCell& GetMapCell(unsigned int row, unsigned int col) {
180 DCHECK_LT(row, rows_);
181 DCHECK_LT(col, cols_);
182 return map_cells_[row * cols_ + col];
183 }
184
185 inline LosslessMapCell* operator[](int row) {
186 return map_cells_ + row * cols_;
187 }
188 inline const LosslessMapCell* operator[](int row) const {
189 return map_cells_ + row * cols_;
190 }
191
192 protected:
194 unsigned int rows_;
196 unsigned int cols_;
199};
200
201} // namespace msf
202} // namespace localization
203} // namespace apollo
The options of the reflectance map.
The data structure of the map cells in a map node.
virtual unsigned int CreateBinary(unsigned char *buf, unsigned int buf_size) const
Create the binary.
const LosslessMapCell & GetMapCell(unsigned int row, unsigned int col) const
Get a map cell.
virtual void Reset(const BaseMapConfig *config)
Reset map cells data.
virtual unsigned int GetBinarySize() const
Get the binary size of the object.
LosslessMapCell & GetMapCell(unsigned int row, unsigned int col)
Get a map cell.
const LosslessMapCell * operator[](int row) const
unsigned int cols_
The number of columns.
virtual void Init(const BaseMapConfig *config)
Initialize the map matrix.
virtual unsigned int LoadBinary(unsigned char *buf)
Load the map cell from a binary chunk.
virtual void GetIntensityImg(cv::Mat *intensity_img) const
get intensity image of node.
LosslessMapCell * map_cells_
The matrix data structure.
#define IDL_CAR_NUM_RESERVED_MAP_LAYER
The first layer (layer 0) includes all the intensities from any layers.
class register implement
Definition arena_queue.h:37
float GetAlt() const
Get the average altitude of the map cell.
float GetVar() const
Get the variance of the intensity of the map cell.
unsigned int GetCount() const
Get the count of the samples in the map cell.
LosslessMapSingleCell & GetLayer(unsigned int layer_id)
Get a particular layer in the map cell.
LosslessMapSingleCell map_cells[IDL_CAR_NUM_RESERVED_MAP_LAYER]
The multiple layers of the cell.
unsigned char GetValue() const
Get the average intensity of the map cell.
const LosslessMapSingleCell & GetLayer(unsigned int layer_id) const
Get a perticular layer in the map cell.
unsigned int GetBinarySize() const
Get the binary size of the object.
unsigned int CreateBinary(unsigned char *buf, unsigned int buf_size) const
Create the binary.
void SetValueLayer(double altitude, unsigned char intensity, double altitude_thres=10.0)
Set the value of a layer that layer_id > 0.
unsigned int layer_num
The layers of the cell.
float GetAltVar() const
Get the variance of the altitude of the map cell.
unsigned int GetLayerId(double altitude) const
Match a layer in the map cell given an altitude.
unsigned int LoadBinary(unsigned char *buf)
Load the map cell from a binary chunk.
void SetValue(double altitude, unsigned char intensity)
Set the value.
float altitude_var
The variance altitude value of the cell.
float altitude
The average altitude of the cell.
unsigned int count
The number of samples in the cell.
unsigned int LoadBinary(unsigned char *buf)
Load the map cell from a binary chunk.
void AddSample(const float new_altitude, const float new_intensity)
Add a sample.
float intensity_var
The variance intensity value.
unsigned int GetBinarySize() const
Get the binary size of the object.
LosslessMapSingleCell & operator=(const LosslessMapSingleCell &ref)
Overloading the assign operator.
unsigned int CreateBinary(unsigned char *buf, unsigned int buf_size) const
Create the binary.