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 
20  const mrpt::maps::CPointsMap& pc, bool printWarnings)
21 {
22  bool ok = true;
23  const size_t n = pc.size();
24 
25  if (auto* pcIRT = dynamic_cast<const mrpt::maps::CPointsMapXYZIRT*>(&pc);
26  pcIRT)
27  {
28  if (pcIRT->hasIntensityField() &&
29  pcIRT->getPointsBufferRef_intensity()->size() != n)
30  {
31  ok = false;
32  if (printWarnings)
33  std::cerr << "[mp2p_icp] XYZIRT WARNING: Intensity channel has "
34  "incorrect length="
35  << pcIRT->getPointsBufferRef_intensity()->size()
36  << " expected=" << n << std::endl;
37  }
38  if (pcIRT->hasRingField() &&
39  pcIRT->getPointsBufferRef_ring()->size() != n)
40  {
41  ok = false;
42  if (printWarnings)
43  std::cerr << "[mp2p_icp] XYZIRT WARNING: Ring channel has "
44  "incorrect length="
45  << pcIRT->getPointsBufferRef_ring()->size()
46  << " expected=" << n << std::endl;
47  }
48  if (pcIRT->hasTimeField() &&
49  pcIRT->getPointsBufferRef_timestamp()->size() != n)
50  {
51  ok = false;
52  if (printWarnings)
53  std::cerr << "[mp2p_icp] XYZIRT WARNING: Timestamp channel has "
54  "incorrect length="
55  << pcIRT->getPointsBufferRef_timestamp()->size()
56  << " expected=" << n << std::endl;
57  }
58  }
59  else if (auto* pcI = dynamic_cast<const mrpt::maps::CPointsMapXYZI*>(&pc);
60  pcI)
61  {
62  if (pcI->getPointsBufferRef_intensity() &&
63  pcI->getPointsBufferRef_intensity()->size() != n)
64  {
65  ok = false;
66  if (printWarnings)
67  std::cerr << "[mp2p_icp] XYZI WARNING: Intensity channel has "
68  "incorrect length="
69  << pcI->getPointsBufferRef_intensity()->size()
70  << " expected=" << n << std::endl;
71  }
72  }
73  return ok;
74 }
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 Thu Dec 26 2024 03:48:12