state_data.h
Go to the documentation of this file.
1 #ifndef SLAM_CTOR_CORE_STATE_DATA_H
2 #define SLAM_CTOR_CORE_STATE_DATA_H
3 
4 #include <ostream>
5 #include "../geometry_utils.h"
6 
7 struct Occupancy {
8  double prob_occ;
10 
11  // TODO: is NaN better for as a dflt value?
12  constexpr Occupancy(double prob = 0, double quality = 0)
13  : prob_occ(prob), estimation_quality(quality) {}
14 
15  operator double() const { return prob_occ; }
16 
17  bool operator==(const Occupancy &that) const {
18  if (!is_valid() && !that.is_valid()) { return true; }
19  return are_equal(prob_occ, that.prob_occ) &&
20  are_equal(estimation_quality, that.estimation_quality);
21  }
22 
23  bool is_valid() const {
24  return !std::isnan(prob_occ) && !std::isnan(estimation_quality);
25  }
26 
27  static Occupancy invalid() {
28  static Occupancy invalid{std::numeric_limits<double>::quiet_NaN(),
29  std::numeric_limits<double>::quiet_NaN()};
30  return invalid;
31  }
32 
33 };
34 
35 inline std::ostream &operator<<(std::ostream &stream, const Occupancy &occ) {
36  if (!occ.is_valid()) {
37  return stream << "invalid";
38  }
39  return stream << "{" << occ.prob_occ << ", " << occ.estimation_quality << "}";
40 }
41 
46  double quality;
47 };
48 
49 #endif
double prob_occ
Definition: state_data.h:8
CONSTEXPR bool are_equal(const T &a, const T &b, const T &eps)
Definition: math_utils.h:17
bool operator==(const Occupancy &that) const
Definition: state_data.h:17
static Occupancy invalid()
Definition: state_data.h:27
bool is_valid() const
Definition: state_data.h:23
double estimation_quality
Definition: state_data.h:9
std::ostream & operator<<(std::ostream &stream, const Occupancy &occ)
Definition: state_data.h:35
constexpr Occupancy(double prob=0, double quality=0)
Definition: state_data.h:12


slam_constructor
Author(s): JetBrains Research, OSLL team
autogenerated on Mon Jun 10 2019 15:08:25