Sampling#
Samplers#
#include "navground/sim/sampling/sampler.h"
Base class#
Abstract Sampler base class. that allows to sample values of type T using sample.
- Template Parameters:
T – The sampled type
- Param once:
[in] Whether to repeat the first sample (until reset)
Subclassed by navground::sim::ChoiceSampler< T >, navground::sim::ConstantSampler< T >, navground::sim::NormalSampler< T >, navground::sim::RegularSampler< T >, navground::sim::SequenceSampler< T >, navground::sim::UniformSampler< T >
Public Functions
Sample values of type T.
- Throws:
std::runtime_error – If the generator is exhausted (i.e., done returns true)
- Parameters:
rg – [in] A random generator
- Returns:
The sampled value.
Counts the number of sampled values since reset.
- Returns:
The number of sampled values
Returns whether the generator is exhausted and if not reset, sample will raise an error.
- Returns:
True if the generator is exhausted.
Resets the generator.
It also resets the samples count to 0.
Public Members
Whenever to sample only once and than output the same constant value until reset.
What should a generator do at the end of a sequence.
Values:
Start from scratch
Repeat the last entry
Terminate
Generic#
An inexhaustible generator that always returns the same value.
- Template Parameters:
T – The sampled type
Public Functions
Construct an instance.
- Parameters:
value – [in] The constant value
once – [in] Whether to repeat the first sample (until reset)
An generator that loops through a sequence of values.
If wrap is not set to Wrap::terminate, the generator is inexhaustible, else it will be exhausted after looping once through all values once.
- Template Parameters:
T – The sampled type
Public Functions
Construct an instance.
- Parameters:
values – [in] The values to be sampled in sequence
wrap – [in] How it should wrap at the end of the sequence
once – [in] Whether to repeat the first sample (until reset)
An inexhaustible generator that randomly pick sequences from a collection of values.
- Template Parameters:
T – The sampled type
Public Functions
Construct an instance.
- Parameters:
values – [in] The values to be sampled randomly sequence
once – [in] Whether to repeat the first sample (until reset)
Numbers and Vectors#
An generator that sample regularly, adding a fixed step to the previous sample.
Only defined if T is an algebra.
If wrap is not set to Wrap::terminate, the generator is inexhaustible, else it will be exhausted after looping once through all values.
- Template Parameters:
T – The sampled type
Public Static Functions
Construct a sampler that will samples
number
points betweenfrom
andto
.For example,
number=3
, samples the following points:from
,(from + to) / 2
,to
.- Parameters:
from – [in] The first value
to – [in] The target value to be reached after
number
samples.number – [in] The number of samples to draw.
wrap – [in] How it should wrap at the end of the interval (i.e., after
number
samples have been drawn)once – [in] Whether to repeat the first sample (until reset)
- Returns:
The sampler.
Construct a sampler that will samples points, iteratively adding
step
.For example,
step=1
, samples the following points:from
,from + 1
, `from + 2
, …- Parameters:
from – [in] The first value
step – [in] The step
number – [in] The number of samples to draw
wrap – [in] How it should wrap at the end of the interval (i.e., after
number
samples have been drawn)once – [in] Whether to repeat the first sample (until reset)
Vectors#
RegularSamplerly sample from a grid of points.
If wrap is not set to Wrap::terminate, the generator is inexhaustible, else it will be exhausted after looping once through all values once.
Public Functions
Construct an instance.
- Parameters:
from – [in] One corner of the covered area
to – [in] The opposite corner of the covered area
numbers – [in] The size of the grid, i.e., the number of points along the x- and y-axis.
wrap – [in] How it should wrap at end of the covered area
once – [in] Whether to repeat the first sample (until reset)
Numbers#
Sample randomly from a uniform distribution.
Only defined if T is a number.
- Template Parameters:
T – The sampled type
- Param once:
[in] Whether to repeat the first sample (until reset)
Sample randomly from a uniform distribution.
Values are optionally clamped when min and/or max are provided.
Only defined if T is a number.
- Template Parameters:
T – The sampled type
Public Functions
Construct an instance.
- Parameters:
mean – [in] The mean
std_dev – [in] The standard deviation
min – [in] The minimum value
max – [in] The maximum value
once – [in] Whether to repeat the first sample (until reset)
clamp – [in] Whether to clamp the values in
[min, max]
Properties#
This class wraps generic Sampler<T> to generate values of type navground::core::Property::Field.
Public Functions
Constructs an instance.
- Parameters:
value – [in] A sampler
- Template Parameters:
T – Needs to be one of the type of navground::core::Property::Field
Constructs an instance.
- Parameters:
value – A sampler
- Template Parameters:
S – Needs to be one a subclass of Sampler<T>, with T as one of the types of navground::core::Property::Field
Create a new sampler.
- Parameters:
args – [in] The arguments of the constructor of
S
- Template Parameters:
S – Needs to be one a subclass of Sampler<T>, with T as one of the types of navground::core::Property::Field
Targs – The type of the arguments of the constructor of
S
Registered components#
Base class#
An inexhaustible sampler of objects from a class that has register.
It creates objects of the sub-class identified by type.
The objects properties are sampled using the properties samplers stored in properties. Property that are not sampled, are assigned to their default value.
The created objects are wrapped in a container, which by default is a shared pointer.
- Template Parameters:
T – The type of the root class
Subclassed by navground::sim::TaskSampler< T >
Public Functions
Constructs a new instance.
- Parameters:
type – [in] The registered type name
Public Members
The registered name of the sub-class to be sampled
A map of property samplers
name -> sampler
used configure the sampled object.
Registers#
Samples navground::core::Behavior.
Defines the same fields as navground::core::Behavior but as sampler of the respective type.
- Template Parameters:
T – The type of the behavior root class. Used to generalize from C++ to Python.
Public Types
Public Functions
Constructs a new instance.
- Parameters:
type – [in] The registered type name
Public Members
Samples navground::core::Kinematics.
Defines the same fields as navground::core::Kinematics but as sampler of the respective type.
- Template Parameters:
T – The type of the behavior root class. Used to generalize from C++ to Python.
Public Types
Public Functions
Constructs a new instance.
- Parameters:
type – [in] The registered type name
Public Members
Samples Task
- Template Parameters:
T – The type of the root class. Used to generalize from C++ to Python.
Public Types
Samples StateEstimation
- Template Parameters:
T – The type of the root class. Used to generalize from C++ to Python.
Public Types
Agents#
Implement an agent sample.
Defines the same fields as Agent but as sampler of the respective type.
- Template Parameters:
W – The world type that the agents belong too. Used to generalize from C++ to Python.
Public Functions
Constructs a new instance.
Public Members
Obstacles#
#include "navground/sim/sampling/geometry.h"
Sample discs.
Centers are sampled uniformly inside a bounding box and rejected if too near to any other disc, taking into account the lattice. The maximal number of rejection is bound by
max_tries
. The function exit when too many rejection are reached, even if not enough discs have been sampled.- Parameters:
rng – The random number generator
number – [in] The number of discs
bounding_box – [in] The bounding box inside of which to sample disc centers
min_radius – [in] The minimum value for disc radius
max_radius – [in] The maximum value for disc radius
margin – [in] The minimal distance between newly sampled discs
disc_margin – [in] The minimal distance between newly sampled discs and discs in
discs
discs – [in] A list of discs already present.
max_tries – [in] The maximum sampling failures before exiting the function.
lattice_grid – [in] The lattice grid
- Returns:
A list of valid disc