1
1
#include " amcl_3d/mcl.hpp"
2
2
#include " amcl_3d/measurement_model/lidar_measurement_model.hpp"
3
+ #include " amcl_3d/measurement_model/ndt_pose_measurement_model.hpp"
3
4
#include " amcl_3d/resample_noise/normal_distribution.hpp"
4
5
5
6
namespace amcl_3d
@@ -33,8 +34,9 @@ bool Amcl::getParticles(std::shared_ptr<const Particles> &particles_ptr)
33
34
return true ;
34
35
}
35
36
36
- bool Amcl::measureLidar (const pcl::PointCloud<pcl::PointXYZ>::Ptr measuement)
37
+ bool Amcl::measureLidar (const Time &time, const pcl::PointCloud<pcl::PointXYZ>::Ptr measuement)
37
38
{
39
+ #if 0
38
40
if (kd_map_ptr_ == nullptr || measuement == nullptr)
39
41
return false;
40
42
MeasurementState measurement_state;
@@ -43,8 +45,25 @@ bool Amcl::measureLidar(const pcl::PointCloud<pcl::PointXYZ>::Ptr measuement)
43
45
const double sigma = 1.0;
44
46
std::shared_ptr<MeasurementModelInterface> model =
45
47
std::make_shared<LidarMeasurementModel>(kd_map_ptr_, measuement, random_sample_num, max_dist, sigma);
46
- pf_ptr_->measure (model, measurement_state);
48
+ pf_ptr_->measure(model, time, measurement_state);
47
49
50
+ checkResample(measurement_state);
51
+ #endif
52
+ return true ;
53
+ }
54
+
55
+ bool Amcl::measureNdtPose (std::shared_ptr<const Particles> particles_ptr, const Position &position, const Quat &quat, const PoseCovariance &covariance)
56
+ {
57
+ MeasurementState measurement_state;
58
+ std::shared_ptr<MeasurementModelInterface> model =
59
+ std::make_shared<NdtPoseMeasurementModel>(position, quat, covariance);
60
+ pf_ptr_->measure (particles_ptr, model, measurement_state);
61
+ checkResample (measurement_state);
62
+ return true ;
63
+ }
64
+
65
+ bool Amcl::checkResample (const MeasurementState &measurement_state)
66
+ {
48
67
param_.augmented_mcl .w_fast =
49
68
param_.augmented_mcl .w_fast +
50
69
param_.augmented_mcl .alpha_fast * (measurement_state.raw_weight_avg - param_.augmented_mcl .w_fast );
@@ -78,18 +97,28 @@ bool Amcl::measureLidar(const pcl::PointCloud<pcl::PointXYZ>::Ptr measuement)
78
97
std::make_shared<NormalDistribution>(/* avg*/ 0.0 , /* var*/ param_.augmented_mcl .noise_pitch_var );
79
98
std::shared_ptr<ResampleNoiseInterface> yaw_noise_ptr =
80
99
std::make_shared<NormalDistribution>(/* avg*/ 0.0 , /* var*/ param_.augmented_mcl .noise_yaw_var );
81
- ParticleFilterInterface ::NoiseGenerators
100
+ ParticleFilter ::NoiseGenerators
82
101
noise_gens (x_noise_ptr, y_noise_ptr, z_noise_ptr, roll_noise_ptr, pitch_noise_ptr, yaw_noise_ptr);
83
102
// pf_ptr_->resample(pf_ptr_->getParticleNum(), 0.3, noise_gens); // random resample
84
103
// pf_ptr_->resample(pf_ptr_->getParticleNum(), random_sampling_ratio, noise_gens); // random resample
85
104
pf_ptr_->resample (param_.kld_sampling , random_sampling_ratio, noise_gens); // random resample and kld sample
86
105
}
87
- return true ;
88
106
}
89
107
90
108
bool Amcl::predict (std::shared_ptr<PredictionModelInterface> model)
91
109
{
92
- pf_ptr_->predict (model);
110
+ return predict (model, Time::getTimeNow ());
111
+ }
112
+
113
+ bool Amcl::predict (std::shared_ptr<PredictionModelInterface> model, const Time &time)
114
+ {
115
+ pf_ptr_->predict (model, time );
116
+ return true ;
117
+ }
118
+
119
+ bool Amcl::predict (std::shared_ptr<Particles> particles_ptr, std::shared_ptr<PredictionModelInterface> model, const Time &time)
120
+ {
121
+ pf_ptr_->predict (particles_ptr, model, time );
93
122
return true ;
94
123
}
95
124
@@ -112,18 +141,19 @@ bool Amcl::setInitialPose(const Position &position, const Quat &quat, const Pose
112
141
std::make_shared<NormalDistribution>(/* avg*/ 0.0 , /* var*/ covariance (4 , 4 ));
113
142
std::shared_ptr<ResampleNoiseInterface> yaw_noise_ptr =
114
143
std::make_shared<NormalDistribution>(/* avg*/ 0.0 , /* var*/ covariance (5 , 5 ));
115
- ParticleFilterInterface ::NoiseGenerators
144
+ ParticleFilter ::NoiseGenerators
116
145
noise_gens (x_noise_ptr, y_noise_ptr, z_noise_ptr, roll_noise_ptr, pitch_noise_ptr, yaw_noise_ptr);
117
146
return pf_ptr_->init (position, quat, noise_gens, particle_num);
118
147
}
119
148
120
- State Amcl::getMMSE (){
149
+ State Amcl::getMMSE ()
150
+ {
121
151
return pf_ptr_->getMMSE ();
122
152
}
123
153
124
- State Amcl::getMAP (){
154
+ State Amcl::getMAP ()
155
+ {
125
156
return pf_ptr_->getMAP ();
126
157
}
127
158
128
-
129
159
} // namespace amcl_3d
0 commit comments