Misc Classes
The following are classes and functions of which the details is not essential to use sbp-env.
Data structure
- class sbp_env.utils.common.Tree(dimension)[source]
A tree representation that stores nodes and edges.
- Parameters
dimension (
int
) – A positive integer that represents \(d\), the dimensionality of the C-space.
- class sbp_env.utils.common.Node(pos)[source]
Represents a node inside a tree.
- Variables
pos (
numpy.ndarray
) – position, a.k.a., the configuration \(q \in C\) that this node representscost (float) – a positive float that represents the cost of this node
parent (
Node
) – parent nodechildren (a list of
Node
) – children nodesis_start (bool) – a flag to indicate this is the start node
is_goal (bool) – a flag to indicate this is the goal node
- Parameters
pos (
ndarray
) – configuration of this node
- class sbp_env.utils.common.PlanningOptions(planner_data_pack, sampler_data_pack, skip_optimality, showSampledPoint, scaling, goalBias, max_number_nodes, radius, ignore_step_size, always_refresh, rrdt_proposal_distribution, start_pt, goal_pt, epsilon=None, goal_radius=None, as_radian=False, simplify_solution=True, no_display=False, first_solution=False, output_dir=None, save_output=None, rover_arm_robot_lengths=None, sampler=None, planner=None, engine=None)[source]
Former: MagicDict
- Parameters
planner_data_pack (PlannerDataPack) –
sampler_data_pack (SamplerDataPack) –
skip_optimality (bool) –
showSampledPoint (bool) –
scaling (float) –
goalBias (float) –
max_number_nodes (int) –
radius (float) –
ignore_step_size (bool) –
always_refresh (bool) –
rrdt_proposal_distribution (str) –
start_pt (str) –
goal_pt (str) –
epsilon (float) –
goal_radius (float) –
as_radian (bool) –
simplify_solution (bool) –
no_display (bool) –
first_solution (bool) –
output_dir (str) –
save_output (str) –
rover_arm_robot_lengths (str) –
sampler (Sampler) –
planner (Planner) –
engine (Engine) –
Randomness
The following are the random methods supported in sbp-env.
- sbp_env.randomness.SUPPORTED_RANDOM_METHODS = ('pseudo_random', 'sobol_sequence', 'saltelli', 'latin_hypercube', 'finite_differences', 'fast')
Supported methods to draw random numbers in samplers. Supported random methods are as follows:
pseudo_random
from numpyPseudo Random
sobol_sequence
from SALibSobol sequence
saltelli
from SALibSaltelli’s extension of Sobol sequence
latin_hypercube
from SALibLatin hypercube
finite_differences
from SALibFinite differences
fast
from SALibFourier Amplitude Sensitivity Test (FAST)
Drawing random samplings
The sbp_env.randomness.RandomnessManager:
is used by most samplers to draw random numbers.
- class sbp_env.randomness.RandomnessManager(num_dim, bucket_size=10000)[source]
A random number manager that draw a buckets of random numbers at a number and redraw when the bucket is exhausted.
- get_random(random_method)[source]
Get one sample of random number \(r\) where \(0 \le r \le 1\)
- Parameters
random_method – The kind of random number method to use, must be one of the choice in
SUPPORTED_RANDOM_METHODS
Drawing normally distributed samplings
The sbp_env.randomness.NormalRandomnessManager:
is used by sbp_env.planners.rrdtPlanner.RRdTSampler
to draw from a von Mises distribution.
- class sbp_env.randomness.NormalRandomnessManager[source]
Randomness Manager that draw a bucket of normally distributed random numbers and refill the bucket on-demand when it is exhausted.
- draw_half_normal(start_at, scale=1)[source]
Draw from a half normal distribution
- Parameters
start_at (
ndarray
) – the originscale (
float
, optional) – the scale of the half normalDefault:1
- draw_normal(origin, use_vonmises=True, kappa=1, sigma=0.7853981633974483)[source]
Draw from the normal distribution
- Parameters
origin (
ndarray
) – the origin (mean) for the random number, which will be used to shift the number that this function returnsuse_vonmises (
bool
, optional) – use vom-Mises distributionDefault:True
kappa (
float
, optional) – the \(\kappa\) valueDefault:1
sigma (
float
, optional) – the \(\sigma\) valueDefault:0.7853981633974483
- Return type
- redraw_normal(kappa, sigma, use_vonmises=True)[source]
Redraw the bucket of normally distributed random numbers
- Parameters
kappa –
the kappa \(\kappa\) parameter to be used to draw from a von Mises distribution
\[x \sim f_\text{VonMises}( x | \mu, \kappa) \]sigma –
the sigma \(\sigma\) parameter to be used to draw from a normal distribution
\[x \sim \mathcal{N}( x | \mu, \sigma^2) \]use_vonmises (optional) – (Default value = True)
Default:True
Planners and Samplers Registry
The following function is used to register a new custom planner.
- sbp_env.utils.planner_registry.register_planner(planner_id, planner_class, sampler_id, visualise_pygame_paint_init=None, visualise_pygame_paint=None, visualise_pygame_paint_terminate=None, visualise_klampt_paint_init=None, visualise_klampt_paint=None, visualise_klampt_paint_terminate=None)[source]
Register a planner to make it available for planning.
- Parameters
planner_id (
str
) – the unique planner id for this registering plannerplanner_class (
Type
[Planner]) – the planner classsampler_id (
str
) – sampler id to constructvisualise_pygame_paint_init (
Optional
[Callable
], optional) – the paint function for pygame, during initialisationDefault:None
visualise_pygame_paint (
Optional
[Callable
], optional) – the paint function for pygameDefault:None
visualise_pygame_paint_terminate (
Optional
[Callable
], optional) – the paint function for pygame, when terminatingDefault:None
visualise_klampt_paint_init (
Optional
[Callable
], optional) – the paint function for klampt, during initialisationDefault:None
visualise_klampt_paint (
Optional
[Callable
], optional) – the paint function for klamptDefault:None
visualise_klampt_paint_terminate (
Optional
[Callable
], optional) – the paint function for klampt, when terminatingDefault:None
- Return type
The following function is used to register a new custom sampler.
- sbp_env.utils.planner_registry.register_sampler(sampler_id, sampler_class, visualise_pygame_paint_init=None, visualise_pygame_paint=None, visualise_pygame_paint_terminate=None, visualise_klampt_paint_init=None, visualise_klampt_paint=None, visualise_klampt_paint_terminate=None)[source]
Register a sampler to make it available for planning.
- Parameters
sampler_id (
str
) – the unique id for this samplersampler_class (
Type
[Sampler]) – the class to construct this samplervisualise_pygame_paint_init (
Optional
[Callable
], optional) – the paint function for pygame, during initialisationDefault:None
visualise_pygame_paint (
Optional
[Callable
], optional) – the paint function for pygameDefault:None
visualise_pygame_paint_terminate (
Optional
[Callable
], optional) – the paint function for pygame, when terminatingDefault:None
visualise_klampt_paint_init (
Optional
[Callable
], optional) – the paint function for klampt, during initialisationDefault:None
visualise_klampt_paint (
Optional
[Callable
], optional) – the paint function for klamptDefault:None
visualise_klampt_paint_terminate (
Optional
[Callable
], optional) – the paint function for klampt, when terminatingDefault:None
- Return type
Registry data structure
- class sbp_env.utils.planner_registry.PlannerDataPack(name, visualise_pygame_paint_init, visualise_pygame_paint, visualise_pygame_paint_terminate, visualise_klampt_paint_init, visualise_klampt_paint, visualise_klampt_paint_terminate, planner_class, sampler_id)[source]
Data pack to stores planner class and the sampler with sample_id to use
- class sbp_env.utils.planner_registry.SamplerDataPack(name, visualise_pygame_paint_init, visualise_pygame_paint, visualise_pygame_paint_terminate, visualise_klampt_paint_init, visualise_klampt_paint, visualise_klampt_paint_terminate, sampler_class)[source]
Data pack to store sampler class
- Parameters
name (str) –