Skip to content

_Mu_new initialize problem  #55

@Needrom

Description

@Needrom

is there some thing wrong with the _Mu_new initialize that i found Pdf<ColumnVector> *posterior = filter->PostGet(); posterior->ExpectedValueGet() here seem not be zero from the beginning.And found the value from posterior->ExpectedValueGet() may come from the class of KalmanFilter from here http://docs.ros.org/en/jade/api/bfl/html/kalmanfilter_8cpp_source.html

Data Showing

here form the data of my terminal output.
we can see the input all be zero at the beginning ,but the posterior Mean seem strange posterior Mean[6](-2.18436e+177,1.32349e-23,1e-07,1e-07,1e-07,1e-07)


df matrix
[6,6]((1,0,0.02,0,0,0),(0,1,0,0.02,0,0),(0,0,1,0,0.02,0),(0,0,0,1,0,0.02),(0,0,0,0,1,0),(0,0,0,0,0,1))
input: [2](0,0)
posterior Mean[6](-2.18436e+177,1.32349e-23,1e-07,1e-07,1e-07,1e-07)
2.4574 -4.29038 1.82393
24 hours ago, the time was 2023-05-23 11:24:38
Printing took -20524us.
df matrix
[6,6]((1,0,0.02,0,0,0),(0,1,0,0.02,0,0),(0,0,1,0,0.02,0),(0,0,0,1,0,0.02),(0,0,0,0,1,0),(0,0,0,0,0,1))
input: [2](0,0)
posterior Mean[6](-2.18392e+177,-0.000858131,4.36784e+171,-8.37904e-06,1e-07,1e-07)
2.51203 -4.18554 1.79193
24 hours ago, the time was 2023-05-23 11:24:38
Printing took -20826us.
df matrix
[6,6]((1,0,0.02,0,0,0),(0,1,0,0.02,0,0),(0,0,1,0,0.02,0),(0,0,0,1,0,0.02),(0,0,0,0,1,0),(0,0,0,0,0,1))
input: [2](0,0)
posterior Mean[6](-2.18326e+177,-0.00211415,1.747e+172,-3.33886e-05,8.73306e+169,-6.7377e-08)
2.51203 -4.18554 1.79193
24 hours ago, the time was 2023-05-23 11:24:38
Printing took -20358us.
df matrix
[6,6]((1,0,0.02,0,0,0),(0,1,0,0.02,0,0),(0,0,1,0,0.02,0),(0,0,0,1,0,0.02),(0,0,0,0,1,0),(0,0,0,0,0,1))
input: [2](0,0)
posterior Mean[6](-2.18239e+177,-0.00378958,4.36749e+172,-8.35105e-05,3.49156e+170,-5.6919e-07)
2.51203 -4.18554 1.79193
24 hours ago, the time was 2023-05-23 11:24:38
Printing took -19543us.
df matrix
[6,6]((1,0,0.02,0,0,0),(0,1,0,0.02,0,0),(0,0,1,0,0.02,0),(0,0,0,1,0,0.02),(0,0,0,0,1,0),(0,0,0,0,0,1))
input: [2](0,0)
posterior Mean[6](-2.1813e+177,-0.00588524,8.73536e+172,-0.000167123,8.72353e+170,-1.57194e-06)
2.51203 -4.18554 1.79193
24 hours ago, the time was 2023-05-23 11:24:38
Printing took -19857us.
df matrix
[6,6]((1,0,0.02,0,0,0),(0,1,0,0.02,0,0),(0,0,1,0,0.02,0),(0,0,0,1,0,0.02),(0,0,0,0,1,0),(0,0,0,0,0,1))
input: [2](0,0)
posterior Mean[6](-2.17998e+177,-0.00840226,1.52882e+173,-0.000292611,1.74338e+171,-3.24135e-06)
2.51203 -4.18554 1.79193
24 hours ago, the time was 2023-05-23 11:24:38
Printing took -19519us.
df matrix
[6,6]((1,0,0.02,0,0,0),(0,1,0,0.02,0,0),(0,0,1,0,0.02,0),(0,0,0,1,0,0.02),(0,0,0,0,1,0),(0,0,0,0,0,1))
input: [2](0,0)
posterior Mean[6](-2.17845e+177,-0.011342,2.4464e+173,-0.000468372,3.04818e+171,-5.74211e-06)
2.53933 -4.09595 1.78735
24 hours ago, the time was 2023-05-23 11:24:38
Printing took -20385us.
df matrix
[6,6]((1,0,0.02,0,0,0),(0,1,0,0.02,0,0),(0,0,1,0,0.02,0),(0,0,0,1,0,0.02),(0,0,0,0,1,0),(0,0,0,0,0,1))
input: [2](0,0)
posterior Mean[6](-2.17669e+177,-0.0146343,3.67015e+173,-0.000697783,4.872e+171,-9.03728e-06)
2.53933 -4.09595 1.78735
24 hours ago, the time was 2023-05-23 11:24:38
Printing took -20670us.
df matrix
[6,6]((1,0,0.02,0,0,0),(0,1,0,0.02,0,0),(0,0,1,0,0.02,0),(0,0,0,1,0,0.02),(0,0,0,0,1,0),(0,0,0,0,0,1))
input: [2](0,0)

and here is the nonlinearanalyticconditionalgaussianmobile.cpp


// $Id: nonlinearanalyticconditionalgaussianmobile.cpp 5823 2005-10-27 13:43:02Z TDeLaet $
// Copyright (C) 2006  Tinne De Laet <first dot last at mech dot kuleuven dot be>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
//

#include "nonlinearanalyticconditionalgaussianmobile_test.h"
#include <wrappers/rng/rng.h> // Wrapper around several rng
                                 // libraries
#define NUMCONDARGUMENTS_MOBILE 2

namespace BFL
{
  using namespace MatrixWrapper;


  NonLinearAnalyticConditionalGaussianMobile::NonLinearAnalyticConditionalGaussianMobile(const Gaussian& additiveNoise)
    : AnalyticConditionalGaussianAdditiveNoise(additiveNoise,NUMCONDARGUMENTS_MOBILE)
  {
  }


  NonLinearAnalyticConditionalGaussianMobile::~NonLinearAnalyticConditionalGaussianMobile(){}

  ColumnVector NonLinearAnalyticConditionalGaussianMobile::ExpectedValueGet() const
  {
    ColumnVector state = ConditionalArgumentGet(0);
    ColumnVector vel  = ConditionalArgumentGet(1);
//    state(1) += cos(state(3)) * vel(1);
//    state(2) += sin(state(3)) * vel(1);
//    state(3) += vel(2);

	state(1) += state(3) * 0.02 + 1/2 * state(5) * pow(0.02, 2);
	state(2) += state(4) * 0.02 + 1/2 * state(6) * pow(0.02, 2);
	state(3) += state(5) * 0.02;
	state(4) += state(6) * 0.02;
	state(5) = vel(1);
	state(6) = vel(2);
	
    return state + AdditiveNoiseMuGet();
  }

  Matrix NonLinearAnalyticConditionalGaussianMobile::dfGet(unsigned int i) const
  {
    if (i==0)//derivative to the first conditional argument (x)
      {
		ColumnVector state = ConditionalArgumentGet(0);
		ColumnVector vel = ConditionalArgumentGet(1);
	//	Matrix df(3,3);
	//	df(1,1)=1;
	//	df(1,2)=0;
	//	df(1,3)=-vel(1)*sin(state(3));
	//	df(2,1)=0;
	//	df(2,2)=1;
	//	df(2,3)=vel(1)*cos(state(3));
	//	df(3,1)=0;
	//	df(3,2)=0;
	//	df(3,3)=1;

		float dt = 0.02;
		
		Matrix df(6,6);
		df(1, 1) = 1;
		df(1, 2) = 0;
		df(1, 3) = dt;
		df(1, 4) = 0;
		df(1, 5) = 1/2 * pow(dt, 2);
		df(1, 6) = 0;

		df(2, 1) = 0;
		df(2, 2) = 1;
		df(2, 3) = 0;
		df(2, 4) = dt;
		df(2, 5) = 0;
		df(2, 6) = 1/2 * pow(dt, 2);

		df(3, 1) = 0;
		df(3, 2) = 0;
		df(3, 3) = 1;
		df(3, 4) = 0;
		df(3, 5) = dt;
		df(3, 6) = 0;		

		df(4, 1) = 0;
		df(4, 2) = 0;
		df(4, 3) = 0;
		df(4, 4) = 1;
		df(4, 5) = 0;
		df(4, 6) = dt;
		
		df(5, 1) = 0;
		df(5, 2) = 0;
		df(5, 3) = 0;
		df(5, 4) = 0;
		df(5, 5) = 1;
		df(6, 6) = 0;

		df(6, 1) = 0;
		df(6, 2) = 0;
		df(6, 3) = 0;
		df(6, 4) = 0;
		df(6, 5) = 0;
		df(6, 6) = 1;

		cout << "df matrix" << endl << df << endl;

		return df;
      }
    else
      {
	if (i >= NumConditionalArgumentsGet())
	  {
	    cerr << "This pdf Only has " << NumConditionalArgumentsGet() << " conditional arguments\n";
	    exit(-BFL_ERRMISUSE);
	  }
	else{
	  cerr << "The df is not implemented for the" <<i << "th conditional argument\n";
	  exit(-BFL_ERRMISUSE);
	}
      }
  }

}//namespace BFL


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions