All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ProblemDefinition.h
142 typedef std::function<void(const Planner*, const std::vector<const base::State*> &, const Cost)> ReportIntermediateSolutionFn;
244 void setStartAndGoalStates(const State *start, const State *goal, const double threshold = std::numeric_limits<double>::epsilon());
247 void setGoalState(const State *goal, const double threshold = std::numeric_limits<double>::epsilon());
250 void setStartAndGoalStates(const ScopedState<> &start, const ScopedState<> &goal, const double threshold = std::numeric_limits<double>::epsilon())
256 void setGoalState(const ScopedState<> &goal, const double threshold = std::numeric_limits<double>::epsilon())
354 void addSolutionPath(const PathPtr &path, bool approximate = false, double difference = -1.0, const std::string& plannerName = "Unknown") const;
const OptimizationObjectivePtr & getOptimizationObjective() const
Get the optimization objective to be considered during planning.
Definition: ProblemDefinition.h:268
PlannerSolution(const PathPtr &path)
Construct a solution that consists of a path and its attributes (whether it is approximate and the di...
Definition: ProblemDefinition.h:73
void setApproximate(double difference)
Specify that the solution is approximate and set the difference to the goal.
Definition: ProblemDefinition.h:90
bool optimized_
True if the solution was optimized to meet the specified optimization criterion.
Definition: ProblemDefinition.h:126
void setOptimizationObjective(const OptimizationObjectivePtr &optimizationObjective)
Set the optimization objective to be considered during planning.
Definition: ProblemDefinition.h:274
Representation of a solution to a planning problem.
Definition: ProblemDefinition.h:70
void clearSolutionNonExistenceProof()
Removes any existing instance of SolutionNonExistenceProof.
Definition: ProblemDefinition.cpp:489
State * getStartState(unsigned int index)
Returns a specific start state.
Definition: ProblemDefinition.h:208
A shared pointer wrapper for ompl::base::SolutionNonExistenceProof.
ReportIntermediateSolutionFn intermediateSolutionCallback_
Callback function which is called when a new intermediate solution has been found.
Definition: ProblemDefinition.h:404
void print(std::ostream &out=std::cout) const
Print information about the start and goal states and the optimization objective. ...
Definition: ProblemDefinition.cpp:465
bool isTrivial(unsigned int *startIndex=nullptr, double *distance=nullptr) const
A problem is trivial if a given starting state already in the goal region, so we need no motion plann...
Definition: ProblemDefinition.cpp:372
double getSolutionDifference() const
Get the distance to the desired goal for the top solution. Return -1.0 if there are no solutions avai...
Definition: ProblemDefinition.cpp:450
void setGoalState(const State *goal, const double threshold=std::numeric_limits< double >::epsilon())
A simple form of setting the goal. This is called by setStartAndGoalStates(). A more general form is ...
Definition: ProblemDefinition.cpp:177
std::function< void(const Planner *, const std::vector< const base::State * > &, const Cost)> ReportIntermediateSolutionFn
When a planner has an intermediate solution (e.g., optimizing planners), a function with this signatu...
Definition: ProblemDefinition.h:138
const SpaceInformationPtr & getSpaceInformation() const
Get the space information this problem definition is for.
Definition: ProblemDefinition.h:165
void setStartAndGoalStates(const State *start, const State *goal, const double threshold=std::numeric_limits< double >::epsilon())
In the simplest case possible, we have a single starting state and a single goal state.
Definition: ProblemDefinition.cpp:170
void addStartState(const ScopedState<> &state)
Add a start state. The state is copied.
Definition: ProblemDefinition.h:177
PathPtr getSolutionPath() const
Return the top solution path, if one is found. The top path is the shortest one that was found...
Definition: ProblemDefinition.cpp:414
SolutionNonExistenceProofPtr nonExistenceProof_
A Representation of a proof of non-existence of a solution for this problem definition.
Definition: ProblemDefinition.h:398
const State * getStartState(unsigned int index) const
Returns a specific start state.
Definition: ProblemDefinition.h:202
bool hasOptimizedSolution() const
Return true if the top found solution is optimized (satisfies the specified optimization objective) ...
Definition: ProblemDefinition.cpp:445
unsigned int getStartStateCount() const
Returns the number of start states.
Definition: ProblemDefinition.h:196
bool hasSolution() const
Returns true if a solution path has been found (could be approximate)
Definition: ProblemDefinition.cpp:404
bool approximate_
True if goal was not achieved, but an approximate solution was found.
Definition: ProblemDefinition.h:120
bool hasOptimizationObjective() const
Check if an optimization objective was defined for planning.
Definition: ProblemDefinition.h:262
bool operator<(const PlannerSolution &b) const
Define a ranking for solutions.
Definition: ProblemDefinition.cpp:151
void clearSolutionPaths() const
Forget the solution paths (thread safe). Memory is freed.
Definition: ProblemDefinition.cpp:460
void addSolutionPath(const PathPtr &path, bool approximate=false, double difference=-1.0, const std::string &plannerName="Unknown") const
Add a solution path in a thread-safe manner. Multiple solutions can be set for a goal. If a solution does not reach the desired goal it is considered approximate. Optionally, the distance between the desired goal and the one actually achieved is set by difference. Optionally, the name of the planner that generated the solution.
Definition: ProblemDefinition.cpp:424
void setStartAndGoalStates(const ScopedState<> &start, const ScopedState<> &goal, const double threshold=std::numeric_limits< double >::epsilon())
In the simplest case possible, we have a single starting state and a single goal state.
Definition: ProblemDefinition.h:250
bool hasApproximateSolution() const
Return true if the top found solution is approximate (does not actually reach the desired goal...
Definition: ProblemDefinition.cpp:440
void setSolutionNonExistenceProof(const SolutionNonExistenceProofPtr &nonExistenceProof)
Set the instance of SolutionNonExistenceProof for this problem definition.
Definition: ProblemDefinition.cpp:499
void setGoalState(const ScopedState<> &goal, const double threshold=std::numeric_limits< double >::epsilon())
A simple form of setting the goal. This is called by setStartAndGoalStates(). A more general form is ...
Definition: ProblemDefinition.h:256
OptimizationObjectivePtr optimizationObjective_
The objective to be optimized while solving the planning problem.
Definition: ProblemDefinition.h:401
int index_
When multiple solutions are found, each is given a number starting at 0, so that the order in which t...
Definition: ProblemDefinition.h:111
const ReportIntermediateSolutionFn & getIntermediateSolutionCallback() const
When this function returns a valid function pointer, that function should be called by planners that ...
Definition: ProblemDefinition.h:281
bool fixInvalidInputStates(double distStart, double distGoal, unsigned int attempts)
Many times the start or goal state will barely touch an obstacle. In this case, we may want to automa...
Definition: ProblemDefinition.cpp:234
A shared pointer wrapper for ompl::base::SpaceInformation.
Cost cost_
The cost of this solution path, with respect to the optimization objective.
Definition: ProblemDefinition.h:132
PathPtr isStraightLinePathValid() const
Check if a straight line path is valid. If it is, return an instance of a path that represents the st...
Definition: ProblemDefinition.cpp:279
bool operator==(const PlannerSolution &p) const
Return true if two solutions are the same.
Definition: ProblemDefinition.h:81
std::vector< PlannerSolution > getSolutions() const
Get all the solution paths available for this goal.
Definition: ProblemDefinition.cpp:455
Abstract definition of optimization objectives.
Definition: OptimizationObjective.h:68
void setOptimized(const OptimizationObjectivePtr &opt, Cost cost, bool meetsObjective)
Set the optimization objective used to optimize this solution, the cost of the solution and whether i...
Definition: ProblemDefinition.h:97
bool fixInvalidInputState(State *state, double dist, bool start, unsigned int attempts)
Helper function for fixInvalidInputStates(). Attempts to fix an individual state. ...
Definition: ProblemDefinition.cpp:198
bool hasExactSolution() const
Returns true if an exact solution path has been found. Specifically returns hasSolution && !hasApprox...
Definition: ProblemDefinition.h:322
Definition of a problem to be solved. This includes the start state(s) for the system and a goal spec...
Definition: ProblemDefinition.h:149
A shared pointer wrapper for ompl::base::OptimizationObjective.
OptimizationObjectivePtr opt_
Optimization objective that was used to optimize this solution.
Definition: ProblemDefinition.h:129
bool hasStartState(const State *state, unsigned int *startIndex=nullptr) const
Check whether a specified starting state is already included in the problem definition and optionally...
Definition: ProblemDefinition.cpp:186
bool getSolution(PlannerSolution &solution) const
Return true if a top solution is found, with the top solution passed by reference in the function hea...
Definition: ProblemDefinition.cpp:419
std::string plannerName_
Name of planner type that generated this solution, as received from Planner::getName() ...
Definition: ProblemDefinition.h:135
SpaceInformationPtr si_
The space information this problem definition is for.
Definition: ProblemDefinition.h:389
bool hasSolutionNonExistenceProof() const
Returns true if the problem definition has a proof of non existence for a solution.
Definition: ProblemDefinition.cpp:484
void addStartState(const State *state)
Add a start state. The state is copied.
Definition: ProblemDefinition.h:171
A shared pointer wrapper for ompl::base::Goal.
std::size_t getSolutionCount() const
Get the number of solutions already found.
Definition: ProblemDefinition.cpp:409
const SolutionNonExistenceProofPtr & getSolutionNonExistenceProof() const
Retrieve a pointer to the SolutionNonExistenceProof instance for this problem definition.
Definition: ProblemDefinition.cpp:494
double difference_
The achieved difference between the found solution and the desired goal.
Definition: ProblemDefinition.h:123
void getInputStates(std::vector< const State * > &states) const
Get all the input states. This includes start states and states that are part of goal regions that ca...
Definition: ProblemDefinition.cpp:263
double length_
For efficiency reasons, keep the length of the path as well.
Definition: ProblemDefinition.h:117
void setIntermediateSolutionCallback(const ReportIntermediateSolutionFn &callback)
Set the callback to be called by planners that can compute intermediate solutions.
Definition: ProblemDefinition.h:287
void setPlannerName(const std::string &name)
Set the name of the planner used to compute this solution.
Definition: ProblemDefinition.h:105
Definition of a cost value. Can represent the cost of a motion or the cost of a state.
Definition: Cost.h:47
A shared pointer wrapper for ompl::base::Path.