00001
00002 #ifndef DDF_ACCELEROMETERSIMU_HPP
00003 #define DDF_ACCELEROMETERSIMU_HPP
00004
00005 #include "ddfsimu/sensorsimu.hpp"
00006 #include "ddfsimu/accelmotion.hpp"
00007 #include "ddf/tools.hpp"
00008
00009 namespace jafar
00010 {
00011 namespace ddfsimu
00012 {
00013
00020 template<typename T_OBS>
00021 class AcceleroSimu : public SensorSimu<T_OBS>
00022 {
00023 VEC m_biases;
00024 bool m_with_biases;
00025
00026 public:
00032 AcceleroSimu(unsigned short x_size, unsigned short z_size, bool use_biases)
00033 : SensorSimu<T_OBS>(x_size, z_size),
00034 m_biases(z_size),
00035 m_with_biases(use_biases)
00036 {
00037 JFR_PRECOND(z_size <= 3, "z_size > 3");
00038
00039 this->m_type_name = SENSOR_ACCEL;
00040 m_biases.clear();
00041
00042 this->Hx.clear();
00043 this->Hx(0, AccelMotion::SV_AX) = 1.;
00044 if (m_with_biases) this->Hx(0, AccelMotion::SV_BAX) = 1.;
00045 if(z_size > 1) { this->Hx(1, AccelMotion::SV_AY) = 1.; if (m_with_biases) this->Hx(1, AccelMotion::SV_BAY) = 1.;}
00046 if(z_size > 2) { this->Hx(2, AccelMotion::SV_AZ) = 1.; if (m_with_biases) this->Hx(2, AccelMotion::SV_BAZ) = 1.;}
00047 }
00048
00049 virtual ~AcceleroSimu() {}
00050
00051 bool WithBiases() { return m_with_biases; }
00052 void SetBiases(VEC const& biases) { m_biases = biases; }
00053 void Perceive(VEC const& proc_state, time t)
00054 {
00055 VEC measured_accel(this->GetMeasureSize());
00056
00057 PerceiveRet(proc_state, measured_accel);
00058 AddMeasurementWithNoise(t,t+this->GetProcTime(),measured_accel);
00059 }
00060
00062 void PerceiveRet(VEC const& proc_state, VEC & result) const {
00063
00064 // Make sure biases are zero before in proc_state before calling this function
00065 noalias(result) = prod(this->Hx, proc_state);
00066 if(m_with_biases) result += m_biases;
00067 }
00068 void PrintObservationModel() {
00069 JFR_DEBUG("Observation model of sensor " << this->GetID() << " (" << this->GetName() << ")" << "\n");
00070 PrettyPrintMatrix(this->Hx, "Hx");
00071 }
00072 };
00073
00080 class AcceleroSimuUncorr : public AcceleroSimu<Bayesian_filter::Linear_uncorrelated_observe_model>
00081 {
00082
00083 public:
00084 AcceleroSimuUncorr(unsigned short x_size, unsigned short z_size, bool with_biases = false):
00085 AcceleroSimu<Bayesian_filter::Linear_uncorrelated_observe_model>(x_size, z_size, with_biases){}
00086 virtual ~AcceleroSimuUncorr() {}
00087
00088 void ComputeInformation(VEC const& z, VEC &i, MSYM &I) { compute_information_uncorr(*this, z, i, I); }
00089 void SetSensorModelVar(VEC const& var) { Zv.clear(); Zv = var; }
00090 void PrintObservationModel()
00091 {
00092 AcceleroSimu<Bayesian_filter::Linear_uncorrelated_observe_model>::PrintObservationModel();
00093 PrettyPrintVector(this->Zv, "Zv");
00094 }
00095 };
00096
00103 class AcceleroSimuCorr : public AcceleroSimu<Bayesian_filter::Linear_correlated_observe_model>
00104 {
00105
00106 public:
00107 AcceleroSimuCorr(unsigned short x_size, unsigned short z_size, bool with_biases = false):
00108 AcceleroSimu<Bayesian_filter::Linear_correlated_observe_model>(x_size, z_size, with_biases){}
00109 virtual ~AcceleroSimuCorr() {}
00110
00111 void ComputeInformation(VEC const& z, VEC &i, MSYM &I) { compute_information_corr(*this, z, m_sp, i, I); }
00112 void SetSensorModelCov(MSYM const& cov) { Z = cov; }
00113 void PrintObservationModel()
00114 {
00115 AcceleroSimu<Bayesian_filter::Linear_correlated_observe_model>::PrintObservationModel();
00116 PrettyPrintMatrix(Z, "R");
00117 }
00118 };
00119
00120 } // namespace ddfsimu
00121 } // namespace jafar
00122 #endif