pointcloud_sanity_check.cpp
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------
2  * A repertory of multi primitive-to-primitive (MP2P) ICP algorithms in C++
3  * Copyright (C) 2018-2024 Jose Luis Blanco, University of Almeria
4  * See LICENSE for license information.
5  * ------------------------------------------------------------------------- */
6 
15 #include <mrpt/core/exceptions.h>
16 #include <mrpt/maps/CPointsMapXYZI.h>
17 #include <mrpt/maps/CPointsMapXYZIRT.h>
18 
19 bool mp2p_icp::pointcloud_sanity_check(const mrpt::maps::CPointsMap& pc, bool printWarnings)
20 {
21  bool ok = true;
22  const size_t n = pc.size();
23 
24  if (auto* pcIRT = dynamic_cast<const mrpt::maps::CPointsMapXYZIRT*>(&pc); pcIRT)
25  {
26  if (pcIRT->hasIntensityField() && pcIRT->getPointsBufferRef_intensity()->size() != n)
27  {
28  ok = false;
29  if (printWarnings)
30  std::cerr << "[mp2p_icp] XYZIRT WARNING: Intensity channel has "
31  "incorrect length="
32  << pcIRT->getPointsBufferRef_intensity()->size() << " expected=" << n
33  << std::endl;
34  }
35  if (pcIRT->hasRingField() && pcIRT->getPointsBufferRef_ring()->size() != n)
36  {
37  ok = false;
38  if (printWarnings)
39  std::cerr << "[mp2p_icp] XYZIRT WARNING: Ring channel has "
40  "incorrect length="
41  << pcIRT->getPointsBufferRef_ring()->size() << " expected=" << n
42  << std::endl;
43  }
44  if (pcIRT->hasTimeField() && pcIRT->getPointsBufferRef_timestamp()->size() != n)
45  {
46  ok = false;
47  if (printWarnings)
48  std::cerr << "[mp2p_icp] XYZIRT WARNING: Timestamp channel has "
49  "incorrect length="
50  << pcIRT->getPointsBufferRef_timestamp()->size() << " expected=" << n
51  << std::endl;
52  }
53  }
54  else if (auto* pcI = dynamic_cast<const mrpt::maps::CPointsMapXYZI*>(&pc); pcI)
55  {
56  if (pcI->getPointsBufferRef_intensity() && pcI->getPointsBufferRef_intensity()->size() != n)
57  {
58  ok = false;
59  if (printWarnings)
60  std::cerr << "[mp2p_icp] XYZI WARNING: Intensity channel has "
61  "incorrect length="
62  << pcI->getPointsBufferRef_intensity()->size() << " expected=" << n
63  << std::endl;
64  }
65  }
66  return ok;
67 }
mp2p_icp::pointcloud_sanity_check
bool pointcloud_sanity_check(const mrpt::maps::CPointsMap &pc, bool printWarnings=true)
Definition: pointcloud_sanity_check.cpp:19
pointcloud_sanity_check.h
Checks for consistent length of field vectors.
ok
ROSCPP_DECL bool ok()


mp2p_icp
Author(s):
autogenerated on Mon May 26 2025 02:45:50