Looking at this OMPL optimization tutorial, there is the line:
ob::PlannerStatus solved = planner->solve(1.4/*seconds timeout*/);
With this PlannerStatus
definition.
However, I am using the RRT# algorithm with a certain cost threshold, let's say 10.0
for the sake of argument. If I set it too low, the algorithm by design aborts after 1.4 second with the best value found so far, and prints a message:
Info: ... Final solution cost 17.071
Info: Solution found in 1.418528 seconds
And returns ob::PlannerStatus::EXACT_SOLUTION
- I suppose I do have an exact, but perhaps not optimal solution.
If I run with a different set of data, I can see something like:
Info: ... Final solution cost 9.543
Info: Solution found in 0.003216 seconds
That also, however, returns ob::PlannerStatus::EXACT_SOLUTION
.
So, how can I differentiate between a timeout solution and a threshold-matching solution?
EXACT_SOLUTION means that the planner has already found a valid path between start and goal configurations regardless of its cost. APPROXIMATE_SOLUTION is when planning time is finished and the planner could not find any solution so that it returns a path that is the nearest to the goal configuration.
For your problem, there are two solutions:
The first solution is to check the returned path cost and planning time. If both parameters are lower than the values you set; therefore, it is the solution you're looking for.
The second one is to change the planner code to return different solutions status which can be edited via StatusType enums.
Once you change the planner code you need to go to the build directory of OMPL (..build/Release) and run "make install" in the terminal.
You could add your enums to ompl::base::PlannerStatus