ed_sensor_integration
beam_model.h
Go to the documentation of this file.
1 #ifndef ED_SENSOR_INTEGRATION_FITTER_BEAM_MODEL_H_
2 #define ED_SENSOR_INTEGRATION_FITTER_BEAM_MODEL_H_
3 
4 #include <geolib/datatypes.h>
5 
6 #include <vector>
7 
8 class BeamModel
9 {
10 
11 public:
12 
13  BeamModel();
14 
15  BeamModel(double w, unsigned int num_beams);
16 
17  void initialize(double w, unsigned int num_beams);
18 
19  inline int CalculateBeam(double x, double depth) const
20  {
21  return (fx_ * x) / depth + half_num_beams_;
22  }
23 
24  inline geo::Vec2 CalculatePoint(int i, double depth) const
25  {
26  return rays_[i] * depth;
27  }
28 
29  inline void CalculatePoints(const std::vector<double>& ranges, std::vector<geo::Vec2>& points)
30  {
31  static double nan = 0.0 / 0.0;
32  points.resize(ranges.size());
33  for(unsigned int i = 0; i < points.size(); ++i)
34  {
35  if (ranges[i] <= 0)
36  points[i] = geo::Vec2(nan, nan);
37  else
38  points[i] = CalculatePoint(i, ranges[i]);
39  }
40  }
41 
42  void RenderModel(const std::vector<std::vector<geo::Vec2> >& contours, const geo::Transform2& pose, int identifier,
43  std::vector<double>& ranges, std::vector<int>& identifiers) const;
44 
45  inline unsigned int num_beams() const { return rays_.size(); }
46  inline float fx() const {return fx_;}
47 
48  inline const std::vector<geo::Vec2>& rays() const { return rays_; }
49 
50 private:
51 
52  double fx_;
53  unsigned int half_num_beams_;
55 };
56 
57 #endif
datatypes.h
std::vector::resize
T resize(T... args)
BeamModel::rays_
std::vector< geo::Vec2 > rays_
Definition: beam_model.h:54
BeamModel::BeamModel
BeamModel()
Definition: beam_model.cpp:5
BeamModel::RenderModel
void RenderModel(const std::vector< std::vector< geo::Vec2 > > &contours, const geo::Transform2 &pose, int identifier, std::vector< double > &ranges, std::vector< int > &identifiers) const
Definition: beam_model.cpp:28
BeamModel::fx_
double fx_
Definition: beam_model.h:52
vector
std::vector::size
T size(T... args)
BeamModel::initialize
void initialize(double w, unsigned int num_beams)
Definition: beam_model.cpp:16
BeamModel::fx
float fx() const
Definition: beam_model.h:46
BeamModel::CalculateBeam
int CalculateBeam(double x, double depth) const
Definition: beam_model.h:19
BeamModel::half_num_beams_
unsigned int half_num_beams_
Definition: beam_model.h:53
geo::Transform2T
geo::Vec2
Vec2T< real > Vec2
BeamModel::num_beams
unsigned int num_beams() const
Definition: beam_model.h:45
BeamModel::CalculatePoint
geo::Vec2 CalculatePoint(int i, double depth) const
Definition: beam_model.h:24
BeamModel::CalculatePoints
void CalculatePoints(const std::vector< double > &ranges, std::vector< geo::Vec2 > &points)
Definition: beam_model.h:29
BeamModel::rays
const std::vector< geo::Vec2 > & rays() const
Definition: beam_model.h:48
geo::Vec2T
BeamModel
Definition: beam_model.h:8