pydrake.trajectories¶

class
pydrake.trajectories.
PiecewisePolynomial
¶ Bases:
pydrake.trajectories.PiecewiseTrajectory
A scalar multivariate piecewise polynomial.
PiecewisePolynomial represents a list of contiguous segments in time with a Matrix of Polynomials defined for each segment. The term segment is used for piece.
An example of a piecewise polynomial is a function of x segments in time, where for each segment a different polynomial is defined. For a more specific example, consider the absolute value function, which is a piecewise function. It uses one function for inputs values < 0, and another function for input values > 0:
int abs(int x) { if (x<0) { return x; } else return x; }
PiecewisePolynomials can be added, subtracted, and multiplied. They cannot be divided because Polynomials are not closed under division.
 Template parameter
T
:  is a scalar type.
Explicit instantiations are provided for:
 double

Cubic
(*args, **kwargs)¶ Overloaded function.
 Cubic(breaks: numpy.ndarray[float64[m, 1]], knots: numpy.ndarray[float64[m, n], flags.f_contiguous], knot_dot_start: numpy.ndarray[float64[m, 1]], knot_dot_end: numpy.ndarray[float64[m, 1]]) > pydrake.trajectories.PiecewisePolynomial
Constructs a third order PiecewisePolynomial from
breaks
andknots
. The PiecewisePolynomial is constructed such that the interior segments have the same value, first and second derivatives atbreaks
. knot_dot_at_start andknot_dot_at_end
are used for the first and last first derivatives.Raises:  RuntimeError if
breaks
andknots
have different length, breaks
is not strictly increasing,knots
has inconsistent dimensions,
knots_dot_at_start
orknot_dot_at_end
and knots
have inconsistent dimensions,breaks
has length smaller than 2.
 Cubic(breaks: numpy.ndarray[float64[m, 1]], knots: numpy.ndarray[float64[m, n], flags.f_contiguous], knots_dot: numpy.ndarray[float64[m, n], flags.f_contiguous]) > pydrake.trajectories.PiecewisePolynomial
Eigen version of Cubic(breaks, knots, knots_dot_start, knots_dot_end) where each column of knots is used as a knot point, and knots.cols() == breaks.size().
@overload PiecewisePolynomial<T> Cubic(breaks, knots, knots_dot_start, knots_dot_end)
 Cubic(breaks: numpy.ndarray[float64[m, 1]], knots: numpy.ndarray[float64[m, n], flags.f_contiguous], periodic_end: bool) > pydrake.trajectories.PiecewisePolynomial
Constructs a third order PiecewisePolynomial from
breaks
, knots and ``knots`dot. Each segment is fully specified by @knots and @knot_dot at both ends. Second derivatives are not continuous.Raises:  RuntimeError if breaks` and
knots
have different length, breaks
is not strictly increasing,breaks
and ``knots`dot have different length, knots` has inconsistent dimensions,
knots_dot
andknots
have inconsistent dimensions,breaks
has length smaller than 2.

FirstOrderHold
(arg0: numpy.ndarray[float64[m, 1]], arg1: numpy.ndarray[float64[m, n], flags.f_contiguous]) → pydrake.trajectories.PiecewisePolynomial¶ Constructs a piecewise linear PiecewisePolynomial.
Raises:  RuntimeError if
breaks
andknots
have different length, breaks
is not strictly increasing,knots
has inconsistent dimensions,
breaks
has length smaller than 2.
 RuntimeError if

Pchip
(arg0: numpy.ndarray[float64[m, 1]], arg1: numpy.ndarray[float64[m, n], flags.f_contiguous], arg2: bool) → pydrake.trajectories.PiecewisePolynomial¶ Constructs a third order PiecewisePolynomial from
breaks
andknots
. First derivatives are chosen to be “shape preserving”, i.e. ifknots
is monotonic within some interval, the interpolated data will also be monotonic. The second derivative is not guaranteed to be smooth across the entire spline.Pchip stands for “Piecewise Cubic Hermite Interpolating Polynomial”. For more details, refer to the matlab file “pchip.m”. http://home.uchicago.edu/~sctchoi/courses/cs138/interp.pdf is also a good reference.
If
zero_end_point_derivatives
is false, the first and last first derivative is chosen using a noncentered, shapepreserving threepoint formulae. See equation (2.10) in the following reference for more details. http://www.mi.sanu.ac.rs/~gvm/radovi/mon.pdf Ifzero_end_point_derivatives
is true, they are set to zeros.If
zero_end_point_derivatives
is false,breaks
andknots
must have at least 3 elements for the algorithm to determine the first derivatives.If
zero_end_point_derivatives
is true,breaks
andknots
may have 2 or more elements. For the 2 elements case, the result is equivalent to computing a cubic polynomial whose values are given byknots
, and derivatives set to zero.Raises:  RuntimeError if
breaks
andknots
have different length, breaks
is not strictly increasing,knots
has inconsistent dimensions,
breaks
has length smaller than 3 and  zero_end_point_derivatives is false,
breaks
has length smaller  than 2 and zero_end_point_derivatives is true.
 RuntimeError if

ZeroOrderHold
(arg0: numpy.ndarray[float64[m, 1]], arg1: numpy.ndarray[float64[m, n], flags.f_contiguous]) → pydrake.trajectories.PiecewisePolynomial¶ Constructs a piecewise constant PiecewisePolynomial. Note that constructing a PiecewisePolynomial requires at least two knot points, although in this case, the second knot point’s value is ignored, and only its break time is used.
Raises:  RuntimeError if
breaks
andknots
have different length, breaks
is not strictly increasing,knots
has inconsistent dimensions,
breaks
has length smaller than 2.
 RuntimeError if

__init__
(*args, **kwargs)¶ Overloaded function.
 __init__(self: pydrake.trajectories.PiecewisePolynomial) > None
 __init__(self: pydrake.trajectories.PiecewisePolynomial, arg0: numpy.ndarray[float64[m, n], flags.f_contiguous]) > None

cols
(self: pydrake.trajectories.PiecewisePolynomial) → int¶ Returns the column count of each and every PolynomialMatrix segment.

derivative
(self: pydrake.trajectories.PiecewisePolynomial, arg0: int) → pydrake.trajectories.PiecewisePolynomial¶ Takes the derivative of this PiecewisePolynomial.
Returns a PiecewisePolynomial where each segment is the derivative of the segment in the input PiecewisePolynomial. Any rules or limitations of Polynomial::derivative also apply to this function.
If
derivative_order
is given, takes the nth derivative of this PiecewisePolynomial.

rows
(self: pydrake.trajectories.PiecewisePolynomial) → int¶ Returns the row count of each and every PolynomialMatrix segment.

shiftRight
(self: pydrake.trajectories.PiecewisePolynomial, offset: float) → None¶

slice
(self: pydrake.trajectories.PiecewisePolynomial, start_segment_index: int, num_segments: int) → pydrake.trajectories.PiecewisePolynomial¶

value
(self: pydrake.trajectories.PiecewisePolynomial, arg0: float) → numpy.ndarray[float64[m, n]]¶ Evaluates the PiecewisePolynomial at the given time
t
. Parameter
t
:  The time at which to evaluate the PiecewisePolynomial.
Returns: The matrix of evaluated values.  Parameter
 Template parameter

class
pydrake.trajectories.
PiecewiseTrajectory
¶ Bases:
pydrake.trajectories.Trajectory
Abstract class that implements the basic logic of maintaining consequent segments of time (delimited by
breaks
) to implement a trajectory that is represented by simpler logic in each segment or “piece”. Template parameter
T
:  is the scalar type.
Instantiated templates for the following kinds of T’s are provided:
 double

__init__
¶ x.__init__(…) initializes x; see help(type(x)) for signature

duration
(self: pydrake.trajectories.PiecewiseTrajectory, arg0: int) → float¶

end_time
(*args, **kwargs)¶ Overloaded function.
 end_time(self: pydrake.trajectories.PiecewiseTrajectory, arg0: int) > float
 end_time(self: pydrake.trajectories.PiecewiseTrajectory) > float

get_number_of_segments
(self: pydrake.trajectories.PiecewiseTrajectory) → int¶

get_segment_index
(self: pydrake.trajectories.PiecewiseTrajectory, arg0: float) → int¶

get_segment_times
(self: pydrake.trajectories.PiecewiseTrajectory) → List[float]¶

start_time
(*args, **kwargs)¶ Overloaded function.
 start_time(self: pydrake.trajectories.PiecewiseTrajectory, arg0: int) > float
 start_time(self: pydrake.trajectories.PiecewiseTrajectory) > float
 Template parameter