ParticleFilter.h
Go to the documentation of this file.
1 
18 #pragma once
19 
20 #include "Grid3d.h"
21 #include "Parameters.h"
22 
23 #include <random>
24 
25 #include <ros/ros.h>
26 
27 #include <geometry_msgs/Point32.h>
28 #include <geometry_msgs/PoseArray.h>
29 #include <geometry_msgs/PoseWithCovarianceStamped.h>
30 
31 #include <boost/thread.hpp>
32 
33 namespace amcl3d
34 {
36 struct Particle
37 {
39  float x, y, z;
40 
42  float a;
43 
45  float w, wp, wr;
46 
47  Particle() : x(0), y(0), z(0), a(0), w(0), wp(0), wr(0)
48  {
49  }
50 };
51 
53 struct Range
54 {
55  float r, ax, ay, az;
56 
57  Range(const float r_, const float ax_, const float ay_, const float az_) : r(r_), ax(ax_), ay(ay_), az(az_)
58  {
59  }
60 };
61 
63 {
64 public:
65  explicit ParticleFilter();
66  virtual ~ParticleFilter();
67 
68  bool isInitialized() const
69  {
70  return initialized_;
71  }
72 
74  Particle getMean() const
75  {
76  return mean_;
77  }
78 
79  void buildParticlesPoseMsg(const geometry_msgs::Point32& offset, geometry_msgs::PoseArray& msg) const;
80 
82  void init(const int num_particles, const float x_init, const float y_init, const float z_init, const float a_init,
83  const float x_dev, const float y_dev, const float z_dev, const float a_dev);
84 
87  void predict(const double odom_x_mod, const double odom_y_mod, const double odom_z_mod, const double odom_a_mod,
88  const double delta_x, const double delta_y, const double delta_z, const double delta_a);
89 
91  void update(const Grid3d& grid3d, const std::vector<pcl::PointXYZ>& points, const std::vector<Range>& range_data,
92  const double alpha, const double sigma);
93 
95  void resample();
96 
97 private:
98  float computeRangeWeight(const float x, const float y, const float z, const std::vector<Range>& range_data,
99  const double sigma);
100 
101  float ranGaussian(const double mean, const double sigma);
102  float rngUniform(const float range_from, const float range_to);
103 
105  bool initialized_{ false };
106 
108  std::vector<Particle> p_;
110 
112  std::random_device rd_;
113  std::mt19937 generator_;
114 };
115 
116 } // namespace amcl3d
std::random_device rd_
Random number generator.
std::vector< Particle > p_
Particles.
float a
Yaw angle.
Particle getMean() const
Get mean value from particles.
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
Struct that contains the data concerning one particle.
Include Grid.hpp.
Definition: Grid3d.cpp:23
float w
Weight.
Range(const float r_, const float ax_, const float ay_, const float az_)
bool isInitialized() const
float x
Position.
Struct that contains the data concerning one range meaurement.


amcl3d
Author(s): Francisco J.Perez-Grau
autogenerated on Sun Sep 15 2019 04:08:05