# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
"""Python interface to C++ motion planning routines"""
from sys import version_info
if version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_motionplanning', [dirname(__file__)])
except ImportError:
import _motionplanning
return _motionplanning
if fp is not None:
try:
_mod = imp.load_module('_motionplanning', fp, pathname, description)
finally:
fp.close()
return _mod
_motionplanning = swig_import_helper()
del swig_import_helper
else:
import _motionplanning
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr_nondynamic(self, class_type, name, static=1):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
if (not static):
return object.__getattr__(self, name)
else:
raise AttributeError(name)
def _swig_getattr(self, class_type, name):
return _swig_getattr_nondynamic(self, class_type, name, 0)
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object:
pass
_newclass = 0
[docs]class SwigPyIterator(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, SwigPyIterator, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, SwigPyIterator, name)
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined - class is abstract")
__repr__ = _swig_repr
__swig_destroy__ = _motionplanning.delete_SwigPyIterator
__del__ = lambda self: None
[docs] def value(self):
return _motionplanning.SwigPyIterator_value(self)
[docs] def incr(self, n=1):
return _motionplanning.SwigPyIterator_incr(self, n)
[docs] def decr(self, n=1):
return _motionplanning.SwigPyIterator_decr(self, n)
[docs] def distance(self, x):
return _motionplanning.SwigPyIterator_distance(self, x)
[docs] def equal(self, x):
return _motionplanning.SwigPyIterator_equal(self, x)
[docs] def copy(self):
return _motionplanning.SwigPyIterator_copy(self)
[docs] def next(self):
return _motionplanning.SwigPyIterator_next(self)
def __next__(self):
return _motionplanning.SwigPyIterator___next__(self)
[docs] def previous(self):
return _motionplanning.SwigPyIterator_previous(self)
[docs] def advance(self, n):
return _motionplanning.SwigPyIterator_advance(self, n)
def __eq__(self, x):
return _motionplanning.SwigPyIterator___eq__(self, x)
def __ne__(self, x):
return _motionplanning.SwigPyIterator___ne__(self, x)
def __iadd__(self, n):
return _motionplanning.SwigPyIterator___iadd__(self, n)
def __isub__(self, n):
return _motionplanning.SwigPyIterator___isub__(self, n)
def __add__(self, n):
return _motionplanning.SwigPyIterator___add__(self, n)
def __sub__(self, *args):
return _motionplanning.SwigPyIterator___sub__(self, *args)
def __iter__(self):
return self
SwigPyIterator_swigregister = _motionplanning.SwigPyIterator_swigregister
SwigPyIterator_swigregister(SwigPyIterator)
[docs]class doubleVector(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, doubleVector, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, doubleVector, name)
__repr__ = _swig_repr
[docs] def iterator(self):
return _motionplanning.doubleVector_iterator(self)
def __iter__(self):
return self.iterator()
def __nonzero__(self):
return _motionplanning.doubleVector___nonzero__(self)
def __bool__(self):
return _motionplanning.doubleVector___bool__(self)
def __len__(self):
return _motionplanning.doubleVector___len__(self)
def __getslice__(self, i, j):
return _motionplanning.doubleVector___getslice__(self, i, j)
def __setslice__(self, *args):
return _motionplanning.doubleVector___setslice__(self, *args)
def __delslice__(self, i, j):
return _motionplanning.doubleVector___delslice__(self, i, j)
def __delitem__(self, *args):
return _motionplanning.doubleVector___delitem__(self, *args)
def __getitem__(self, *args):
return _motionplanning.doubleVector___getitem__(self, *args)
def __setitem__(self, *args):
return _motionplanning.doubleVector___setitem__(self, *args)
[docs] def pop(self):
return _motionplanning.doubleVector_pop(self)
[docs] def append(self, x):
return _motionplanning.doubleVector_append(self, x)
[docs] def empty(self):
return _motionplanning.doubleVector_empty(self)
[docs] def size(self):
return _motionplanning.doubleVector_size(self)
[docs] def swap(self, v):
return _motionplanning.doubleVector_swap(self, v)
[docs] def begin(self):
return _motionplanning.doubleVector_begin(self)
[docs] def end(self):
return _motionplanning.doubleVector_end(self)
[docs] def rbegin(self):
return _motionplanning.doubleVector_rbegin(self)
[docs] def rend(self):
return _motionplanning.doubleVector_rend(self)
[docs] def clear(self):
return _motionplanning.doubleVector_clear(self)
[docs] def get_allocator(self):
return _motionplanning.doubleVector_get_allocator(self)
[docs] def pop_back(self):
return _motionplanning.doubleVector_pop_back(self)
[docs] def erase(self, *args):
return _motionplanning.doubleVector_erase(self, *args)
def __init__(self, *args):
this = _motionplanning.new_doubleVector(*args)
try:
self.this.append(this)
except Exception:
self.this = this
[docs] def push_back(self, x):
return _motionplanning.doubleVector_push_back(self, x)
[docs] def front(self):
return _motionplanning.doubleVector_front(self)
[docs] def back(self):
return _motionplanning.doubleVector_back(self)
[docs] def assign(self, n, x):
return _motionplanning.doubleVector_assign(self, n, x)
[docs] def resize(self, *args):
return _motionplanning.doubleVector_resize(self, *args)
[docs] def insert(self, *args):
return _motionplanning.doubleVector_insert(self, *args)
[docs] def reserve(self, n):
return _motionplanning.doubleVector_reserve(self, n)
[docs] def capacity(self):
return _motionplanning.doubleVector_capacity(self)
__swig_destroy__ = _motionplanning.delete_doubleVector
__del__ = lambda self: None
doubleVector_swigregister = _motionplanning.doubleVector_swigregister
doubleVector_swigregister(doubleVector)
[docs]class doubleMatrix(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, doubleMatrix, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, doubleMatrix, name)
__repr__ = _swig_repr
[docs] def iterator(self):
return _motionplanning.doubleMatrix_iterator(self)
def __iter__(self):
return self.iterator()
def __nonzero__(self):
return _motionplanning.doubleMatrix___nonzero__(self)
def __bool__(self):
return _motionplanning.doubleMatrix___bool__(self)
def __len__(self):
return _motionplanning.doubleMatrix___len__(self)
def __getslice__(self, i, j):
return _motionplanning.doubleMatrix___getslice__(self, i, j)
def __setslice__(self, *args):
return _motionplanning.doubleMatrix___setslice__(self, *args)
def __delslice__(self, i, j):
return _motionplanning.doubleMatrix___delslice__(self, i, j)
def __delitem__(self, *args):
return _motionplanning.doubleMatrix___delitem__(self, *args)
def __getitem__(self, *args):
return _motionplanning.doubleMatrix___getitem__(self, *args)
def __setitem__(self, *args):
return _motionplanning.doubleMatrix___setitem__(self, *args)
[docs] def pop(self):
return _motionplanning.doubleMatrix_pop(self)
[docs] def append(self, x):
return _motionplanning.doubleMatrix_append(self, x)
[docs] def empty(self):
return _motionplanning.doubleMatrix_empty(self)
[docs] def size(self):
return _motionplanning.doubleMatrix_size(self)
[docs] def swap(self, v):
return _motionplanning.doubleMatrix_swap(self, v)
[docs] def begin(self):
return _motionplanning.doubleMatrix_begin(self)
[docs] def end(self):
return _motionplanning.doubleMatrix_end(self)
[docs] def rbegin(self):
return _motionplanning.doubleMatrix_rbegin(self)
[docs] def rend(self):
return _motionplanning.doubleMatrix_rend(self)
[docs] def clear(self):
return _motionplanning.doubleMatrix_clear(self)
[docs] def get_allocator(self):
return _motionplanning.doubleMatrix_get_allocator(self)
[docs] def pop_back(self):
return _motionplanning.doubleMatrix_pop_back(self)
[docs] def erase(self, *args):
return _motionplanning.doubleMatrix_erase(self, *args)
def __init__(self, *args):
this = _motionplanning.new_doubleMatrix(*args)
try:
self.this.append(this)
except Exception:
self.this = this
[docs] def push_back(self, x):
return _motionplanning.doubleMatrix_push_back(self, x)
[docs] def front(self):
return _motionplanning.doubleMatrix_front(self)
[docs] def back(self):
return _motionplanning.doubleMatrix_back(self)
[docs] def assign(self, n, x):
return _motionplanning.doubleMatrix_assign(self, n, x)
[docs] def resize(self, *args):
return _motionplanning.doubleMatrix_resize(self, *args)
[docs] def insert(self, *args):
return _motionplanning.doubleMatrix_insert(self, *args)
[docs] def reserve(self, n):
return _motionplanning.doubleMatrix_reserve(self, n)
[docs] def capacity(self):
return _motionplanning.doubleMatrix_capacity(self)
__swig_destroy__ = _motionplanning.delete_doubleMatrix
__del__ = lambda self: None
doubleMatrix_swigregister = _motionplanning.doubleMatrix_swigregister
doubleMatrix_swigregister(doubleMatrix)
[docs]def setRandomSeed(seed):
"""
Sets the random seed used by the configuration sampler.
Args:
seed (int)
"""
return _motionplanning.setRandomSeed(seed)
[docs]def setPlanJSONString(string):
"""
Loads planner values from a JSON string.
Args:
string (str)
"""
return _motionplanning.setPlanJSONString(string)
[docs]def getPlanJSONString():
"""
Saves planner values to a JSON string.
Returns:
str:
"""
return _motionplanning.getPlanJSONString()
[docs]def setPlanType(type):
"""
Sets the planner type.
Args:
type (str)
Valid values are
* prm: the Probabilistic Roadmap algorithm
* rrt: the Rapidly Exploring Random Trees algorithm
* sbl: the Single-Query Bidirectional Lazy planner
* sblprt: the probabilistic roadmap of trees (PRT) algorithm with SBL as the
inter-root planner.
* rrt*: the RRT* algorithm for optimal motion planning
* prm*: the PRM* algorithm for optimal motion planning
* lazyprm*: the Lazy-PRM* algorithm for optimal motion planning
* lazyrrg*: the Lazy-RRG* algorithm for optimal motion planning
* fmm: the fast marching method algorithm for resolution-complete optimal
motion planning
* fmm*: an anytime fast marching method algorithm for optimal motion planning
"""
return _motionplanning.setPlanType(type)
[docs]def setPlanSetting(*args):
"""
Sets a numeric or string-valued setting for the planner.
setPlanSetting (setting,value)
Args:
setting (str):
value (str or float):
Valid numeric values are:
* "knn": k value for the k-nearest neighbor connection strategy (only for
PRM)
* "connectionThreshold": a milestone connection threshold
* "perturbationRadius": (for RRT and SBL)
* "bidirectional": 1 if bidirectional planning is requested (for RRT)
* "grid": 1 if a point selection grid should be used (for SBL)
* "gridResolution": resolution for the grid, if the grid should be used (for
SBL with grid, FMM, FMM*)
* "suboptimalityFactor": allowable suboptimality (for RRT*, lazy PRM*, lazy
RRG*)
* "randomizeFrequency": a grid randomization frequency (for SBL)
* "shortcut": nonzero if you wish to perform shortcutting after a first plan
is found.
* "restart": nonzero if you wish to restart the planner to get better paths
with the remaining time.
Valid string values are:
* "pointLocation": a string designating a point location data structure.
"kdtree" is supported, optionally followed by a weight vector (for PRM,
RRT*, PRM*, LazyPRM*, LazyRRG*)
* "restartTermCond": used if the "restart" setting is true. This is a JSON
string defining the termination condition.
The default value is "{foundSolution:1;maxIters:1000}", which indicates
that the planner will restart if it has found a solution, or 1000 iterations
have passed.
To restart after a certain amount of time has elasped, use
"{timeLimit:X}". If you are using an optimizing planner, e.g.,
shortcutting, you should set foundSolution:0.
"""
return _motionplanning.setPlanSetting(*args)
[docs]def destroy():
"""
destroys internal data structures
"""
return _motionplanning.destroy()
[docs]class CSpaceInterface(_object):
"""
A raw interface for a configuration space. Note: the native Python CSpace
interface class in cspace.py is easier to use.
You can either set a single feasibility test function using setFeasibility() or
add several feasibility tests, all of which need to be satisfied, using
addFeasibilityTest(). In the latter case, planners may be able to provide
debugging statistics, solve Minimum Constraint Removal problems, run faster by
eliminating constraint tests, etc.
Either setVisibility() or setVisibilityEpsilon() must be called to define a
visibility checker between two (feasible) configurations. In the latter case,
the path will be discretized at the resolution sent to setVisibilityEpsilon. If
you have special single-constraint visibility tests, you can call that using
addVisibilityTest (for example, for convex constraints you can set it to the
lambda function that returns true regardless of its arguments).
Supported properties include "euclidean" (boolean), "metric" (string),
"geodesic" (boolean), "minimum" (vector), and "maximum" (vector). These
may be used by planners to make planning faster or more accurate. For a complete
list see KrisLibrary/planning/CSpace.h.
C++ includes: motionplanning.h
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, CSpaceInterface, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, CSpaceInterface, name)
__repr__ = _swig_repr
def __init__(self, *args):
"""
__init__ (): :class:`~klampt.CSpaceInterface`
__init__ (arg2): :class:`~klampt.CSpaceInterface`
Args:
arg2 (:class:`~klampt.CSpaceInterface`, optional):
"""
this = _motionplanning.new_CSpaceInterface(*args)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _motionplanning.delete_CSpaceInterface
__del__ = lambda self: None
[docs] def destroy(self):
"""
"""
return _motionplanning.CSpaceInterface_destroy(self)
[docs] def setFeasibility(self, pyFeas):
"""
Args:
pyFeas (:obj:`object`)
"""
return _motionplanning.CSpaceInterface_setFeasibility(self, pyFeas)
[docs] def addFeasibilityTest(self, name, pyFeas):
"""
Args:
name (str)
pyFeas (:obj:`object`)
"""
return _motionplanning.CSpaceInterface_addFeasibilityTest(self, name, pyFeas)
[docs] def setVisibility(self, pyVisible):
"""
Args:
pyVisible (:obj:`object`)
"""
return _motionplanning.CSpaceInterface_setVisibility(self, pyVisible)
[docs] def addVisibilityTest(self, name, pyVisible):
"""
Args:
name (str)
pyVisible (:obj:`object`)
"""
return _motionplanning.CSpaceInterface_addVisibilityTest(self, name, pyVisible)
[docs] def setVisibilityEpsilon(self, eps):
"""
Args:
eps (float)
"""
return _motionplanning.CSpaceInterface_setVisibilityEpsilon(self, eps)
[docs] def setSampler(self, pySamp):
"""
Args:
pySamp (:obj:`object`)
"""
return _motionplanning.CSpaceInterface_setSampler(self, pySamp)
[docs] def setNeighborhoodSampler(self, pySamp):
"""
Args:
pySamp (:obj:`object`)
"""
return _motionplanning.CSpaceInterface_setNeighborhoodSampler(self, pySamp)
[docs] def setDistance(self, pyDist):
"""
Args:
pyDist (:obj:`object`)
"""
return _motionplanning.CSpaceInterface_setDistance(self, pyDist)
[docs] def setInterpolate(self, pyInterp):
"""
Args:
pyInterp (:obj:`object`)
"""
return _motionplanning.CSpaceInterface_setInterpolate(self, pyInterp)
[docs] def setProperty(self, key, value):
"""
Args:
key (str)
value (str)
"""
return _motionplanning.CSpaceInterface_setProperty(self, key, value)
[docs] def getProperty(self, key):
"""
Args:
key (str)
Returns:
str:
"""
return _motionplanning.CSpaceInterface_getProperty(self, key)
[docs] def isFeasible(self, q):
"""
Queries whether a given configuration is feasible.
Args:
q (:obj:`object`)
Returns:
bool:
"""
return _motionplanning.CSpaceInterface_isFeasible(self, q)
[docs] def isVisible(self, a, b):
"""
Queries whether two configurations are visible.
Args:
a (:obj:`object`)
b (:obj:`object`)
Returns:
bool:
"""
return _motionplanning.CSpaceInterface_isVisible(self, a, b)
[docs] def testFeasibility(self, name, q):
"""
Queries whether a given configuration is feasible with respect to a given
constraint.
Args:
name (str)
q (:obj:`object`)
Returns:
bool:
"""
return _motionplanning.CSpaceInterface_testFeasibility(self, name, q)
[docs] def testVisibility(self, name, a, b):
"""
Queries whether two configurations are visible with respect to a given
constraint.
Args:
name (str)
a (:obj:`object`)
b (:obj:`object`)
Returns:
bool:
"""
return _motionplanning.CSpaceInterface_testVisibility(self, name, a, b)
[docs] def feasibilityFailures(self, q):
"""
Returns a list of all failed feasibility constraints.
Args:
q (:obj:`object`)
Returns:
:obj:`object`:
"""
return _motionplanning.CSpaceInterface_feasibilityFailures(self, q)
[docs] def visibilityFailures(self, a, b):
"""
Returns a list of all failed visibility constraints.
Args:
a (:obj:`object`)
b (:obj:`object`)
Returns:
:obj:`object`:
"""
return _motionplanning.CSpaceInterface_visibilityFailures(self, a, b)
[docs] def sample(self):
"""
Samples a configuration.
Returns:
:obj:`object`:
"""
return _motionplanning.CSpaceInterface_sample(self)
[docs] def distance(self, a, b):
"""
Returns the distance between two configurations.
Args:
a (:obj:`object`)
b (:obj:`object`)
Returns:
float:
"""
return _motionplanning.CSpaceInterface_distance(self, a, b)
[docs] def interpolate(self, a, b, u):
"""
Interpolates between two configurations.
Args:
a (:obj:`object`)
b (:obj:`object`)
u (float)
Returns:
:obj:`object`:
"""
return _motionplanning.CSpaceInterface_interpolate(self, a, b, u)
[docs] def adaptiveQueriesEnabled(self):
"""
optional: adaptive queries can be used to automatically minimize the total cost
of testing feasibility / visibility using empirical estimates. Off by default.
Returns:
bool:
"""
return _motionplanning.CSpaceInterface_adaptiveQueriesEnabled(self)
[docs] def enableAdaptiveQueries(self, enabled=True):
"""
Call this to enable adaptive queries. (It has a small overhead.)
enableAdaptiveQueries (enabled=True)
enableAdaptiveQueries ()
Args:
enabled (bool, optional): default value True
"""
return _motionplanning.CSpaceInterface_enableAdaptiveQueries(self, enabled)
[docs] def optimizeQueryOrder(self):
"""
Call this to optimize the feasibility / visibility testing order.
"""
return _motionplanning.CSpaceInterface_optimizeQueryOrder(self)
[docs] def setFeasibilityDependency(self, name, precedingTest):
"""
Marks that a certain feasibility test must be performed before another.
Args:
name (str)
precedingTest (str)
"""
return _motionplanning.CSpaceInterface_setFeasibilityDependency(self, name, precedingTest)
[docs] def setFeasibilityPrior(self, name, costPrior=0.0, feasibilityProbability=0.0, evidenceStrength=1.0):
"""
Resets the data for a certain feasibility test. Default values give a data-
gathering behavior.
setFeasibilityPrior (name,costPrior=0.0,feasibilityProbability=0.0,evidenceStrength=1.0)
setFeasibilityPrior (name,costPrior=0.0,feasibilityProbability=0.0)
setFeasibilityPrior (name,costPrior=0.0)
setFeasibilityPrior (name)
Args:
name (str):
costPrior (float, optional): default value 0.0
feasibilityProbability (float, optional): default value 0.0
evidenceStrength (float, optional): default value 1.0
"""
return _motionplanning.CSpaceInterface_setFeasibilityPrior(self, name, costPrior, feasibilityProbability, evidenceStrength)
[docs] def setVisibilityDependency(self, name, precedingTest):
"""
Marks that a certain feasibility test must be performed before another.
Args:
name (str)
precedingTest (str)
"""
return _motionplanning.CSpaceInterface_setVisibilityDependency(self, name, precedingTest)
[docs] def setVisibilityPrior(self, name, costPrior=0.0, visibilityProbability=0.0, evidenceStrength=1.0):
"""
Resets the data for a certain visibility test. Default values give a data-
gathering behavior.
setVisibilityPrior (name,costPrior=0.0,visibilityProbability=0.0,evidenceStrength=1.0)
setVisibilityPrior (name,costPrior=0.0,visibilityProbability=0.0)
setVisibilityPrior (name,costPrior=0.0)
setVisibilityPrior (name)
Args:
name (str):
costPrior (float, optional): default value 0.0
visibilityProbability (float, optional): default value 0.0
evidenceStrength (float, optional): default value 1.0
"""
return _motionplanning.CSpaceInterface_setVisibilityPrior(self, name, costPrior, visibilityProbability, evidenceStrength)
[docs] def feasibilityCost(self, name):
"""
Retrieves the empirical average cost of a given feasibility test.
Args:
name (str)
Returns:
float:
"""
return _motionplanning.CSpaceInterface_feasibilityCost(self, name)
[docs] def feasibilityProbability(self, name):
"""
Retrieves the empirical average success rate of a given feasibility test.
Args:
name (str)
Returns:
float:
"""
return _motionplanning.CSpaceInterface_feasibilityProbability(self, name)
[docs] def visibilityCost(self, name):
"""
Retrieves the empirical average cost of a given visibility test.
Args:
name (str)
Returns:
float:
"""
return _motionplanning.CSpaceInterface_visibilityCost(self, name)
[docs] def visibilityProbability(self, name):
"""
Retrieves the empirical average success rate of a given visibility test.
Args:
name (str)
Returns:
float:
"""
return _motionplanning.CSpaceInterface_visibilityProbability(self, name)
[docs] def feasibilityQueryOrder(self):
"""
Retrieves the current order of feasibility tests.
Returns:
:obj:`object`:
"""
return _motionplanning.CSpaceInterface_feasibilityQueryOrder(self)
[docs] def visibilityQueryOrder(self):
"""
Retrieves the current order of visibility tests.
Returns:
:obj:`object`:
"""
return _motionplanning.CSpaceInterface_visibilityQueryOrder(self)
[docs] def getStats(self):
"""
Returns constraint testing statistics. If adaptive queries are enabled, this
returns the stats on each constraint.
Returns:
:obj:`object`:
"""
return _motionplanning.CSpaceInterface_getStats(self)
__swig_setmethods__["index"] = _motionplanning.CSpaceInterface_index_set
__swig_getmethods__["index"] = _motionplanning.CSpaceInterface_index_get
if _newclass:
index = _swig_property(_motionplanning.CSpaceInterface_index_get, _motionplanning.CSpaceInterface_index_set)
CSpaceInterface_swigregister = _motionplanning.CSpaceInterface_swigregister
CSpaceInterface_swigregister(CSpaceInterface)
[docs]class PlannerInterface(_object):
"""
An interface for a kinematic motion planner. The :class:`MotionPlan` interface
in cspace.py is somewhat easier to use.
On construction, uses the planner type specified by setPlanType and the settings
currently specified by calls to setPlanSetting.
Point-to-point planning is enabled by sending two configurations to the
setEndpoints method. This is mandatory for RRT and SBL-style planners. The start
and end milestones are given by indices 0 and 1, respectively
Point-to-set planning is enabled by sending a *goal test* as the second argument
to the setEndpoints method. It is possible also to send a special goal sampler
by providing a *pair of functions* as the second argument consisting of the two
functions (goaltest,goalsample). The first in this pair tests whether a
configuration is a goal, and the second returns a sampled configuration in a
superset of the goal. Ideally the goal sampler generates as many goals as
possible.
To plan, call planMore(iters) until getPath(0,1) returns non-NULL. The return
value is a list of configurations.
Some planners can be used multi-query mode (such as PRM). In multi-query mode,
you may call addMilestone(q) to add a new milestone. addMilestone() returns the
index of that milestone, which can be used in later calls to getPath().
In point-to-set mode, getSolutionPath will return the optimal path to any goal
milestone.
All planners work with the standard path-length objective function. Some
planners can work with other cost functions, and you can use setCostFunction to
set the edge / terminal costs. Usually, the results will only be optimal on the
computed graph, and the graph is not specifically computed to optimize that
cost.
To get a roadmap (V,E), call getRoadmap(). V is a list of configurations (each
configuration is a Python list) and E is a list of edges (each edge is a pair
(i,j) indexing into V).
To dump the roadmap to disk, call dump(fn). This saves to a Trivial Graph Format
(TGF) format.
C++ includes: motionplanning.h
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, PlannerInterface, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, PlannerInterface, name)
__repr__ = _swig_repr
def __init__(self, cspace):
"""
Args:
cspace (:class:`~klampt.CSpaceInterface`)
"""
this = _motionplanning.new_PlannerInterface(cspace)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _motionplanning.delete_PlannerInterface
__del__ = lambda self: None
[docs] def destroy(self):
"""
"""
return _motionplanning.PlannerInterface_destroy(self)
[docs] def setEndpoints(self, start, goal):
"""
Args:
start (:obj:`object`)
goal (:obj:`object`)
Returns:
bool:
"""
return _motionplanning.PlannerInterface_setEndpoints(self, start, goal)
[docs] def setEndpointSet(self, start, goal, goalSample=None):
"""
setEndpointSet (start,goal,goalSample=None): bool
setEndpointSet (start,goal): bool
Args:
start (:obj:`object`):
goal (:obj:`object`):
goalSample (:obj:`object`, optional): default value None
Returns:
(bool):
"""
return _motionplanning.PlannerInterface_setEndpointSet(self, start, goal, goalSample)
[docs] def setCostFunction(self, edgeCost=None, terminalCost=None):
"""
setCostFunction (edgeCost=None,terminalCost=None)
setCostFunction (edgeCost=None)
setCostFunction ()
Args:
edgeCost (:obj:`object`, optional): default value None
terminalCost (:obj:`object`, optional): default value None
"""
return _motionplanning.PlannerInterface_setCostFunction(self, edgeCost, terminalCost)
[docs] def addMilestone(self, milestone):
"""
Args:
milestone (:obj:`object`)
Returns:
int:
"""
return _motionplanning.PlannerInterface_addMilestone(self, milestone)
[docs] def getClosestMilestone(self, config):
"""
Args:
config (:obj:`object`)
Returns:
int:
"""
return _motionplanning.PlannerInterface_getClosestMilestone(self, config)
[docs] def getMilestone(self, arg2):
"""
Args:
arg2 (int)
Returns:
:obj:`object`:
"""
return _motionplanning.PlannerInterface_getMilestone(self, arg2)
[docs] def planMore(self, iterations):
"""
Args:
iterations (int)
"""
return _motionplanning.PlannerInterface_planMore(self, iterations)
[docs] def getSolutionPath(self):
"""
Returns:
:obj:`object`:
"""
return _motionplanning.PlannerInterface_getSolutionPath(self)
[docs] def getPath(self, *args):
"""
getPath (milestone1,milestone2): :obj:`object`
getPath (milestone1,int,goalMilestones): :obj:`object`
Args:
milestone1 (int):
milestone2 (int, optional):
int (:obj:`std::vector<`, optional):
goalMilestones (:obj:`std::allocator< int > >`, optional):
Returns:
(:obj:`object`):
"""
return _motionplanning.PlannerInterface_getPath(self, *args)
[docs] def getData(self, setting):
"""
Args:
setting (str)
Returns:
float:
"""
return _motionplanning.PlannerInterface_getData(self, setting)
[docs] def getStats(self):
"""
Returns:
:obj:`object`:
"""
return _motionplanning.PlannerInterface_getStats(self)
[docs] def getRoadmap(self):
"""
Returns:
:obj:`object`:
"""
return _motionplanning.PlannerInterface_getRoadmap(self)
[docs] def dump(self, fn):
"""
Args:
fn (str)
"""
return _motionplanning.PlannerInterface_dump(self, fn)
__swig_setmethods__["index"] = _motionplanning.PlannerInterface_index_set
__swig_getmethods__["index"] = _motionplanning.PlannerInterface_index_get
if _newclass:
index = _swig_property(_motionplanning.PlannerInterface_index_get, _motionplanning.PlannerInterface_index_set)
__swig_setmethods__["spaceIndex"] = _motionplanning.PlannerInterface_spaceIndex_set
__swig_getmethods__["spaceIndex"] = _motionplanning.PlannerInterface_spaceIndex_get
if _newclass:
spaceIndex = _swig_property(_motionplanning.PlannerInterface_spaceIndex_get, _motionplanning.PlannerInterface_spaceIndex_set)
PlannerInterface_swigregister = _motionplanning.PlannerInterface_swigregister
PlannerInterface_swigregister(PlannerInterface)
[docs]def interpolate1DMinTime(x0, v0, x1, v1, xmin, xmax, vmax, amax):
"""interpolate1DMinTime(double x0, double v0, double x1, double v1, double xmin, double xmax, double vmax, double amax)"""
return _motionplanning.interpolate1DMinTime(x0, v0, x1, v1, xmin, xmax, vmax, amax)
[docs]def interpolate1DMinAccel(x0, v0, x1, v1, endTime, xmin, xmax, vmax):
"""interpolate1DMinAccel(double x0, double v0, double x1, double v1, double endTime, double xmin, double xmax, double vmax)"""
return _motionplanning.interpolate1DMinAccel(x0, v0, x1, v1, endTime, xmin, xmax, vmax)
[docs]def interpolateNDMinTime(x0, v0, x1, v1, xmin, xmax, vmax, amax):
"""interpolateNDMinTime(doubleVector x0, doubleVector v0, doubleVector x1, doubleVector v1, doubleVector xmin, doubleVector xmax, doubleVector vmax, doubleVector amax)"""
return _motionplanning.interpolateNDMinTime(x0, v0, x1, v1, xmin, xmax, vmax, amax)
[docs]def interpolateNDMinAccel(x0, v0, x1, v1, endTime, xmin, xmax, vmax):
"""interpolateNDMinAccel(doubleVector x0, doubleVector v0, doubleVector x1, doubleVector v1, double endTime, doubleVector xmin, doubleVector xmax, doubleVector vmax)"""
return _motionplanning.interpolateNDMinAccel(x0, v0, x1, v1, endTime, xmin, xmax, vmax)
[docs]def interpolateNDMinTimeLinear(x0, x1, vmax, amax):
"""interpolateNDMinTimeLinear(doubleVector x0, doubleVector x1, doubleVector vmax, doubleVector amax)"""
return _motionplanning.interpolateNDMinTimeLinear(x0, x1, vmax, amax)
[docs]def combineNDCubic(times, positions, velocities):
"""combineNDCubic(doubleMatrix times, doubleMatrix positions, doubleMatrix velocities)"""
return _motionplanning.combineNDCubic(times, positions, velocities)
# This file is compatible with both classic and new-style classes.