-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsimulator.cpp
More file actions
executable file
·28 lines (21 loc) · 906 Bytes
/
simulator.cpp
File metadata and controls
executable file
·28 lines (21 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "simulator.h"
using namespace Eigen;
Simulator::Simulator(ReadParaVehicle& param_vehicle):observation_model_(param_vehicle, true), process_model_(param_vehicle, true){};
void Simulator::Initialize(const State& x0, const StateCovariance& P0)
{
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); //different seed for different initial random number
Eigen::EigenMultivariateNormal<double> initialConditionSampler(Eigen::MatrixXd::Zero(N,1),P0,false,seed);
x_ = x0 + initialConditionSampler.samples(1);
}
void Simulator::Step(int count)
{
x_ = process_model_.Predict(x_,count);
z_ = observation_model_.Predict(x_);
}
//compute the average and variance of random number. It should be similar to the parameters in initialConditionSampler
State Simulator::get_ini_state_noise(){
return ini_state_noise_;
};
unsigned Simulator::get_seed(){
return seed_;
}