Apollo 10.0
自动驾驶开放平台
lossless_map_to_lossy_map.cc 文件参考
lossless_map_to_lossy_map.cc 的引用(Include)关系图:

浏览源代码.

命名空间

namespace  apollo
 class register implement
 
namespace  apollo::localization
 apollo::localization
 
namespace  apollo::localization::msf
 apollo::localization::msf
 

函数

MapNodeIndex apollo::localization::msf::GetMapIndexFromMapFolder (const std::string &map_folder)
 
bool apollo::localization::msf::GetAllMapIndex (const std::string &src_map_folder, const std::string &dst_map_folder, std::list< MapNodeIndex > *buf)
 
int main (int argc, char **argv)
 

函数说明

◆ main()

int main ( int  argc,
char **  argv 
)

在文件 lossless_map_to_lossy_map.cc92 行定义.

92 {
93 boost::program_options::options_description boost_desc("Allowed options");
94 boost_desc.add_options()("help", "produce help message")(
95 "srcdir", boost::program_options::value<std::string>(),
96 "provide the data base dir")("dstdir",
97 boost::program_options::value<std::string>(),
98 "provide the lossy map destination dir");
99
100 boost::program_options::variables_map boost_args;
101 boost::program_options::store(
102 boost::program_options::parse_command_line(argc, argv, boost_desc),
103 boost_args);
104 boost::program_options::notify(boost_args);
105
106 if (boost_args.count("help") || !boost_args.count("srcdir") ||
107 !boost_args.count("dstdir")) {
108 AERROR << boost_desc;
109 return 0;
110 }
111
112 const std::string src_path = boost_args["srcdir"].as<std::string>();
113 const std::string dst_path = boost_args["dstdir"].as<std::string>();
114 std::string src_map_folder = src_path + "/";
115
116 PyramidMapConfig lossless_config("lossless_map");
117 PyramidMapNodePool lossless_map_node_pool(25, 8);
118 lossless_map_node_pool.Initial(&lossless_config);
119
120 PyramidMap lossless_map(&lossless_config);
121 lossless_map.InitMapNodeCaches(12, 24);
122 lossless_map.AttachMapNodePool(&lossless_map_node_pool);
123 if (!lossless_map.SetMapFolderPath(src_map_folder)) {
124 AERROR << "Reflectance map folder is invalid!";
125 return -1;
126 }
127
128 // create lossy map
129 std::string dst_map_folder = dst_path + "/lossy_map/";
130 if (!boost::filesystem::exists(dst_map_folder)) {
131 boost::filesystem::create_directory(dst_map_folder);
132 }
133
134 std::list<MapNodeIndex> buf;
135 apollo::localization::msf::GetAllMapIndex(src_map_folder, dst_map_folder,
136 &buf);
137 AINFO << "index size: " << buf.size();
138
139 PyramidMapConfig config_transform_lossy("lossless_map");
140 config_transform_lossy.Load(src_map_folder + "config.xml");
141 config_transform_lossy.map_version_ = "lossy_map";
142 config_transform_lossy.Save(dst_map_folder + "config.xml");
143
144 AINFO << "lossy map directory structure has built.";
145
146 PyramidMapNodePool lossy_map_node_pool(25, 8);
147 lossy_map_node_pool.Initial(&config_transform_lossy);
148 PyramidMap lossy_map(&config_transform_lossy);
149 lossy_map.InitMapNodeCaches(12, 24);
150 lossy_map.AttachMapNodePool(&lossy_map_node_pool);
151 if (!lossy_map.SetMapFolderPath(dst_map_folder)) {
152 AINFO << "lossy_map config xml not exist";
153 }
154
155 int index = 0;
156 auto itr = buf.begin();
157 for (; itr != buf.end(); ++itr, ++index) {
158 PyramidMapNode* lossless_node =
159 static_cast<PyramidMapNode*>(lossless_map.GetMapNodeSafe(*itr));
160 if (lossless_node == nullptr) {
161 AWARN << "index: " << index << " is a nullptr pointer!";
162 continue;
163 }
164 PyramidMapMatrix& lossless_matrix =
165 static_cast<PyramidMapMatrix&>(lossless_node->GetMapCellMatrix());
166
167 PyramidMapNode* lossy_node =
168 static_cast<PyramidMapNode*>(lossy_map.GetMapNodeSafe(*itr));
169 PyramidMapMatrix& lossy_matrix =
170 static_cast<PyramidMapMatrix&>(lossy_node->GetMapCellMatrix());
171
172 int rows = lossless_config.map_node_size_y_;
173 int cols = lossless_config.map_node_size_x_;
174 for (int row = 0; row < rows; ++row) {
175 for (int col = 0; col < cols; ++col) {
176 const float* intensity = lossless_matrix.GetIntensitySafe(row, col);
177 const float* intensity_var =
178 lossless_matrix.GetIntensityVarSafe(row, col);
179 const unsigned int* count = lossless_matrix.GetCountSafe(row, col);
180 // Read altitude
181 const float* altitude_avg = lossless_matrix.GetAltitudeSafe(row, col);
182 const float* altitude_var =
183 lossless_matrix.GetAltitudeVarSafe(row, col);
184 const float* altitude_ground =
185 lossless_matrix.GetGroundAltitudeSafe(row, col);
186 const unsigned int* ground_count =
187 lossless_matrix.GetGroundCountSafe(row, col);
188 if (intensity) {
189 lossy_matrix.SetIntensitySafe(*intensity, row, col);
190 }
191 if (intensity_var) {
192 lossy_matrix.SetIntensityVarSafe(*intensity_var, row, col);
193 }
194 if (count) {
195 lossy_matrix.SetCountSafe(*count, row, col);
196 }
197 if (altitude_avg) {
198 lossy_matrix.SetAltitudeSafe(*altitude_avg, row, col);
199 }
200 if (altitude_var) {
201 lossy_matrix.SetAltitudeVarSafe(*altitude_var, row, col);
202 }
203 if (altitude_ground) {
204 lossy_matrix.SetGroundAltitudeSafe(*altitude_ground, row, col);
205 }
206 if (ground_count) {
207 lossy_matrix.SetGroundCountSafe(*ground_count, row, col);
208 }
209 }
210 }
211 lossy_node->SetIsChanged(true);
212 }
213
214 return 0;
215}
const BaseMapMatrix & GetMapCellMatrix() const
Get map cell matrix.
void SetIsChanged(bool is)
Set if the map node data has changed.
const unsigned int * GetGroundCountSafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get a ground count value by check.
const float * GetIntensityVarSafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get an intensity variance value by check.
const float * GetIntensitySafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get an intensity value by check.
void SetGroundAltitudeSafe(float ground_altitude, unsigned int row, unsigned int col, unsigned int level=0)
Set an altitude ground value by check.
const float * GetAltitudeSafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get an altitude value by check.
void SetAltitudeSafe(float altitude, unsigned int row, unsigned int col, unsigned int level=0)
Set an altitude value by check.
void SetCountSafe(unsigned int count, unsigned int row, unsigned int col, unsigned int level=0)
Set a count value by check.
const unsigned int * GetCountSafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get a count value by check.
void SetIntensityVarSafe(float intensity_var, unsigned int row, unsigned int col, unsigned int level=0)
Set an intensity variance value by check.
const float * GetAltitudeVarSafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get an altitude variance value by check.
const float * GetGroundAltitudeSafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get an altitude ground value by check.
void SetGroundCountSafe(unsigned int ground_count, unsigned int row, unsigned int col, unsigned int level=0)
Set a ground count value by check.
void SetIntensitySafe(float intensity, unsigned int row, unsigned int col, unsigned int level=0)
Set an intensity value by check.
void SetAltitudeVarSafe(float altitude_var, unsigned int row, unsigned int col, unsigned int level=0)
Set an altitude variance value by check.
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
#define AWARN
Definition log.h:43
bool GetAllMapIndex(const std::string &src_map_folder, const std::string &dst_map_folder, std::list< MapNodeIndex > *buf)