10 #include <gmapping/scanmatcher/scanmatcher_export.h> 11 #define LASER_MAXBEAMS 2048 26 void setLaserParameters
27 (
unsigned int beams,
double* angles,
const OrientedPoint& lpose);
28 void setMatchingParameters
29 (
double urange,
double range,
double sigma,
int kernsize,
double lopt,
double aopt,
int iterations,
double likelihoodSigma=1,
unsigned int likelihoodSkip=0 );
30 void invalidateActiveArea();
35 inline unsigned int likelihoodAndScore(
double& s,
double& l,
const ScanMatcherMap& map,
const OrientedPoint& p,
const double* readings)
const;
38 inline const double*
laserAngles()
const {
return m_laserAngles; }
39 inline unsigned int laserBeams()
const {
return m_laserBeams; }
51 PARAM_SET_GET(
double, laserMaxRange, protected, public, public)
54 PARAM_SET_GET(
double, gaussianSigma, protected, public, public)
55 PARAM_SET_GET(
double, likelihoodSigma, protected, public, public)
57 PARAM_SET_GET(
double, optAngularDelta, protected, public, public)
58 PARAM_SET_GET(
double, optLinearDelta, protected, public, public)
59 PARAM_SET_GET(
unsigned int, optRecursiveIterations, protected, public, public)
60 PARAM_SET_GET(
unsigned int, likelihoodSkip, protected, public, public)
61 PARAM_SET_GET(
double, llsamplerange, protected, public, public)
62 PARAM_SET_GET(
double, llsamplestep, protected, public, public)
63 PARAM_SET_GET(
double, lasamplerange, protected, public, public)
64 PARAM_SET_GET(
double, lasamplestep, protected, public, public)
67 PARAM_SET_GET(
double, fullnessThreshold, protected, public, public)
68 PARAM_SET_GET(
double, angularOdometryReliability, protected, public, public)
69 PARAM_SET_GET(
double, linearOdometryReliability, protected, public, public)
70 PARAM_SET_GET(
double, freeCellRatio, protected, public, public)
71 PARAM_SET_GET(
unsigned int, initialBeamsSkip, protected, public, public)
78 const double * angle=m_laserAngles+m_initialBeamsSkip;
80 lp.
x+=cos(p.theta)*m_laserPose.x-sin(p.theta)*m_laserPose.y;
81 lp.
y+=sin(p.theta)*m_laserPose.x+cos(p.theta)*m_laserPose.y;
82 lp.
theta+=m_laserPose.theta;
84 double freeDelta=map.getDelta()*m_freeCellRatio;
85 std::list<PointPair> pairs;
87 for (
const double* r=readings+m_initialBeamsSkip; r<readings+m_laserBeams; r++, angle++){
89 skip=skip>m_likelihoodSkip?0:
skip;
90 if (*r>m_usableRange||*r==0.0)
continue;
93 phit.
x+=*r*cos(lp.
theta+*angle);
94 phit.
y+=*r*sin(lp.
theta+*angle);
97 pfree.
x+=(*r-map.getDelta()*freeDelta)*cos(lp.
theta+*angle);
98 pfree.
y+=(*r-map.getDelta()*freeDelta)*sin(lp.
theta+*angle);
100 IntPoint ipfree=map.world2map(pfree);
103 Point bestCell(0.,0.);
104 for (
int xx=-m_kernelSize; xx<=m_kernelSize; xx++)
105 for (
int yy=-m_kernelSize; yy<=m_kernelSize; yy++){
107 IntPoint pf=pr+ipfree;
112 if (((
double)cell )> m_fullnessThreshold && ((
double)fcell )<m_fullnessThreshold){
113 Point mu=phit-cell.mean();
116 bestCell=cell.mean();
119 if((mu*mu)<(bestMu*bestMu)){
121 bestCell=cell.mean();
128 pairs.push_back(std::make_pair(phit, bestCell));
136 std::cerr <<
"result(" << pairs.size() <<
")=" << result.
x <<
" " << result.
y <<
" " << result.
theta << std::endl;
139 pret.theta=p.theta+result.
theta;
140 pret.theta=atan2(sin(pret.theta), cos(pret.theta));
141 return score(map, p, readings);
146 const double * angle=m_laserAngles+m_initialBeamsSkip;
148 lp.
x+=cos(p.
theta)*m_laserPose.x-sin(p.
theta)*m_laserPose.y;
149 lp.
y+=sin(p.
theta)*m_laserPose.x+cos(p.
theta)*m_laserPose.y;
150 lp.
theta+=m_laserPose.theta;
152 double freeDelta=map.
getDelta()*m_freeCellRatio;
153 for (
const double* r=readings+m_initialBeamsSkip; r<readings+m_laserBeams; r++, angle++){
155 skip=skip>m_likelihoodSkip?0:
skip;
156 if (skip||*r>m_usableRange||*r==0.0)
continue;
158 phit.
x+=*r*cos(lp.
theta+*angle);
159 phit.
y+=*r*sin(lp.
theta+*angle);
168 for (
int xx=-m_kernelSize; xx<=m_kernelSize; xx++)
169 for (
int yy=-m_kernelSize; yy<=m_kernelSize; yy++){
171 IntPoint pf=pr+ipfree;
176 if (((
double)cell )> m_fullnessThreshold && ((
double)fcell )<m_fullnessThreshold){
177 Point mu=phit-cell.mean();
182 bestMu=(mu*mu)<(bestMu*bestMu)?mu:bestMu;
187 s+=exp(-1./m_gaussianSigma*bestMu*bestMu);
196 const double * angle=m_laserAngles+m_initialBeamsSkip;
198 lp.
x+=cos(p.
theta)*m_laserPose.x-sin(p.
theta)*m_laserPose.y;
199 lp.
y+=sin(p.
theta)*m_laserPose.x+cos(p.
theta)*m_laserPose.y;
200 lp.
theta+=m_laserPose.theta;
201 double noHit=nullLikelihood/(m_likelihoodSigma);
204 double freeDelta=map.
getDelta()*m_freeCellRatio;
205 for (
const double* r=readings+m_initialBeamsSkip; r<readings+m_laserBeams; r++, angle++){
207 skip=skip>m_likelihoodSkip?0:
skip;
208 if (*r>m_usableRange)
continue;
211 phit.
x+=*r*cos(lp.
theta+*angle);
212 phit.
y+=*r*sin(lp.
theta+*angle);
215 pfree.
x+=(*r-freeDelta)*cos(lp.
theta+*angle);
216 pfree.
y+=(*r-freeDelta)*sin(lp.
theta+*angle);
221 for (
int xx=-m_kernelSize; xx<=m_kernelSize; xx++)
222 for (
int yy=-m_kernelSize; yy<=m_kernelSize; yy++){
224 IntPoint pf=pr+ipfree;
229 if (((
double)cell )>m_fullnessThreshold && ((
double)fcell )<m_fullnessThreshold){
230 Point mu=phit-cell.mean();
235 bestMu=(mu*mu)<(bestMu*bestMu)?mu:bestMu;
240 s+=exp(-1./m_gaussianSigma*bestMu*bestMu);
244 double f=(-1./m_likelihoodSigma)*(bestMu*bestMu);
Cell & cell(int x, int y)
#define PARAM_SET_GET(type, name, qualifier, setqualifier, getqualifier)
unsigned int laserBeams() const
double icpStep(OrientedPoint &retval, const PointPairContainer &container)
unsigned int likelihoodAndScore(double &s, double &l, const ScanMatcherMap &map, const OrientedPoint &p, const double *readings) const
const double * laserAngles() const
unsigned int m_laserBeams
double score(const ScanMatcherMap &map, const OrientedPoint &p, const double *readings) const
static const double nullLikelihood
Covariance3 CovarianceMatrix
IntPoint world2map(const Point &p) const
bool m_activeAreaComputed