GoalLazySamples.cpp
41 ompl::base::GoalLazySamples::GoalLazySamples(const SpaceInformationPtr &si, const GoalSamplingFn &samplerFunc, bool autoStart, double minDist) :
42 GoalStates(si), samplerFunc_(samplerFunc), terminateSamplingThread_(false), samplingThread_(nullptr), samplingAttempts_(0), minDist_(minDist)
87 OMPL_DEBUG("Waiting for space information to be set up before the sampling thread can begin computation...");
106 samplerFunc_ ? (si_->isSetup() ? "" : " Space information not set up.") : " No sampling function set.");
108 OMPL_DEBUG("Stopped goal sampling thread after %u sampling attempts", samplingAttempts_ - prevsa);
std::function< bool(const GoalLazySamples *, State *)> GoalSamplingFn
Goal sampling function. Returns false when no further calls should be made to it. Fills its second ar...
Definition: GoalLazySamples.h:52
virtual bool couldSample() const
Return true if GoalStates::couldSample() is true or if the sampling thread is active, as in this case it is possible a sample can be produced at some point.
Definition: GoalLazySamples.cpp:116
void goalSamplingThread()
The function that samples goals by calling samplerFunc_ in a separate thread.
Definition: GoalLazySamples.cpp:83
virtual std::size_t getStateCount() const
Return the number of valid goal states.
Definition: GoalStates.cpp:117
virtual bool hasStates() const
Check if there are any states in this goal region.
Definition: GoalStates.cpp:122
virtual double distanceGoal(const State *st) const
Compute the distance to the goal (heuristic). This function is the one used in computing the distance...
Definition: GoalStates.cpp:59
virtual void sampleGoal(State *st) const
Sample a state in the goal region.
Definition: GoalLazySamples.cpp:133
double minDist_
Samples returned by the sampling thread are added to the list of states only if they are at least min...
Definition: GoalLazySamples.h:183
std::thread * samplingThread_
Additional thread for sampling goal states.
Definition: GoalLazySamples.h:176
virtual const State * getState(unsigned int index) const
Return a pointer to the indexth state in the state list.
Definition: GoalLazySamples.cpp:150
bool addStateIfDifferent(const State *st, double minDistance)
Add a state st if it further away that minDistance from previously added states. Return true if the s...
Definition: GoalLazySamples.cpp:168
virtual const State * getState(unsigned int index) const
Return a pointer to the indexth state in the state list.
Definition: GoalStates.cpp:109
duration seconds(double sec)
Return the time duration representing a given number of seconds.
Definition: Time.h:78
virtual void sampleGoal(State *st) const
Sample a state in the goal region.
Definition: GoalStates.cpp:81
void setNewStateCallback(const NewStateCallbackFn &callback)
Set the callback function to be called when a new state is added to the list of possible samples...
Definition: GoalLazySamples.cpp:139
std::vector< State * > states_
The goal states. Only ones that are valid are considered by the motion planner.
Definition: GoalStates.h:91
virtual bool hasStates() const
Check if there are any states in this goal region.
Definition: GoalLazySamples.cpp:156
GoalLazySamples(const SpaceInformationPtr &si, const GoalSamplingFn &samplerFunc, bool autoStart=true, double minDist=std::numeric_limits< double >::epsilon())
Create a goal region that can be sampled in a lazy fashion. A function (samplerFunc) that produces sa...
Definition: GoalLazySamples.cpp:41
bool canSample() const
Return true if maxSampleCount() > 0, since in this case samples can certainly be produced.
Definition: GoalSampleableRegion.h:70
A shared pointer wrapper for ompl::base::SpaceInformation.
virtual std::size_t getStateCount() const
Return the number of valid goal states.
Definition: GoalLazySamples.cpp:162
virtual double distanceGoal(const State *st) const
Compute the distance to the goal (heuristic). This function is the one used in computing the distance...
Definition: GoalLazySamples.cpp:127
bool terminateSamplingThread_
Flag used to notify the sampling thread to terminate sampling.
Definition: GoalLazySamples.h:173
unsigned int samplingAttempts_
The number of times the sampling function was called and it returned true.
Definition: GoalLazySamples.h:179
This bit is set if casting to goal states (ompl::base::GoalLazySamples) is possible.
Definition: GoalTypes.h:64
std::function< void(const base::State *)> NewStateCallbackFn
When new samples are generated and added to the list of possible samples, a callback can be called...
Definition: GoalLazySamples.h:80
bool isSampling() const
Return true if the sampling thread is active.
Definition: GoalLazySamples.cpp:111
NewStateCallbackFn callback_
If defined, this function is called when a new state is added to the list of possible samples...
Definition: GoalLazySamples.h:186