Apollo 10.0
自动驾驶开放平台
base_map_node.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 <string>
20#include <vector>
21
26
27namespace apollo {
28namespace localization {
29namespace msf {
30
33 public:
37 virtual ~BaseMapNode();
38
40 virtual void Init(const BaseMapConfig* map_config, const MapNodeIndex& index,
41 bool create_map_cells = true);
43 virtual void InitMapMatrix(const BaseMapConfig* map_config);
45 virtual void Finalize();
47 virtual void ResetMapNode();
48
50 bool Save();
52 bool SaveIntensityImage() const;
54 bool Load();
55 bool Load(const char* filename);
56
57 // /**@brief Set compression strategy. */
58 // void SetCompressionStrategy(compression::CompressionStrategy* strategy);
60 inline const BaseMapMatrix& GetMapCellMatrix() const { return *map_matrix_; }
61
63
65 inline const BaseMapConfig& GetMapConfig() const { return *map_config_; }
67 inline void SetMapNodeIndex(const MapNodeIndex& index) { index_ = index; }
69 inline const MapNodeIndex& GetMapNodeIndex() const { return index_; }
71 inline void SetIsReserved(bool is_reserved) { is_reserved_ = is_reserved; }
73 inline bool GetIsReserved() const { return is_reserved_; }
75 inline bool GetIsChanged() const { return is_changed_; }
77 inline void SetIsChanged(bool is) { is_changed_ = is; }
79 inline bool GetIsReady() const { return data_is_ready_; }
81 // inline const idl::car::core::numerical::Vector2D& GetLeftTopCorner()
82 // const {
83 // return left_top_corner_;
84 // }
85
86 inline const Eigen::Vector2d& GetLeftTopCorner() const {
87 return left_top_corner_;
88 }
89
90 inline void SetLeftTopCorner(double x, double y) {
91 // left_top_corner_[0] = x;
92 // left_top_corner_[1] = y;
93
94 left_top_corner_[0] = x;
95 left_top_corner_[1] = y;
96 }
98 inline float GetMapResolution() const {
100 }
104 // bool GetCoordinate(const idl::car::core::numerical::Vector2D& coordinate,
105 // unsigned int& x, unsigned int& y) const;
106 // bool GetCoordinate(const idl::car::core::numerical::Vector3D& coordinate,
107 // unsigned int& x, unsigned int& y) const;
109 // idl::car::core::numerical::Vector2D GetCoordinate(unsigned int x, unsigned
110 // int y) const;
111
115 bool GetCoordinate(const Eigen::Vector2d& coordinate, unsigned int* x,
116 unsigned int* y) const;
117 bool GetCoordinate(const Eigen::Vector3d& coordinate, unsigned int* x,
118 unsigned int* y) const;
121 Eigen::Vector2d GetCoordinate(unsigned int x, unsigned int y) const;
122
123 // static idl::car::core::numerical::Vector2D GetLeftTopCorner(const
124 // BaseMapConfig& option,
125 // const MapNodeIndex&
126 // index);
127 static Eigen::Vector2d GetLeftTopCorner(const BaseMapConfig& option,
128 const MapNodeIndex& index);
129
130 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
131
132 protected:
136 virtual unsigned int LoadBinary(FILE* file);
140 virtual unsigned int CreateBinary(FILE* file) const;
142 virtual unsigned int GetBinarySize() const;
146 virtual unsigned int LoadHeaderBinary(unsigned char* buf);
151 virtual unsigned int CreateHeaderBinary(unsigned char* buf,
152 unsigned int buf_size) const;
154 virtual unsigned int GetHeaderBinarySize() const;
158 virtual unsigned int LoadBodyBinary(std::vector<unsigned char>* buf);
163 virtual unsigned int CreateBodyBinary(std::vector<unsigned char>* buf) const;
165 virtual unsigned int GetBodyBinarySize() const;
167 bool SaveIntensityImage(const std::string& path) const;
168
170 const BaseMapConfig* map_config_ = nullptr;
175 // idl::car::core::numerical::Vector2D left_top_corner_;
176 Eigen::Vector2d left_top_corner_;
180 bool is_reserved_ = false;
182 bool is_changed_ = false;
183 /* *@brief Indicate map node data is ready*/
184 bool data_is_ready_ = false;
187 mutable unsigned int file_body_binary_size_ = 0;
191 float min_altitude_ = 1e6;
192};
193
194} // namespace msf
195} // namespace localization
196} // namespace apollo
The options of the reflectance map.
std::vector< float > map_resolutions_
The pixel resolutions in the map in meters.
The data structure of the map cells in a map node.
The data structure of a Node in the map.
const Eigen::Vector2d & GetLeftTopCorner() const
Get the left top corner of the map node.
void SetMapNodeIndex(const MapNodeIndex &index)
Set the map node index.
virtual unsigned int CreateBinary(FILE *file) const
Create the binary.
BaseMapMatrix * map_matrix_
The data structure of the map datas, which is a matrix.
virtual void Init(const BaseMapConfig *map_config, const MapNodeIndex &index, bool create_map_cells=true)
Initialize the map node.
MapNodeIndex index_
The index of this node.
unsigned int file_body_binary_size_
The body binary size in file.
virtual void ResetMapNode()
Reset map cells data.
virtual unsigned int LoadBinary(FILE *file)
Load the map cell from a binary chunk.
bool SaveIntensityImage() const
Save intensity image of node.
const MapNodeIndex & GetMapNodeIndex() const
Get the map node index.
virtual unsigned int CreateHeaderBinary(unsigned char *buf, unsigned int buf_size) const
Create the binary header.
virtual void InitMapMatrix(const BaseMapConfig *map_config)
Initialize the map matrix.
bool is_changed_
Has the map node been changed.
const BaseMapMatrix & GetMapCellMatrix() const
Get map cell matrix.
void SetIsChanged(bool is)
Set if the map node data has changed.
void SetLeftTopCorner(double x, double y)
virtual ~BaseMapNode()
Destruct a map node.
bool GetIsReserved() const
Get if the map node is reserved.
virtual void Finalize()
call before deconstruction or reset.
bool is_reserved_
If the node is reserved in map.
CompressionStrategy * compression_strategy_
@bried The compression strategy.
bool Load()
Load the map node from the disk.
bool Save()
Save the map node to the disk.
virtual unsigned int LoadHeaderBinary(unsigned char *buf)
Load the map node header from a binary chunk.
virtual unsigned int GetBodyBinarySize() const
Get the size of the body in bytes.
const BaseMapConfig * map_config_
The map settings.
float min_altitude_
The min altitude of point cloud in the node.
bool GetIsChanged() const
Get if the map data has changed.
virtual unsigned int LoadBodyBinary(std::vector< unsigned char > *buf)
Load the map node body from a binary chunk.
virtual unsigned int CreateBodyBinary(std::vector< unsigned char > *buf) const
Create the binary body.
Eigen::Vector2d left_top_corner_
The left top corner of the map node in the global coordinate system.
void SetIsReserved(bool is_reserved)
Set if the map node is reserved.
float GetMapResolution() const
Get the resolution of this map nodex.
virtual unsigned int GetBinarySize() const
Get the binary size of the object.
bool GetIsReady() const
Get if the map node data is ready
const BaseMapConfig & GetMapConfig() const
Get the map settings.
bool GetCoordinate(const Eigen::Vector2d &coordinate, unsigned int *x, unsigned int *y) const
Given the global coordinate, get the local 2D coordinate of the map cell matrix.
virtual unsigned int GetHeaderBinarySize() const
Get the size of the header in bytes.
unsigned int resolution_id_
The ID of the resolution.
class register implement
Definition arena_queue.h:37