32 if (parent && (--parent->childs)<=0)
45 for (ParticleVector::const_iterator it=m_particles.begin(); it!=m_particles.end(); it++){
53 for (ParticleVector::const_iterator it=m_particles.begin(); it!=m_particles.end(); it++){
57 assert(newnode->
childs==0);
59 parentCache.insert(make_pair(newnode->
parent, newnode));
64 border.push_back(newnode->
parent);
71 while (! border.empty()){
74 const TNode* node=border.front();
84 pair<TNodeMultimap::iterator, TNodeMultimap::iterator> p=parentCache.equal_range(node);
86 for (TNodeMultimap::iterator it=p.first; it!=p.second; it++){
87 assert(it->second->parent==it->first);
88 (it->second)->parent=newnode;
93 parentCache.erase(p.first, p.second);
95 assert(childs==newnode->
childs);
99 parentCache.insert(make_pair(node->
parent, newnode));
101 border.push_back(node->
parent);
108 for (
unsigned int i=0; i<v.size(); i++){
136 m_infoStream <<
"Restoring State Nodes=" <<count << endl;
151 double dw=aux->
weight-oldWeight;
155 double * plainReading =
new double[m_beams];
156 for(
unsigned int i=0; i<m_beams; i++)
157 plainReading[i]=(*(aux->
reading))[i];
159 for (ParticleVector::iterator it=m_particles.begin(); it!=m_particles.end(); it++){
161 double s=sin(oldPose.
theta-it->pose.theta),
162 c=cos(oldPose.
theta-it->pose.theta);
164 it->pose.x+=
c*dp.
x-s*dp.
y;
165 it->pose.y+=s*dp.
x+
c*dp.
y;
166 it->pose.theta+=dp.
theta;
167 it->pose.theta=atan2(sin(it->pose.theta), cos(it->pose.theta));
170 m_matcher.invalidateActiveArea();
171 m_matcher.computeActiveArea(it->map, it->pose, plainReading);
177 it->node=
new TNode(it->pose, 0.0, it->node);
181 delete [] plainReading;
189 reversed=reversed->
parent;
200 if (!weightsAlreadyNormalized) {
210 for (ParticleVector::iterator it=m_particles.begin(); it!=m_particles.end(); it++){
239 double lastNodeWeight=0;
243 std::vector<double>::iterator w=m_weights.begin();
244 for (ParticleVector::iterator it=m_particles.begin(); it!=m_particles.end(); it++){
253 if (fabs(aw-1.0) > 0.0001 || fabs(lastNodeWeight-1.0) > 0.0001) {
255 cerr <<
"root->accWeight=" << lastNodeWeight <<
" sum_leaf_weights=" << aw << endl;
258 return lastNodeWeight;
void normalize(const Iterator &begin, const Iterator &end)
const RangeReading * reading
std::vector< GridSlamProcessor::TNode * > TNodeVector
void integrateScanSequence(TNode *node)
unsigned int visitCounter
TNode(const OrientedPoint &pose, double weight, TNode *parent=0, unsigned int childs=0)
std::deque< GridSlamProcessor::TNode * > TNodeDeque
std::multimap< const GridSlamProcessor::TNode *, GridSlamProcessor::TNode * > TNodeMultimap
double propagateWeights()
double propagateWeight(GridSlamProcessor::TNode *n, double weight)
void updateTreeWeights(bool weightsAlreadyNormalized=false)
TNodeVector getTrajectories() const