7
7
#include < gmapping/utils/stat.h>
8
8
#include < iostream>
9
9
#include < gmapping/utils/gvalues.h>
10
- #define LASER_MAXBEAMS 2048
10
+ #include < vector >
11
11
12
12
namespace GMapping {
13
13
@@ -34,7 +34,7 @@ class ScanMatcher{
34
34
inline unsigned int likelihoodAndScore (double & s, double & l, const ScanMatcherMap& map, const OrientedPoint& p, const double * readings) const ;
35
35
double likelihood (double & lmax, OrientedPoint& mean, CovarianceMatrix& cov, const ScanMatcherMap& map, const OrientedPoint& p, const double * readings);
36
36
double likelihood (double & _lmax, OrientedPoint& _mean, CovarianceMatrix& _cov, const ScanMatcherMap& map, const OrientedPoint& p, Gaussian3& odometry, const double * readings, double gain=180 .);
37
- inline const double * laserAngles () const { return m_laserAngles; }
37
+ inline const double * laserAngles () const { return m_laserAngles. data () ; }
38
38
inline unsigned int laserBeams () const { return m_laserBeams; }
39
39
40
40
static const double nullLikelihood;
@@ -44,7 +44,7 @@ class ScanMatcher{
44
44
45
45
/* *laser parameters*/
46
46
unsigned int m_laserBeams;
47
- double m_laserAngles[LASER_MAXBEAMS] ;
47
+ std::vector< double > m_laserAngles;
48
48
// OrientedPoint m_laserPose;
49
49
PARAM_SET_GET (OrientedPoint, laserPose, protected, public, public)
50
50
PARAM_SET_GET (double , laserMaxRange, protected, public, public)
@@ -74,7 +74,7 @@ class ScanMatcher{
74
74
};
75
75
76
76
inline double ScanMatcher::icpStep (OrientedPoint & pret, const ScanMatcherMap& map, const OrientedPoint& p, const double * readings) const {
77
- const double * angle=m_laserAngles+m_initialBeamsSkip;
77
+ std::vector< double >::const_iterator angle=m_laserAngles. begin () +m_initialBeamsSkip;
78
78
OrientedPoint lp=p;
79
79
lp.x +=cos (p.theta )*m_laserPose.x -sin (p.theta )*m_laserPose.y ;
80
80
lp.y +=sin (p.theta )*m_laserPose.x +cos (p.theta )*m_laserPose.y ;
@@ -89,12 +89,12 @@ inline double ScanMatcher::icpStep(OrientedPoint & pret, const ScanMatcherMap& m
89
89
if (*r>m_usableRange||*r==0.0 ) continue ;
90
90
if (skip) continue ;
91
91
Point phit=lp;
92
- phit.x +=*r*cos (lp.theta +*angle);
93
- phit.y +=*r*sin (lp.theta +*angle);
92
+ phit.x +=*r*cos (lp.theta +( *angle) );
93
+ phit.y +=*r*sin (lp.theta +( *angle) );
94
94
IntPoint iphit=map.world2map (phit);
95
95
Point pfree=lp;
96
- pfree.x +=(*r-map.getDelta ()*freeDelta)*cos (lp.theta +*angle);
97
- pfree.y +=(*r-map.getDelta ()*freeDelta)*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) );
98
98
pfree=pfree-phit;
99
99
IntPoint ipfree=map.world2map (pfree);
100
100
bool found=false ;
@@ -142,7 +142,7 @@ inline double ScanMatcher::icpStep(OrientedPoint & pret, const ScanMatcherMap& m
142
142
143
143
inline double ScanMatcher::score (const ScanMatcherMap& map, const OrientedPoint& p, const double * readings) const {
144
144
double s=0 ;
145
- const double * angle=m_laserAngles+m_initialBeamsSkip;
145
+ std::vector< double >::const_iterator angle=m_laserAngles. begin () +m_initialBeamsSkip;
146
146
OrientedPoint lp=p;
147
147
lp.x +=cos (p.theta )*m_laserPose.x -sin (p.theta )*m_laserPose.y ;
148
148
lp.y +=sin (p.theta )*m_laserPose.x +cos (p.theta )*m_laserPose.y ;
@@ -154,12 +154,12 @@ inline double ScanMatcher::score(const ScanMatcherMap& map, const OrientedPoint&
154
154
skip=skip>m_likelihoodSkip?0 :skip;
155
155
if (skip||*r>m_usableRange||*r==0.0 ) continue ;
156
156
Point phit=lp;
157
- phit.x +=*r*cos (lp.theta +*angle);
158
- phit.y +=*r*sin (lp.theta +*angle);
157
+ phit.x +=*r*cos (lp.theta +( *angle) );
158
+ phit.y +=*r*sin (lp.theta +( *angle) );
159
159
IntPoint iphit=map.world2map (phit);
160
160
Point pfree=lp;
161
- pfree.x +=(*r-map.getDelta ()*freeDelta)*cos (lp.theta +*angle);
162
- pfree.y +=(*r-map.getDelta ()*freeDelta)*sin (lp.theta +*angle);
161
+ pfree.x +=(*r-map.getDelta ()*freeDelta)*cos (lp.theta +( *angle) );
162
+ pfree.y +=(*r-map.getDelta ()*freeDelta)*sin (lp.theta +( *angle) );
163
163
pfree=pfree-phit;
164
164
IntPoint ipfree=map.world2map (pfree);
165
165
bool found=false ;
@@ -192,7 +192,7 @@ inline unsigned int ScanMatcher::likelihoodAndScore(double& s, double& l, const
192
192
using namespace std ;
193
193
l=0 ;
194
194
s=0 ;
195
- const double * angle=m_laserAngles+m_initialBeamsSkip;
195
+ std::vector< double >::const_iterator angle=m_laserAngles. begin () +m_initialBeamsSkip;
196
196
OrientedPoint lp=p;
197
197
lp.x +=cos (p.theta )*m_laserPose.x -sin (p.theta )*m_laserPose.y ;
198
198
lp.y +=sin (p.theta )*m_laserPose.x +cos (p.theta )*m_laserPose.y ;
@@ -207,12 +207,12 @@ inline unsigned int ScanMatcher::likelihoodAndScore(double& s, double& l, const
207
207
if (*r>m_usableRange) continue ;
208
208
if (skip) continue ;
209
209
Point phit=lp;
210
- phit.x +=*r*cos (lp.theta +*angle);
211
- phit.y +=*r*sin (lp.theta +*angle);
210
+ phit.x +=*r*cos (lp.theta +( *angle) );
211
+ phit.y +=*r*sin (lp.theta +( *angle) );
212
212
IntPoint iphit=map.world2map (phit);
213
213
Point pfree=lp;
214
- pfree.x +=(*r-freeDelta)*cos (lp.theta +*angle);
215
- pfree.y +=(*r-freeDelta)*sin (lp.theta +*angle);
214
+ pfree.x +=(*r-freeDelta)*cos (lp.theta +( *angle) );
215
+ pfree.y +=(*r-freeDelta)*sin (lp.theta +( *angle) );
216
216
pfree=pfree-phit;
217
217
IntPoint ipfree=map.world2map (pfree);
218
218
bool found=false ;
0 commit comments