MCPcopy Create free account
hub / github.com/PeterFWS/Structure-PLP-SLAM / create_new_plane

Method create_new_plane

src/PLPSLAM/planar_mapping_module.cc:347–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345 }
346
347 bool Planar_Mapping_module::create_new_plane(eigen_alloc_unord_map<long, data::Plane *> &colorToPlanes)
348 {
349 if (_setVerbose)
350 {
351 spdlog::info("-- PlanarMapping -- trying to create plane");
352 }
353
354 auto before = std::chrono::high_resolution_clock::now();
355
356 bool hasNewPlanes = false;
357 for (auto &color_plane_pair : colorToPlanes)
358 {
359 if (color_plane_pair.second->get_num_landmarks() < MIN_NUMBER_POINTS_BEFORE_RANSAC) // 12
360 {
361 delete color_plane_pair.second;
362 color_plane_pair.second = nullptr;
363 continue;
364 }
365
366 // Conditional ternary operator
367 if (_use_graph_cut
368 ? estimate_plane_sequential_Graph_cut_RANSAC(color_plane_pair.second)
369 : estimate_plane_sequential_RANSAC(color_plane_pair.second))
370 {
371 hasNewPlanes = true;
372 color_plane_pair.second->set_valid(); // set valid, but plane need to be refined
373
374 if (_setVerbose)
375 {
376 double a, b, c, d;
377 color_plane_pair.second->get_equation(a, b, c, d);
378 spdlog::info("\t \t | new plane detected: ({}, {}, {}, {})", a, b, c, d);
379 }
380
381 // save to map database
382 _map_db->add_landmark_plane(color_plane_pair.second);
383 }
384 else
385 {
386 color_plane_pair.second->remove_landmarks_ownership();
387
388 // delete pointer first, then set as null
389 delete color_plane_pair.second;
390 color_plane_pair.second = nullptr;
391
392 if (_setVerbose)
393 {
394 spdlog::info("\t \t | estimate plane through RANSAC failed");
395 }
396 }
397 }
398
399 colorToPlanes.clear();
400
401 auto after = std::chrono::high_resolution_clock::now();
402 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(after - before).count();
403
404 if (_setVerbose)

Callers

nothing calls this directly

Calls 8

infoFunction · 0.85
set_validMethod · 0.80
get_equationMethod · 0.80
add_landmark_planeMethod · 0.80
get_num_landmarksMethod · 0.45
clearMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected