Go to the documentation of this file.00001 #include <gmapping/gridfastslam/motionmodel.h>
00002 #include <gmapping/utils/stat.h>
00003 #include <iostream>
00004
00005 #define MotionModelConditioningLinearCovariance 0.01
00006 #define MotionModelConditioningAngularCovariance 0.001
00007
00008 namespace GMapping {
00009
00010
00011
00012 OrientedPoint
00013 MotionModel::drawFromMotion (const OrientedPoint& p, double linearMove, double angularMove) const{
00014 OrientedPoint n(p);
00015 double lm=linearMove + fabs( linearMove ) * sampleGaussian( srr ) + fabs( angularMove ) * sampleGaussian( str );
00016 double am=angularMove + fabs( linearMove ) * sampleGaussian( srt ) + fabs( angularMove ) * sampleGaussian( stt );
00017 n.x+=lm*cos(n.theta+.5*am);
00018 n.y+=lm*sin(n.theta+.5*am);
00019 n.theta+=am;
00020 n.theta=atan2(sin(n.theta), cos(n.theta));
00021 return n;
00022 }
00023
00024 OrientedPoint
00025 MotionModel::drawFromMotion(const OrientedPoint& p, const OrientedPoint& pnew, const OrientedPoint& pold) const{
00026 double sxy=0.3*srr;
00027 OrientedPoint delta=absoluteDifference(pnew, pold);
00028 OrientedPoint noisypoint(delta);
00029 noisypoint.x+=sampleGaussian(srr*fabs(delta.x)+str*fabs(delta.theta)+sxy*fabs(delta.y));
00030 noisypoint.y+=sampleGaussian(srr*fabs(delta.y)+str*fabs(delta.theta)+sxy*fabs(delta.x));
00031 noisypoint.theta+=sampleGaussian(stt*fabs(delta.theta)+srt*sqrt(delta.x*delta.x+delta.y*delta.y));
00032 noisypoint.theta=fmod(noisypoint.theta, 2*M_PI);
00033 if (noisypoint.theta>M_PI)
00034 noisypoint.theta-=2*M_PI;
00035 return absoluteSum(p,noisypoint);
00036 }
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 Covariance3 MotionModel::gaussianApproximation(const OrientedPoint& pnew, const OrientedPoint& pold) const{
00062 OrientedPoint delta=absoluteDifference(pnew,pold);
00063 double linearMove=sqrt(delta.x*delta.x+delta.y*delta.y);
00064 double angularMove=fabs(delta.x);
00065 double s11=srr*srr*linearMove*linearMove;
00066 double s22=stt*stt*angularMove*angularMove;
00067 double s12=str*angularMove*srt*linearMove;
00068 Covariance3 cov;
00069 double s=sin(pold.theta),c=cos(pold.theta);
00070 cov.xx=c*c*s11+MotionModelConditioningLinearCovariance;
00071 cov.yy=s*s*s11+MotionModelConditioningLinearCovariance;
00072 cov.tt=s22+MotionModelConditioningAngularCovariance;
00073 cov.xy=s*c*s11;
00074 cov.xt=c*s12;
00075 cov.yt=s*s12;
00076 return cov;
00077 }
00078
00079 };
00080