1. OMPL
  2. OMPL
  3. ompl
  4. Pull requests

Pull requests

#32 Declined
Repository
Deleted repository
Branch
default (cfb64c8e2a10)
Repository
ompl
Branch
default

RNG Local Seeds

Author
  1. Jonathan Gammell
Reviewers
Description

Added the ability to set the local seed of a specific RNG instance, either on construction or after construction.

Comments (6)

  1. Ioan Sucan

    Thank you Jonathan, I have added some comments inline. Most of the changes you are proposing are excellent (please don't worry about my picky styling comments). My only concern is with exposing the RNG instance of the sampler and the local seed get/set for RRTstar.

  2. Mark Moll

    Perhaps an alternative way to achieve what you want is to set a StateSamplerAllocator that will call RNG::setLocalSeed for each sampler it allocates? E.g.:

    struct quasiRandomStateSamplerAllocator
    {
        quasiRandomStateSamplerAllocator(boost::uint32_t seed) : seed_(seed)
        {
        }
    
        const StateSamplerPtr operator(const StateSpace* space)
        {
              StateSamplerPtr sampler = space->allocDefaultStateSampler();
              sampler->rng().setLocalSeed(seed_++);
              return sampler;
        }
    
       boost::uint32_t seed_;
    };
    
    ....
    
    space->setStateSamplerAllocator(quasiRandomStateSamplerAllocator(1));
    

    This would still assume that the state space sampler is using the RNG instance in the base class StateSampler. That doesn't seem unreasonable to me. If the state sampler is doing random sampling, it should use the RNG instance in the base class. If it's not (e.g., because it's using quasi random number sequences), then you already have deterministic behavior.

  3. Ioan Sucan

    I like this idea much better than modifying RRT*. The issue I have with exposing rng_ from samplers is that they could potentially define their own RNG instance. For instance, a compound sampler will use the RNG instances of the samplers it contains, not its own. This means that this trick won't work for things like SE2. It would work just fine for Rn though. Based on this idea though, we could have a function pointer that returns the next seed be set for RNG. So then we have control on all RNG instances. BUT we still have no control on how many RNG instances are constructed by a sampler. So we would have something like RNG::setLocalSeedGenerator(&mySeedGenerator) and then RNG::clearLocalSeedGenerator? This seems very cumbersome to use though, as one would have to make sure samplers are created in the expected order, so the seeds can be set nicely. This is not a guarantee that we can give, i think.

  4. Jonathan Gammell author

    Wait, will that be too messy for the compound cases Ioan is talking about? If I understand correctly, you'll have to pull out each individual subspace and set it's default allocator?...

    The only other option I can think of would be, instead of exposing the member RNG in StateSampler, just adding set/getSeed functions to StateSampler. E.g.,

    class StateSampler
    ....
        virtual boost::uint32_t getSeed() const
        {
            return rng_.getSeed();
        }
        virtual void setSeed(boost::uint32_t newSeed)
        {
            rng_.setSeed(newSeed);
        }
    };
    

    For the compound case, the function could be overloaded to set a sequence of seeds to the member StateSamplers, i.e.,

    class CompoundStateSampler
    ....
        virtual boost::uint32_t getSeed() const
        {
            return samplers_.at(0u).getSeed();
        }
        virtual void setSeed(boost::uint32_t newSeed)
        {
            for (unsigned int i = 0u; i < samplers_.size(); ++i)
            {
                samplers_.at(i).setSeed(newSeed + i);
            }
        }
    };
    

    I believe a piece of code would be consistent in the order the samplers_ are allocated, so setting the seed should be ok. Unfortunately though, this only solves the problem of getting deterministic state samples from a specific sampler. To get deterministic behaviour out of RRT*, you'd need to set both the seed of it's state sampler, and the seed of it's RNG used for goal biasing. That would require two pairs of seed-based member functions for the RRTstar class, or one and another to get the StateSampler in use... or something...

    I dunno, which ever fits your preferred design styles I guess? Let me know.