Open tlpss opened 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)
Ok some progress, you can set the seed of the RNG
object in its constructor:
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
:
I'm still missing two things:
SimpleSetup
to use the new ValidStateSampler
RNG
that ValidStateSampler
usesAdditionally, there is a Python example on how to inherit from ValidStateSampler
.
A bit more progress, apparent
RRTConnect
does not allocate a ValidStateSampler
, but simply a StateSampler
, see RRTConnect.cpp
.RealVectorDeterministicStateSampler
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 SimpleSetup
s and plan to the same goal, I still get two different paths. Maybe it's due to the path simplification also being random?
Any updates on this issue?
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.
would be nice to have a convenient way to fix the seed (or maybe have this as default) so that generated plans are deterministic