Skip to content

Commit dad8a45

Browse files
committed
remove mutable member from GNAT
1 parent 134b59c commit dad8a45

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/ompl/datastructures/NearestNeighborsGNAT.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,12 @@ namespace ompl
246246

247247
#ifdef GNAT_SAMPLER
248248
/// Sample an element from the GNAT.
249-
const _T& sample() const
249+
const _T& sample(RNG& rng) const
250250
{
251251
if (!size())
252252
throw Exception("Cannot sample from an empty tree");
253253
else
254-
return tree_->sample(*this);
254+
return tree_->sample(*this, rng);
255255
}
256256
#endif
257257

@@ -665,20 +665,20 @@ namespace ompl
665665
minR = std::max(minR, maxRadius_);
666666
return std::pow(minR, gnat.estimatedDimension_) / (double) subtreeSize_;
667667
}
668-
const _T& sample(const GNAT& gnat) const
668+
const _T& sample(const GNAT& gnat, RNG& rng) const
669669
{
670670
if (children_.size() != 0)
671671
{
672-
if (gnat.rng_.uniform01() < 1./(double) subtreeSize_)
672+
if (rng.uniform01() < 1./(double) subtreeSize_)
673673
return pivot_;
674674
PDF<const Node*> distribution;
675675
for(unsigned int i = 0; i < children_.size(); ++i)
676676
distribution.add(children_[i], children_[i]->getSamplingWeight(gnat));
677-
return distribution.sample(gnat.rng_.uniform01())->sample(gnat);
677+
return distribution.sample(rng.uniform01())->sample(gnat, rng);
678678
}
679679
else
680680
{
681-
unsigned int i = gnat.rng_.uniformInt(0, data_.size());
681+
unsigned int i = rng.uniformInt(0, data_.size());
682682
return (i==data_.size()) ? pivot_ : data_[i];
683683
}
684684
}
@@ -788,8 +788,6 @@ namespace ompl
788788
#ifdef GNAT_SAMPLER
789789
/// \brief Estimated dimension of the local free space.
790790
double estimatedDimension_;
791-
/// \brief Random number generator used to sample elements from the GNAT.
792-
mutable RNG rng_;
793791
#endif
794792
};
795793

src/ompl/geometric/planners/stride/src/STRIDE.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ void ompl::geometric::STRIDE::addMotion(Motion *motion)
225225

226226
ompl::geometric::STRIDE::Motion* ompl::geometric::STRIDE::selectMotion(void)
227227
{
228-
return tree_->sample();
228+
return tree_->sample(rng_);
229229
}
230230

231231
void ompl::geometric::STRIDE::getPlannerData(base::PlannerData &data) const

0 commit comments

Comments
 (0)