klampt.model.multipath module

This module defines the MultiPath class, and methods for loading and saving multipaths from xml files.

class klampt.model.multipath.MultiPath[source]

A sophisticated path representation that allows timed/untimed paths, attached velocity information, as well as making and breaking contact.

Primarily, a MultiPath consists of a list of Sections, each of which is a path or timed trajectory along a fixed stance.

A Section can either contain the Holds defining its stance, or its stance could be defined by indices into the holdSet member of MultiPath. If all Sections have the latter structure it is known as an “aggregated” MultiPath.

sections

the segments of the multipath, each operating over a fixed stance.

Type:list of Sections
settings

an unstructured propery map ‘settings’ which can contain metadata about which robot this path applies to, how the path was created, etc.

Type:dict mapping str to str
holdSet

a set of indexed Holds, which can be referred to inside Section objects.

Type:dict mapping int to Hold
class Section[source]

Contains a path or time-parameterized trajectory, as well as a list of holds and ik constraints

If the times member is set, this is time parameterized. Otherwise, it is just a path.

settings

an unstructured property map.

Type:dict mapping str to str
configs

a list of N configurations along the path section.

Type:list of lists of floats
velocities

a list of N joint velocities along the path section.

Type:list of lists of floats, optional
times

along the path section.

Type:list of floats, optional
holds

the set of Holds that this section is required to meet.

Type:list of Holds, optional
holdIndices

the set of Holds that this section is required to meet, indexed into MultiPath.holdSet.

Type:list of ints, optional
ikObjectives

the set of extra IKObjectives that this section is required to meet.

Type:list of IKObjectives, optional
aggregateHolds(holdSimilarityThreshold=None)[source]

Aggregates holds from all sections to the global holdSet variable, and converts sections to use holdIndices. If holdSimilarityThreshold is not None, then sections’ holds that are the same within the given tolerance are combined into one hold.

checkValid()[source]

Checks for validity of the path

concat(path)[source]

Appends the path, making sure times and holds are appropriately set

deaggregateHolds()[source]

De-aggregates holds from the global holdSet variable into the sections’ holds.

duration()[source]
endConfig()[source]
endTime()[source]

Returns the final time parameter

eval(t)[source]

Evaluates the MultiPath at time t.

getIKProblem(section)[source]

Returns the set of IKObjectives that the section should satisfy

getSectionTiming(section)[source]

Returns a pair (tstart,tend) giving the timing of the section

getStance(section)[source]

Returns the list of Holds that the section should satisfy

getTrajectory(robot=None, eps=None)[source]

Returns a trajectory representation of this MultiPath. If robot is provided, then a RobotTrajectory is returned. Otherwise, if velocity information is given, then a HermiteTrajectory is returned. Otherwise, a Trajectory is returned.

If robot and eps is given, then the IK constraints along the trajectory are solved and the path is discretized at resolution eps.

hasTiming()[source]

Returns true if the multipath is timed

isContinuous()[source]

Returns true if all the sections are continuous (i.e., the last config of each section matches the start config of the next).

load(fn)[source]

Loads this multipath from a multipath xml file.

loadXML(tree)[source]

Loads a multipath from a multipath xml tree (ElementTree).

numSections()[source]
save(fn)[source]

Saves this multipath to an xml file.

saveXML()[source]

Saves this multipath to a multipath xml tree (ElementTree)

setConfig(section, configIndex, q, v=None, t=None, maintainContinuity=True)[source]

Sets a configuration along the path, maintaining continuity if maintainContinuity is true. Equivalent to self.sections[section].configs[configIndex] = q except that adjacent sections’ configurations are also modified.

startConfig()[source]
startTime()[source]
timeToSection(t)[source]

Returns the section corresponding to the time parameter t

timeToSegment(t)[source]

Returns a (section index,milestone index,param) tuple such that interpolation between the section’s milestone and its successor corresponds to time t.