MRPT  2.0.4
PF_aux_structs.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <iostream>
12 #include <iterator>
13 #include <vector>
14 
16 {
17 using namespace mrpt;
18 using namespace mrpt::math;
19 using namespace std;
20 
21 /** Auxiliary structure used in KLD-sampling in particle filters \sa
22  * CPosePDFParticles, CMultiMetricMapPDF */
23 struct TPoseBin2D
24 {
25  TPoseBin2D() = default;
26  /** Bin indices */
27  int x{0}, y{0}, phi{0};
28 
29  /** less-than ordering of bins for usage in STL containers */
30  struct lt_operator
31  {
32  inline bool operator()(const TPoseBin2D& s1, const TPoseBin2D& s2) const
33  {
34  if (s1.x < s2.x) return true;
35  if (s1.x > s2.x) return false;
36  if (s1.y < s2.y) return true;
37  if (s1.y > s2.y) return false;
38  return s1.phi < s2.phi;
39  }
40  };
41 };
42 
43 /** Auxiliary structure */
44 struct TPathBin2D
45 {
46  std::vector<TPoseBin2D> bins;
47 
48  /** less-than ordering of bins for usage in STL containers */
49  struct lt_operator
50  {
51  bool operator()(const TPathBin2D& s1, const TPathBin2D& s2) const
52  {
53  ASSERT_(s1.bins.size() == s2.bins.size());
54  for (size_t i = 0; i < s1.bins.size(); i++)
55  {
56  if (s1.bins[i].x < s2.bins[i].x) return true;
57  if (s1.bins[i].x > s2.bins[i].x) return false;
58  if (s1.bins[i].y < s2.bins[i].y) return true;
59  if (s1.bins[i].y > s2.bins[i].y) return false;
60  if (s1.bins[i].phi < s2.bins[i].phi) return true;
61  if (s1.bins[i].phi > s2.bins[i].phi) return false;
62  // else, keep comparing:
63  }
64  return false; // If they're exactly equal, s1 is NOT < s2.
65  }
66  };
67 };
68 
69 /** Auxiliary structure used in KLD-sampling in particle filters \sa
70  * CPosePDFParticles, CMultiMetricMapPDF */
71 struct TPoseBin3D
72 {
73  TPoseBin3D() = default;
74  /** Bin indices */
75  int x{0}, y{0}, z{0}, yaw{0}, pitch{0}, roll{0};
76 
77  /** less-than ordering of bins for usage in STL containers */
78  struct lt_operator
79  {
80  bool operator()(const TPoseBin3D& s1, const TPoseBin3D& s2) const
81  {
82  if (s1.x < s2.x) return true;
83  if (s1.x > s2.x) return false;
84  if (s1.y < s2.y) return true;
85  if (s1.y > s2.y) return false;
86  if (s1.z < s2.z) return true;
87  if (s1.z > s2.z) return false;
88  if (s1.yaw < s2.yaw) return true;
89  if (s1.yaw > s2.yaw) return false;
90  if (s1.pitch < s2.pitch) return true;
91  if (s1.pitch > s2.pitch) return false;
92  return s1.roll < s2.roll;
93  }
94  };
95 };
96 
97 } // namespace mrpt::slam::detail
less-than ordering of bins for usage in STL containers
less-than ordering of bins for usage in STL containers
STL namespace.
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
bool operator()(const TPathBin2D &s1, const TPathBin2D &s2) const
This base provides a set of functions for maths stuff.
Auxiliary structure.
bool operator()(const TPoseBin3D &s1, const TPoseBin3D &s2) const
Auxiliary structure used in KLD-sampling in particle filters.
Auxiliary structure used in KLD-sampling in particle filters.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
less-than ordering of bins for usage in STL containers
std::vector< TPoseBin2D > bins
bool operator()(const TPoseBin2D &s1, const TPoseBin2D &s2) const



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020