org.robokind.api.animation.compiled
Class CompiledPath

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<Double>
              extended by 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

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
CompiledPath(long start, long stepLength)
          Constructs an empty path list with give start time and step length.
 
Method Summary
 CompiledPath clone()
          Creates a deep copy of the CompiledPath.
static CompiledPath combine(List<CompiledPath> paths)
          Returns a composite of the paths in the given list.
static CompiledPath compilePath(long start, long end, List<Point2D> interpolated, long stepLength)
          Creates a CompiledPath from the interpolated points.
 double estimatePosition(long time)
          Returns the estimated path position for the given time.
 Long getEndTime()
          Returns the time (from 0) the last position is expected to be consumed.
 Long getStartTime()
          Returns the start offset time.
 double getStep(long time)
          Returns the position for a given time.
 Long getStepLength()
          Returns the time between each position in millisecond.
 boolean matches(long start, long end, long step)
          Checks if the given values correspond to this CompiledPath.
 CompiledPath setTimes(long start, long end)
          Returns a copy of this path, using a new time window.
 
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
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

CompiledPath

public CompiledPath(long start,
                    long stepLength)
Constructs an empty path list with give start time and step length.

Parameters:
start - offset for each position
stepLength - milliseconds between positions
Method Detail

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 position
end - bound on the time of the last position
step - 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 time
end - 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 time
end - path end time
interpolated - points to compile
stepLength - milliseconds between positions multiples of stepLength
Returns:
CompiledPath from interpolated points


Copyright © 2011-2013. All Rights Reserved.