Differentiating between a timeout and a threshold match with OMPL Planner

225 views Asked by At

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?

1

There are 1 answers

0
Reza On

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

        /// The possible values of the status returned by a planner
        enum StatusType
        {
            /// Uninitialized status
            UNKNOWN = 0,
            /// Invalid start state or no start state specified
            INVALID_START,
            /// Invalid goal state
            INVALID_GOAL,
            /// The goal is of a type that a planner does not recognize
            UNRECOGNIZED_GOAL_TYPE,
            /// The planner failed to find a solution
            TIMEOUT,
            /// The planner found an approximate solution
            APPROXIMATE_SOLUTION,
            /// The planner found an exact solution
            EXACT_SOLUTION,
            /// The planner crashed
            CRASH,
            /// The planner did not find a solution for some other reason
            ABORT,
            /// The number of possible status values
            TYPE_COUNT
        };