88#include < iostream>
99#include < gmapping/utils/gvalues.h>
1010#include < gmapping/scanmatcher/scanmatcher_export.h>
11- #define LASER_MAXBEAMS 2048
11+ #include < vector >
1212
1313namespace GMapping {
1414
@@ -35,7 +35,7 @@ class SCANMATCHER_EXPORT ScanMatcher{
3535 inline unsigned int likelihoodAndScore (double & s, double & l, const ScanMatcherMap& map, const OrientedPoint& p, const double * readings) const ;
3636 double likelihood (double & lmax, OrientedPoint& mean, CovarianceMatrix& cov, const ScanMatcherMap& map, const OrientedPoint& p, const double * readings);
3737 double likelihood (double & _lmax, OrientedPoint& _mean, CovarianceMatrix& _cov, const ScanMatcherMap& map, const OrientedPoint& p, Gaussian3& odometry, const double * readings, double gain=180 .);
38- inline const double * laserAngles () const { return m_laserAngles; }
38+ inline const double * laserAngles () const { return m_laserAngles. data () ; }
3939 inline unsigned int laserBeams () const { return m_laserBeams; }
4040
4141 static const double nullLikelihood;
@@ -45,7 +45,7 @@ class SCANMATCHER_EXPORT ScanMatcher{
4545
4646 /* *laser parameters*/
4747 unsigned int m_laserBeams;
48- double m_laserAngles[LASER_MAXBEAMS] ;
48+ std::vector< double > m_laserAngles;
4949 // OrientedPoint m_laserPose;
5050 PARAM_SET_GET (OrientedPoint, laserPose, protected, public, public)
5151 PARAM_SET_GET (double , laserMaxRange, protected, public, public)
@@ -75,7 +75,7 @@ class SCANMATCHER_EXPORT ScanMatcher{
7575};
7676
7777inline double ScanMatcher::icpStep (OrientedPoint & pret, const ScanMatcherMap& map, const OrientedPoint& p, const double * readings) const {
78- const double * angle=m_laserAngles+m_initialBeamsSkip;
78+ std::vector< double >::const_iterator angle=m_laserAngles. begin () +m_initialBeamsSkip;
7979 OrientedPoint lp=p;
8080 lp.x +=cos (p.theta )*m_laserPose.x -sin (p.theta )*m_laserPose.y ;
8181 lp.y +=sin (p.theta )*m_laserPose.x +cos (p.theta )*m_laserPose.y ;
@@ -90,12 +90,12 @@ inline double ScanMatcher::icpStep(OrientedPoint & pret, const ScanMatcherMap& m
9090 if (*r>m_usableRange||*r==0.0 ) continue ;
9191 if (skip) continue ;
9292 Point phit=lp;
93- phit.x +=*r*cos (lp.theta +*angle);
94- phit.y +=*r*sin (lp.theta +*angle);
93+ phit.x +=*r*cos (lp.theta +( *angle) );
94+ phit.y +=*r*sin (lp.theta +( *angle) );
9595 IntPoint iphit=map.world2map (phit);
9696 Point pfree=lp;
97- pfree.x +=(*r-map.getDelta ()*freeDelta)*cos (lp.theta +*angle);
98- pfree.y +=(*r-map.getDelta ()*freeDelta)*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) );
9999 pfree=pfree-phit;
100100 IntPoint ipfree=map.world2map (pfree);
101101 bool found=false ;
@@ -143,7 +143,7 @@ inline double ScanMatcher::icpStep(OrientedPoint & pret, const ScanMatcherMap& m
143143
144144inline double ScanMatcher::score (const ScanMatcherMap& map, const OrientedPoint& p, const double * readings) const {
145145 double s=0 ;
146- const double * angle=m_laserAngles+m_initialBeamsSkip;
146+ std::vector< double >::const_iterator angle=m_laserAngles. begin () +m_initialBeamsSkip;
147147 OrientedPoint lp=p;
148148 lp.x +=cos (p.theta )*m_laserPose.x -sin (p.theta )*m_laserPose.y ;
149149 lp.y +=sin (p.theta )*m_laserPose.x +cos (p.theta )*m_laserPose.y ;
@@ -155,12 +155,12 @@ inline double ScanMatcher::score(const ScanMatcherMap& map, const OrientedPoint&
155155 skip=skip>m_likelihoodSkip?0 :skip;
156156 if (skip||*r>m_usableRange||*r==0.0 ) continue ;
157157 Point phit=lp;
158- phit.x +=*r*cos (lp.theta +*angle);
159- phit.y +=*r*sin (lp.theta +*angle);
158+ phit.x +=*r*cos (lp.theta +( *angle) );
159+ phit.y +=*r*sin (lp.theta +( *angle) );
160160 IntPoint iphit=map.world2map (phit);
161161 Point pfree=lp;
162- pfree.x +=(*r-map.getDelta ()*freeDelta)*cos (lp.theta +*angle);
163- pfree.y +=(*r-map.getDelta ()*freeDelta)*sin (lp.theta +*angle);
162+ pfree.x +=(*r-map.getDelta ()*freeDelta)*cos (lp.theta +( *angle) );
163+ pfree.y +=(*r-map.getDelta ()*freeDelta)*sin (lp.theta +( *angle) );
164164 pfree=pfree-phit;
165165 IntPoint ipfree=map.world2map (pfree);
166166 bool found=false ;
@@ -193,7 +193,7 @@ inline unsigned int ScanMatcher::likelihoodAndScore(double& s, double& l, const
193193 using namespace std ;
194194 l=0 ;
195195 s=0 ;
196- const double * angle=m_laserAngles+m_initialBeamsSkip;
196+ std::vector< double >::const_iterator angle=m_laserAngles. begin () +m_initialBeamsSkip;
197197 OrientedPoint lp=p;
198198 lp.x +=cos (p.theta )*m_laserPose.x -sin (p.theta )*m_laserPose.y ;
199199 lp.y +=sin (p.theta )*m_laserPose.x +cos (p.theta )*m_laserPose.y ;
@@ -208,12 +208,12 @@ inline unsigned int ScanMatcher::likelihoodAndScore(double& s, double& l, const
208208 if (*r>m_usableRange) continue ;
209209 if (skip) continue ;
210210 Point phit=lp;
211- phit.x +=*r*cos (lp.theta +*angle);
212- phit.y +=*r*sin (lp.theta +*angle);
211+ phit.x +=*r*cos (lp.theta +( *angle) );
212+ phit.y +=*r*sin (lp.theta +( *angle) );
213213 IntPoint iphit=map.world2map (phit);
214214 Point pfree=lp;
215- pfree.x +=(*r-freeDelta)*cos (lp.theta +*angle);
216- pfree.y +=(*r-freeDelta)*sin (lp.theta +*angle);
215+ pfree.x +=(*r-freeDelta)*cos (lp.theta +( *angle) );
216+ pfree.y +=(*r-freeDelta)*sin (lp.theta +( *angle) );
217217 pfree=pfree-phit;
218218 IntPoint ipfree=map.world2map (pfree);
219219 bool found=false ;
0 commit comments