37 #ifndef OMPL_BASE_STATE_SAMPLER_ARRAY_
38 #define OMPL_BASE_STATE_SAMPLER_ARRAY_
40 #include "ompl/base/SpaceInformation.h"
41 #include "ompl/base/StateSampler.h"
42 #include "ompl/base/ValidStateSampler.h"
54 struct SamplerSelector
60 struct SamplerSelector<StateSampler>
62 using Sampler = StateSampler;
65 SamplerPtr allocStateSampler(
const SpaceInformation *si)
67 return si->allocStateSampler();
72 struct SamplerSelector<ValidStateSampler>
74 using Sampler = ValidStateSampler;
77 SamplerPtr allocStateSampler(
const SpaceInformation *si)
79 return si->allocValidStateSampler();
87 class StateSamplerArray
91 using SamplerPtr =
typename SamplerSelector<T>::SamplerPtr;
94 using Sampler =
typename SamplerSelector<T>::Sampler;
112 return samplers_[index].get();
116 void resize(std::size_t count)
118 if (samplers_.size() > count)
119 samplers_.resize(count);
120 else if (samplers_.size() < count)
122 samplers_.resize(count);
123 for (
auto &sampler : samplers_)
124 sampler = ss_.allocStateSampler(si_);
129 std::size_t
size()
const
131 return samplers_.size();
141 const SpaceInformation *si_;
142 SamplerSelector<T> ss_;
143 std::vector<SamplerPtr> samplers_;
void clear()
Clear all allocated samplers.
typename SamplerSelector< T >::SamplerPtr SamplerPtr
Pointer to the type of sampler allocated.
Sampler * operator[](std::size_t index) const
Access operator for a specific sampler. For performance reasons, the bounds are not checked.
std::size_t size() const
Get the count of samplers currently available.
typename SamplerSelector< T >::Sampler Sampler
The type of sampler allocated.
StateSamplerArray(const SpaceInformationPtr &si)
Constructor.
A shared pointer wrapper for ompl::base::StateSampler.
A shared pointer wrapper for ompl::base::ValidStateSampler.
void resize(std::size_t count)
Create or release some state samplers.
Main namespace. Contains everything in this library.