klampt.plan.cspaceutils module
General utilities for creating and operating with C-spaces.
Functions:
|
|
|
|
|
|
|
Helper: makes a space's callbacks perform the default Cartesian space operations. |
Classes:
|
A cartesian product of multiple spaces, given as a list upon construction. |
|
A subspace of an ambient space, with the active DOFs given by a list of DOF indices of that ambient space. |
|
A subspace of an ambient space, with the active DOFs given by variables x that are transformed to the ambient space by the transform x_amb = A*x+b. |
|
An adaptor that "lifts" a motion planner in an |
|
An adaptor that "lifts" a motion planner in an |
- klampt.plan.cspaceutils.make_default(space)[source]
Helper: makes a space’s callbacks perform the default Cartesian space operations.
- class klampt.plan.cspaceutils.CompositeCSpace(spaces)[source]
Bases:
CSpace
A cartesian product of multiple spaces, given as a list upon construction. The feasible method can be overloaded to include interaction tests.
Methods:
subDims
()split
(x)join
(xs)feasible
(x)Overload this to define your new feasibility test.
sample
()Overload this to define a nonuniform sampler.
- class klampt.plan.cspaceutils.EmbeddedCSpace(ambientspace, subset, xinit=None)[source]
Bases:
CSpace
A subspace of an ambient space, with the active DOFs given by a list of DOF indices of that ambient space.
Note
A MotionPlan constructed on this object operates in the embedded space, NOT the ambient space. To push endpoints to the embedded space you will need to call
EmbeddedCSpace.project()
, and to pull a plan back to the ambient space, use theEmbeddedCSpace.liftPlan()
method.To make this more convenient, the
SubsetMotionPlan
class is provided for you.EmbeddedMotionPlan
does the same thing.Note
Sampling does not work directly when the ambient space has implicit manifold constraints, e.g., closed-loop constraints.
sample
andsampleneighborhood
will need to be customized so that the constraint solving is done without perturbing the seed configuration except for the dofs in the moving subset.- mapping
the list of active indices into the ambient configuration space
- Type:
list
- xinit
the initial configuration in the ambient space (by default, 0 vector)
- Type:
list, optional
Methods:
project
(xamb)Ambient space -> embedded space
lift
(xemb)Embedded space -> ambient space
liftPath
(path)Given a CSpace path, lifts it to a full ambient C-space path
projectPath
(path_amb)Given an ambient C-space path, projects it to a C-space path
feasible
(x)Overload this to define your new feasibility test.
sample
()Overload this to define a nonuniform sampler.
- class klampt.plan.cspaceutils.AffineEmbeddedCSpace(ambientspace, A, b=None)[source]
Bases:
CSpace
A subspace of an ambient space, with the active DOFs given by variables x that are transformed to the ambient space by the transform x_amb = A*x+b. Here A is a sparse matrix.
Note
A MotionPlan constructed on this object operates in the embedded space, NOT the ambient space. To push endpoints to the embedded space you will need to call
AffineEmbeddedCSpace.project()
, and to pull a plan back to the ambient space, use theAffineEmbeddedCSpace.liftPlan()
method.To make this more convenient, the
EmbeddedMotionPlan
class is provided for you.Note
Sampling does not work directly when the ambient space has implicit manifold constraints, e.g., closed-loop constraints.
sample
andsampleneighborhood
will need to be customized so that the constraint solving is done without perturbing the seed configuration except for the dofs in the moving subset.- A
the map from embedded space to ambient space
- Type:
list of dict, numpy array, or scipy sparse matrix
- b
the offset in the ambient space (by default, the 0 vector)
- Type:
list, optional
Methods:
fromRobotDrivers
(robot, ambientspace[, drivers])Creates an AffineEmbeddedCSpace for a robot's drivers.
project
(xamb)Ambient space -> embedded space
lift
(xemb)Embedded space -> ambient space
liftPath
(path)Given a CSpace path, lifts it to a full ambient C-space path
projectPath
(path_amb)Given an ambient C-space path, projects it to a C-space path
feasible
(x)Overload this to define your new feasibility test.
sample
()Overload this to define a nonuniform sampler.
- static fromRobotDrivers(robot, ambientspace, drivers=None)[source]
Creates an AffineEmbeddedCSpace for a robot’s drivers.
- Parameters:
robot (RobotModel) – the robot that you’d like to move
ambientspace (CSpace) – an ambient space on the robot’s full DOFs, e.g., RobotCSpace.
drivers (list of int or list of str, optional) – if provided, gives a list of robot’s active drivers.
- class klampt.plan.cspaceutils.SubsetMotionPlan(space, subset, q0, type=None, **options)[source]
Bases:
MotionPlan
An adaptor that “lifts” a motion planner in an
EmbeddedCSpace
to a higher dimensional ambient space. Used for planning in subsets of robot DOFs.Initializes a plan with a given CSpace and a given type. Optionally, planner options can be set via keyword arguments.
Valid values for type 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
(this list may be out-of-date; the most current documentation is listed in src/motionplanning.h)
Methods:
project
(xamb)Ambient space -> embedded space
lift
(xemb)Embedded space -> ambient space
setEndpoints
(start, goal)Takes care of projecting the start and goal (represented in the ambient space) down to the subset.
addMilestone
(x)Manually adds a milestone from the ambient space, and returns its index
getPath
([milestone1, milestone2])Lifts the motion planner's lower-dimensional path back to the ambient space
Lifts the motion planner's lower-dimensional roadmap back to the ambient space
- setEndpoints(start, goal)[source]
Takes care of projecting the start and goal (represented in the ambient space) down to the subset. Works with both config and set goals.
- class klampt.plan.cspaceutils.EmbeddedMotionPlan(space, q0, type=None, **options)[source]
Bases:
MotionPlan
An adaptor that “lifts” a motion planner in an
EmbeddedCSpace
orAffineEmbeddedCSpace
to a higher dimensional ambient space.Used for planning in robots with frozen DOFs (EmbeddedCSpace) or “affine” drivers (AffineEmbeddedCSpace).
Initializes a plan with a given CSpace and a given type. Optionally, planner options can be set via keyword arguments.
Valid values for type 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
(this list may be out-of-date; the most current documentation is listed in src/motionplanning.h)
Methods:
setEndpoints
(start, goal)Takes care of projecting the start and goal (represented in the ambient space) down to the subset.
addMilestone
(x)Manually adds a milestone from the ambient space, and returns its index
getPath
([milestone1, milestone2])Lifts the motion planner's lower-dimensional path back to the ambient space
Lifts the motion planner's lower-dimensional roadmap back to the ambient space
setCostFunction
([edgeCost, terminalCost])Sets edge / terminal costs from functions in the ambient space
pathCost
(p)Calculates the cost of a path in the ambient space.
- setEndpoints(start, goal)[source]
Takes care of projecting the start and goal (represented in the ambient space) down to the subset. Works with both config and set goals.
- getPath(milestone1=None, milestone2=None)[source]
Lifts the motion planner’s lower-dimensional path back to the ambient space
- getRoadmap()[source]
Lifts the motion planner’s lower-dimensional roadmap back to the ambient space