airo-ugent / airo-planner

Python package for single and dual robot arm motion planning.
MIT License
6 stars 0 forks source link

Deterministic planning for OMPL #1

Open tlpss opened 4 months ago

tlpss commented 4 months ago

would be nice to have a convenient way to fix the seed (or maybe have this as default) so that generated plans are deterministic

Victorlouisdg commented 4 months ago

I tried this:

from ompl import util as ou

ou.RNG().setSeed(1)

But that gives the following error, even when you run it in the first cell of a notebook.

Error:   Random number generation already started. Changing seed now will not lead to deterministic sampling.
         at line 78 in [/project/src/ompl/util/src/RandomNumbers.cpp](https://file+.vscode-resource.vscode-cdn.net/project/src/ompl/util/src/RandomNumbers.cpp)
Victorlouisdg commented 4 months ago

Ok some progress, you can set the seed of the RNG object in its constructor: image

However, I don't know yet if and how I can change the RNG object used by the SimpleSetup. I've found that StateSampler objects have a protected .rng_ attribute. And I've also found how you can allocate a new ValidStateSampler: image

I'm still missing two things:

Additionally, there is a Python example on how to inherit from ValidStateSampler.

Victorlouisdg commented 4 months ago

A bit more progress, apparent

I've tried setting the allocator of the StateSpace use by my SimpleSetup like so:

def allocDeterministicStateSampler(space: ob.StateSpace) -> ob.StateSampler:
    return ob.RealVectorDeterministicStateSampler(space)

space.setStateSamplerAllocator(ob.StateSamplerAllocator(allocDeterministicStateSampler))

But I'm still not getting deterministic plans. When I create two different SimpleSetups and plan to the same goal, I still get two different paths. Maybe it's due to the path simplification also being random?

zkytony commented 2 weeks ago

Any updates on this issue?

Victorlouisdg commented 21 hours ago

Hi Kaiyu, no we haven't had the time to figure this out yet, but this definitely still something we want in the future for repeatable testing.