Bayes Filters Library
InitSurveillanceAreaGrid.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2019 Istituto Italiano di Tecnologia (IIT)
3  *
4  * This software may be modified and distributed under the terms of the
5  * BSD 3-Clause license. See the accompanying LICENSE file for details.
6  */
7 
9 
10 using namespace bfl;
11 using namespace Eigen;
12 
13 
15 (
16  const double surv_x_inf,
17  const double surv_x_sup,
18  const double surv_y_inf,
19  const double surv_y_sup,
20  const unsigned int num_particle_x,
21  const unsigned int num_particle_y
22 ) noexcept :
23  surv_x_inf_(surv_x_inf),
24  surv_x_sup_(surv_x_sup),
25  surv_y_inf_(surv_y_inf),
26  surv_y_sup_(surv_y_sup),
27  num_particle_x_(num_particle_x),
28  num_particle_y_(num_particle_y)
29 { }
30 
31 
33 (
34  const double surv_x,
35  const double surv_y,
36  const unsigned int num_particle_x,
37  const unsigned int num_particle_y
38 ) noexcept :
39  InitSurveillanceAreaGrid(0, surv_x, 0, surv_y,
40  num_particle_x, num_particle_y)
41 { }
42 
43 
45 {
46  int num_particle = particles.state().cols();
47  if (num_particle != num_particle_x_ * num_particle_y_)
48  return false;
49 
50  double delta_surv_x = surv_x_sup_ - surv_x_inf_;
51  double delta_surv_y = surv_y_sup_ - surv_y_inf_;
52 
53  for (int i = 0; i < num_particle_x_; ++i)
54  for (int j = 0; j < num_particle_y_; ++j)
55  particles.state().col(i*num_particle_y_ + j) << static_cast<double>((delta_surv_x / (num_particle_x_ - 1)) * i + surv_x_inf_),
56  0,
57  static_cast<double>((delta_surv_y / (num_particle_y_ - 1)) * j + surv_y_inf_),
58  0;
59 
60  particles.weight().setConstant(-std::log(num_particle));
61 
62  return true;
63 }
bfl::InitSurveillanceAreaGrid
Definition: InitSurveillanceAreaGrid.h:18
bfl
Port of boost::any for C++11 compilers.
Definition: AdditiveMeasurementModel.h:13
InitSurveillanceAreaGrid.h
bfl::InitSurveillanceAreaGrid::InitSurveillanceAreaGrid
InitSurveillanceAreaGrid(const double surv_x_inf, const double surv_x_sup, const double surv_y_inf, const double surv_y_sup, const unsigned int num_particle_x, const unsigned int num_particle_y) noexcept
Definition: InitSurveillanceAreaGrid.cpp:15
bfl::ParticleSet::state
Eigen::Ref< Eigen::MatrixXd > state()
Definition: ParticleSet.cpp:84
bfl::InitSurveillanceAreaGrid::initialize
bool initialize(bfl::ParticleSet &particles) override
Definition: InitSurveillanceAreaGrid.cpp:44
bfl::ParticleSet
Definition: ParticleSet.h:20
bfl::GaussianMixture::weight
Eigen::Ref< Eigen::VectorXd > weight()
Definition: GaussianMixture.cpp:166