Apollo 11.0
自动驾驶开放平台
base_map.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 <list>
20#include <set>
21#include <string>
22
29
30namespace apollo {
31namespace localization {
32namespace msf {
33
35class BaseMap {
36 public:
38 explicit BaseMap(BaseMapConfig* map_config);
40 virtual ~BaseMap();
41
43 virtual void InitMapNodeCaches(int cacheL1_size, int cahceL2_size);
44
46 BaseMapNode* GetMapNode(const MapNodeIndex& index);
50 bool IsMapNodeExist(const MapNodeIndex& index) const;
51
53 bool SetMapFolderPath(const std::string folder_path);
55 void AddDataset(const std::string dataset_path);
56
63 virtual void PreloadMapArea(const Eigen::Vector3d& location,
64 const Eigen::Vector3d& trans_diff,
65 unsigned int resolution_id, unsigned int zone_id);
71 virtual bool LoadMapArea(const Eigen::Vector3d& seed_pt3d,
72 unsigned int resolution_id, unsigned int zone_id,
73 int filter_size_x, int filter_size_y);
74
76 void AttachMapNodePool(BaseMapNodePool* p_map_node_pool);
77
83 void WriteBinary(FILE* file);
89 void LoadBinary(FILE* file, std::string map_folder_path = "");
90
92 inline const BaseMapConfig& GetConfig() const { return *map_config_; }
94 inline BaseMapConfig& GetConfig() { return *map_config_; }
95
96 protected:
98 void LoadMapNodes(std::set<MapNodeIndex>* map_ids);
100 void PreloadMapNodes(std::set<MapNodeIndex>* map_ids);
102 void LoadMapNodeThreadSafety(MapNodeIndex index, bool is_reserved = false);
103
107 std::list<MapNodeIndex> map_nodes_disk_;
108
118 std::set<MapNodeIndex> map_preloading_task_index_;
120 boost::recursive_mutex map_load_mutex_;
121};
122
123} // namespace msf
124} // namespace localization
125} // namespace apollo
The options of the reflectance map.
The memory pool for the data structure of BaseMapNode.
The data structure of a Node in the map.
The data structure of the base map.
Definition base_map.h:35
void AddDataset(const std::string dataset_path)
Add a dataset path to the map config.
Definition base_map.cc:114
std::list< MapNodeIndex > map_nodes_disk_
All the map nodes in the Map (in the disk).
Definition base_map.h:107
virtual bool LoadMapArea(const Eigen::Vector3d &seed_pt3d, unsigned int resolution_id, unsigned int zone_id, int filter_size_x, int filter_size_y)
Load map nodes for the location calculate of this frame.
Definition base_map.cc:407
virtual ~BaseMap()
The destructor.
Definition base_map.cc:35
void WriteBinary(FILE *file)
Write all the map nodes to a single binary file stream.
BaseMapConfig * map_config_
The map settings.
Definition base_map.h:105
BaseMapConfig & GetConfig()
Get the map config.
Definition base_map.h:94
MapNodeCache< MapNodeIndex, BaseMapNode >::DestroyFunc destroy_func_lvl2_
Definition base_map.h:110
virtual void InitMapNodeCaches(int cacheL1_size, int cahceL2_size)
Init load threadpool and preload threadpool.
Definition base_map.cc:46
void AttachMapNodePool(BaseMapNodePool *p_map_node_pool)
Attach map node pointer.
Definition base_map.cc:232
void LoadBinary(FILE *file, std::string map_folder_path="")
Load all the map nodes from a single binary file stream.
boost::recursive_mutex map_load_mutex_
The mutex for preload map node.
Definition base_map.h:120
bool SetMapFolderPath(const std::string folder_path)
Set the directory of the map.
Definition base_map.cc:101
MapNodeCache< MapNodeIndex, BaseMapNode > * map_node_cache_lvl2_
brief The dynamic map node preloading thread pool pointer.
Definition base_map.h:114
void LoadMapNodes(std::set< MapNodeIndex > *map_ids)
Load map node by index.
Definition base_map.cc:120
std::set< MapNodeIndex > map_preloading_task_index_
@bried Keep the index of preloading nodes.
Definition base_map.h:118
void PreloadMapNodes(std::set< MapNodeIndex > *map_ids)
Load map node by index.
Definition base_map.cc:187
BaseMapNodePool * map_node_pool_
The map node memory pool pointer.
Definition base_map.h:116
bool IsMapNodeExist(const MapNodeIndex &index) const
Check if the map node in the cache.
Definition base_map.cc:97
const BaseMapConfig & GetConfig() const
Get the map config.
Definition base_map.h:92
BaseMapNode * GetMapNodeSafe(const MapNodeIndex &index)
Return the map node, if it's not in the cache, safely load it.
Definition base_map.cc:67
void LoadMapNodeThreadSafety(MapNodeIndex index, bool is_reserved=false)
Load map node by index, thread_safety.
Definition base_map.cc:236
MapNodeCache< MapNodeIndex, BaseMapNode >::DestroyFunc destroy_func_lvl1_
Definition base_map.h:109
virtual void PreloadMapArea(const Eigen::Vector3d &location, const Eigen::Vector3d &trans_diff, unsigned int resolution_id, unsigned int zone_id)
Preload map nodes for the next frame location calculation.
Definition base_map.cc:268
MapNodeCache< MapNodeIndex, BaseMapNode > * map_node_cache_lvl1_
The cache for map node preload.
Definition base_map.h:112
BaseMapNode * GetMapNode(const MapNodeIndex &index)
Get the map node, if it's not in the cache, return false.
Definition base_map.cc:61
The data structure of the LRUCache.
std::function< bool(Element *)> DestroyFunc
class register implement
Definition arena_queue.h:37