10 #define LASER_MAXBEAMS 2048 26 (
unsigned int beams,
double* angles,
const OrientedPoint& lpose);
28 (
double urange,
double range,
double sigma,
int kernsize,
double lopt,
double aopt,
int iterations,
double likelihoodSigma=1,
unsigned int likelihoodSkip=0 );
50 PARAM_SET_GET(
double, laserMaxRange, protected, public, public)
53 PARAM_SET_GET(
double, gaussianSigma, protected, public, public)
54 PARAM_SET_GET(
double, likelihoodSigma, protected, public, public)
56 PARAM_SET_GET(
double, optAngularDelta, protected, public, public)
57 PARAM_SET_GET(
double, optLinearDelta, protected, public, public)
58 PARAM_SET_GET(
unsigned int, optRecursiveIterations, protected, public, public)
59 PARAM_SET_GET(
unsigned int, likelihoodSkip, protected, public, public)
60 PARAM_SET_GET(
double, llsamplerange, protected, public, public)
61 PARAM_SET_GET(
double, llsamplestep, protected, public, public)
62 PARAM_SET_GET(
double, lasamplerange, protected, public, public)
63 PARAM_SET_GET(
double, lasamplestep, protected, public, public)
66 PARAM_SET_GET(
double, fullnessThreshold, protected, public, public)
67 PARAM_SET_GET(
double, angularOdometryReliability, protected, public, public)
68 PARAM_SET_GET(
double, linearOdometryReliability, protected, public, public)
69 PARAM_SET_GET(
double, freeCellRatio, protected, public, public)
70 PARAM_SET_GET(
unsigned int, initialBeamsSkip, protected, public, public)
77 const double * angle=m_laserAngles+m_initialBeamsSkip;
79 lp.
x+=cos(p.theta)*m_laserPose.x-sin(p.theta)*m_laserPose.y;
80 lp.
y+=sin(p.theta)*m_laserPose.x+cos(p.theta)*m_laserPose.y;
81 lp.
theta+=m_laserPose.theta;
83 double freeDelta=map.getDelta()*m_freeCellRatio;
84 std::list<PointPair> pairs;
86 for (
const double* r=readings+m_initialBeamsSkip; r<readings+
m_laserBeams; r++, angle++){
88 skip=skip>m_likelihoodSkip?0:
skip;
89 if (*r>m_usableRange||*r==0.0)
continue;
92 phit.
x+=*r*cos(lp.
theta+*angle);
93 phit.
y+=*r*sin(lp.
theta+*angle);
96 pfree.
x+=(*r-map.getDelta()*freeDelta)*cos(lp.
theta+*angle);
97 pfree.
y+=(*r-map.getDelta()*freeDelta)*sin(lp.
theta+*angle);
99 IntPoint ipfree=map.world2map(pfree);
102 Point bestCell(0.,0.);
103 for (
int xx=-m_kernelSize; xx<=m_kernelSize; xx++)
104 for (
int yy=-m_kernelSize; yy<=m_kernelSize; yy++){
106 IntPoint pf=pr+ipfree;
111 if (((
double)cell )> m_fullnessThreshold && ((
double)fcell )<m_fullnessThreshold){
112 Point mu=phit-cell.mean();
115 bestCell=cell.mean();
118 if((mu*mu)<(bestMu*bestMu)){
120 bestCell=cell.mean();
127 pairs.push_back(std::make_pair(phit, bestCell));
135 std::cerr <<
"result(" << pairs.size() <<
")=" << result.
x <<
" " << result.
y <<
" " << result.
theta << std::endl;
138 pret.theta=p.theta+result.
theta;
139 pret.theta=atan2(sin(pret.theta), cos(pret.theta));
140 return score(map, p, readings);
145 const double * angle=m_laserAngles+m_initialBeamsSkip;
147 lp.
x+=cos(p.
theta)*m_laserPose.x-sin(p.
theta)*m_laserPose.y;
148 lp.
y+=sin(p.
theta)*m_laserPose.x+cos(p.
theta)*m_laserPose.y;
149 lp.
theta+=m_laserPose.theta;
151 double freeDelta=map.
getDelta()*m_freeCellRatio;
152 for (
const double* r=readings+m_initialBeamsSkip; r<readings+
m_laserBeams; r++, angle++){
154 skip=skip>m_likelihoodSkip?0:
skip;
155 if (skip||*r>m_usableRange||*r==0.0)
continue;
157 phit.
x+=*r*cos(lp.
theta+*angle);
158 phit.
y+=*r*sin(lp.
theta+*angle);
167 for (
int xx=-m_kernelSize; xx<=m_kernelSize; xx++)
168 for (
int yy=-m_kernelSize; yy<=m_kernelSize; yy++){
170 IntPoint pf=pr+ipfree;
175 if (((
double)cell )> m_fullnessThreshold && ((
double)fcell )<m_fullnessThreshold){
176 Point mu=phit-cell.mean();
181 bestMu=(mu*mu)<(bestMu*bestMu)?mu:bestMu;
186 s+=exp(-1./m_gaussianSigma*bestMu*bestMu);
195 const double * angle=m_laserAngles+m_initialBeamsSkip;
197 lp.
x+=cos(p.
theta)*m_laserPose.x-sin(p.
theta)*m_laserPose.y;
198 lp.
y+=sin(p.
theta)*m_laserPose.x+cos(p.
theta)*m_laserPose.y;
199 lp.
theta+=m_laserPose.theta;
200 double noHit=nullLikelihood/(m_likelihoodSigma);
203 double freeDelta=map.
getDelta()*m_freeCellRatio;
204 for (
const double* r=readings+m_initialBeamsSkip; r<readings+
m_laserBeams; r++, angle++){
206 skip=skip>m_likelihoodSkip?0:
skip;
207 if (*r>m_usableRange)
continue;
210 phit.
x+=*r*cos(lp.
theta+*angle);
211 phit.
y+=*r*sin(lp.
theta+*angle);
214 pfree.
x+=(*r-freeDelta)*cos(lp.
theta+*angle);
215 pfree.
y+=(*r-freeDelta)*sin(lp.
theta+*angle);
220 for (
int xx=-m_kernelSize; xx<=m_kernelSize; xx++)
221 for (
int yy=-m_kernelSize; yy<=m_kernelSize; yy++){
223 IntPoint pf=pr+ipfree;
228 if (((
double)cell )>m_fullnessThreshold && ((
double)fcell )<m_fullnessThreshold){
229 Point mu=phit-cell.mean();
234 bestMu=(mu*mu)<(bestMu*bestMu)?mu:bestMu;
239 s+=exp(-1./m_gaussianSigma*bestMu*bestMu);
243 double f=(-1./m_likelihoodSigma)*(bestMu*bestMu);
double optimize(OrientedPoint &pnew, const ScanMatcherMap &map, const OrientedPoint &p, const double *readings) const
double registerScan(ScanMatcherMap &map, const OrientedPoint &p, const double *readings)
Cell & cell(int x, int y)
double icpStep(OrientedPoint &pret, const ScanMatcherMap &map, const OrientedPoint &p, const double *readings) const
#define PARAM_SET_GET(type, name, qualifier, setqualifier, getqualifier)
unsigned int likelihoodAndScore(double &s, double &l, const ScanMatcherMap &map, const OrientedPoint &p, const double *readings) const
const double * laserAngles() const
void setLaserParameters(unsigned int beams, double *angles, const OrientedPoint &lpose)
void invalidateActiveArea()
IntPoint world2map(const Point &p) const
void setMatchingParameters(double urange, double range, double sigma, int kernsize, double lopt, double aopt, int iterations, double likelihoodSigma=1, unsigned int likelihoodSkip=0)
double m_laserAngles[LASER_MAXBEAMS]
unsigned int m_laserBeams
double icpOptimize(OrientedPoint &pnew, const ScanMatcherMap &map, const OrientedPoint &p, const double *readings) const
double score(const ScanMatcherMap &map, const OrientedPoint &p, const double *readings) const
unsigned int laserBeams() const
static const double nullLikelihood
double likelihood(double &lmax, OrientedPoint &mean, CovarianceMatrix &cov, const ScanMatcherMap &map, const OrientedPoint &p, const double *readings)
Covariance3 CovarianceMatrix
void computeActiveArea(ScanMatcherMap &map, const OrientedPoint &p, const double *readings)
bool m_activeAreaComputed