15 #include <Eigen/Dense>
18 using namespace Eigen;
23 unsigned int num_particle,
24 std::size_t state_size_linear,
25 std::size_t state_size_circular,
26 std::unique_ptr<ParticleSetInitialization> initialization,
27 std::unique_ptr<PFPrediction> prediction,
28 std::unique_ptr<PFCorrection> correction,
29 std::unique_ptr<Resampling> resampling
31 ParticleFilter(std::move(initialization), std::move(prediction), std::move(correction), std::move(resampling)),
32 num_particle_(num_particle),
33 state_size_(state_size_linear + state_size_circular),
34 pred_particle_(num_particle_, state_size_linear, state_size_circular),
35 cor_particle_(num_particle_, state_size_linear, state_size_circular)
41 unsigned int num_particle,
42 std::size_t state_size_linear,
43 std::unique_ptr<ParticleSetInitialization> initialization,
44 std::unique_ptr<PFPrediction> prediction,
45 std::unique_ptr<PFCorrection> correction,
46 std::unique_ptr<Resampling> resampling
48 SIS(num_particle, state_size_linear, 0, std::move(initialization), std::move(prediction), std::move(correction), std::move(resampling))
54 return initialization().initialize(pred_particle_);
60 if (step_number() != 0)
61 prediction().predict(cor_particle_, pred_particle_);
63 if (correction().freeze_measurements())
65 correction().correct(pred_particle_, cor_particle_);
71 cor_particle_ = pred_particle_;
75 if (resampling().neff(cor_particle_.weight()) <
static_cast<double>(num_particle_)/3.0)
77 ParticleSet res_particle(num_particle_, state_size_);
78 VectorXi res_parent(num_particle_, 1);
80 resampling().resample(cor_particle_, res_particle, res_parent);
82 cor_particle_ = res_particle;
93 std::vector<std::string>
SIS::log_file_names(
const std::string& folder_path,
const std::string& file_name_prefix)
95 return { folder_path +
"/" + file_name_prefix +
"_pred_particles",
96 folder_path +
"/" + file_name_prefix +
"_pred_weights",
97 folder_path +
"/" + file_name_prefix +
"_cor_particles",
98 folder_path +
"/" + file_name_prefix +
"_cor_weights" };
104 logger(pred_particle_.state().transpose(), pred_particle_.weight().transpose(),
105 cor_particle_.state().transpose(), cor_particle_.weight().transpose());