org.robokind.api.animation.compiled
Class CompiledPath
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<Double>
org.robokind.api.animation.compiled.CompiledPath
- All Implemented Interfaces:
- Serializable, Cloneable, Iterable<Double>, Collection<Double>, List<Double>, RandomAccess
public class CompiledPath
- extends ArrayList<Double>
An ArrayList of servo positions.
The positions are spaced by myStepLength, in milliseconds.
- Author:
- Matthew Stevenson
- See Also:
- Serialized Form
Constructor Summary |
CompiledPath(long start,
long stepLength)
Constructs an empty path list with give start time and step length. |
Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
CompiledPath
public CompiledPath(long start,
long stepLength)
- Constructs an empty path list with give start time and step length.
- Parameters:
start
- offset for each positionstepLength
- milliseconds between positions
getEndTime
public Long getEndTime()
- Returns the time (from 0) the last position is expected to be consumed.
This is equal to the startTime + stepLength*positions.
- Returns:
- time path is expected to end
getStartTime
public Long getStartTime()
- Returns the start offset time. The time position i in the path should be
used is myStartTime + myStepLength*i.
- Returns:
- the start offset time for each position
getStepLength
public Long getStepLength()
- Returns the time between each position in millisecond. The time position i in the path should be
used is myStartTime + myStepLength*i.
- Returns:
- the time between each position in milliseconds
getStep
public double getStep(long time)
- Returns the position for a given time. The time position i in the path should be
used is myStartTime + myStepLength*i.
- Parameters:
time
- the time of the position to be retrieved.
- Returns:
- the position for the given time. If the time is outside the
bounds of the path -1 is returned
estimatePosition
public double estimatePosition(long time)
- Returns the estimated path position for the given time.
- Parameters:
time
- time for which to estimate
- Returns:
- estimated position at time
matches
public boolean matches(long start,
long end,
long step)
- Checks if the given values correspond to this CompiledPath.
- Parameters:
start
- offset for each positionend
- bound on the time of the last positionstep
- expected position spacing
- Returns:
- true if the given values match this path, otherwise false
clone
public CompiledPath clone()
- Creates a deep copy of the CompiledPath.
- Overrides:
clone
in class ArrayList<Double>
- Returns:
- a deep copy of the CompiledPath
combine
public static CompiledPath combine(List<CompiledPath> paths)
- Returns a composite of the paths in the given list.
If two or more paths overlap for a give time, the path with the lowest
index is used.
- Parameters:
paths
- list of paths to add
- Returns:
- new Compiled path containing positions from given paths
setTimes
public CompiledPath setTimes(long start,
long end)
- Returns a copy of this path, using a new time window.
If there is no change in times it will return itself.
Otherwise, a new CompiledPath is created with the given start time.
If the new start time is earlier or end time later, then those positions
are filled with -1. If the new start time is later or end time earlier,
those positions are truncated.
- Parameters:
start
- the new start timeend
- the new stop time
- Returns:
- if there is no change in times returns itself, otherwise returns
a new CompiledPath consisting of values from the existing path using the
new times
compilePath
public static CompiledPath compilePath(long start,
long end,
List<Point2D> interpolated,
long stepLength)
- Creates a CompiledPath from the interpolated points.
- Parameters:
start
- path start timeend
- path end timeinterpolated
- points to compilestepLength
- milliseconds between positions multiples of stepLength
- Returns:
- CompiledPath from interpolated points
Copyright © 2011. All Rights Reserved.