pydrake.trajectories
- class pydrake.trajectories.BezierCurve
Bases:
pydrake.trajectories.Trajectory
A Bézier curve is defined by a set of control points p₀ through pₙ, where n is called the order of the curve (n = 1 for linear, 2 for quadratic, 3 for cubic, etc.). The first and last control points are always the endpoints of the curve; however, the intermediate control points (if any) generally do not lie on the curve, but the curve is guaranteed to stay within the convex hull of the control points.
See also BsplineTrajectory. A B-spline can be thought of as a composition of overlapping Bézier curves (where each evaluation only depends on a local subset of the control points). In contrast, evaluating a Bézier curve will use all of the control points.
Note
This class is templated; see
BezierCurve_
for the list of instantiations.- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.BezierCurve) -> None
Default initializer. Constructs an empty Bézier curve over the interval t ∈ [0, 1].
__init__(self: pydrake.trajectories.BezierCurve, start_time: float, end_time: float, control_points: numpy.ndarray[numpy.float64[m, n], flags.f_contiguous]) -> None
Constructs a Bézier curve over the interval t ∈ [start_time,
end_time`] with control points defined in the columns of `control_points
.- Precondition:
end_time >= start_time.
- AsLinearInControlPoints(self: pydrake.trajectories.BezierCurve, derivative_order: int = 1) scipy.sparse.csc_matrix[numpy.float64]
Supports writing optimizations using the control points as decision variables. This method returns the matrix,
M
, defining the control points of theorder
derivative in the form:Click to expand C++ code...
derivative.control_points() = this.control_points() * M
For instance, since we have
Click to expand C++ code...
derivative.control_points().col(k) = this.control_points() * M.col(k),
constraining the kth control point of the `n`th derivative to be in [ub, lb], could be done with:
Click to expand C++ code...
auto M = curve.AsLinearInControlPoints(n); for (int i=0; i<curve.rows(); ++i) { auto c = std::make_shared<solvers::LinearConstraint>( M.col(k).transpose(), Vector1d(lb(i)), Vector1d(ub(i))); prog.AddConstraint(c, curve.row(i).transpose()); }
Iterating over the rows of the control points is the natural sparsity pattern here (since
M
is the same for all rows). For instance, we also haveClick to expand C++ code...
derivative.control_points().row(k).T = M.T * this.control_points().row(k).T,
or
Click to expand C++ code...
vec(derivative.control_points().T) = blockMT * vec(this.control_points().T), blockMT = [ M.T, 0, .... 0 ] [ 0, M.T, 0, ... ] [ ... ] [ ... , 0, M.T ].
- Precondition:
derivative_order >= 0.
- BernsteinBasis(self: pydrake.trajectories.BezierCurve, i: int, time: float, order: Optional[int] = None) float
Returns the value of the ith basis function of
order
(1 for linear, 2 for quadratic, etc) evaluated attime
. The default value for the optional argumentorder
is theorder()
ofthis
.
- control_points(self: pydrake.trajectories.BezierCurve) numpy.ndarray[numpy.float64[m, n]]
Returns a const reference to the control points which define the curve.
- ElevateOrder(self: pydrake.trajectories.BezierCurve) None
Increases the order of the curve by 1. A Bézier curve of order n can be converted into a Bézier curve of order n + 1 with the same shape. The control points of
this
are modified to obtain the equivalent curve.
- GetExpression(self: pydrake.trajectories.BezierCurve, time: pydrake.symbolic.Variable = Variable('t', Continuous)) numpy.ndarray[object[m, 1]]
Extracts the expanded underlying polynomial expression of this curve in terms of variable
time
.
- order(self: pydrake.trajectories.BezierCurve) int
Returns the order of the curve (1 for linear, 2 for quadratic, etc.).
- template pydrake.trajectories.BezierCurve_
Instantiations:
BezierCurve_[float]
,BezierCurve_[AutoDiffXd]
,BezierCurve_[Expression]
- class pydrake.trajectories.BezierCurve_[AutoDiffXd]
Bases:
pydrake.trajectories.Trajectory_[AutoDiffXd]
A Bézier curve is defined by a set of control points p₀ through pₙ, where n is called the order of the curve (n = 1 for linear, 2 for quadratic, 3 for cubic, etc.). The first and last control points are always the endpoints of the curve; however, the intermediate control points (if any) generally do not lie on the curve, but the curve is guaranteed to stay within the convex hull of the control points.
See also BsplineTrajectory. A B-spline can be thought of as a composition of overlapping Bézier curves (where each evaluation only depends on a local subset of the control points). In contrast, evaluating a Bézier curve will use all of the control points.
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.BezierCurve_[AutoDiffXd]) -> None
Default initializer. Constructs an empty Bézier curve over the interval t ∈ [0, 1].
__init__(self: pydrake.trajectories.BezierCurve_[AutoDiffXd], start_time: float, end_time: float, control_points: numpy.ndarray[object[m, n], flags.f_contiguous]) -> None
Constructs a Bézier curve over the interval t ∈ [start_time,
end_time`] with control points defined in the columns of `control_points
.- Precondition:
end_time >= start_time.
- AsLinearInControlPoints(self: pydrake.trajectories.BezierCurve_[AutoDiffXd], derivative_order: int = 1) scipy.sparse.csc_matrix[numpy.float64]
Supports writing optimizations using the control points as decision variables. This method returns the matrix,
M
, defining the control points of theorder
derivative in the form:Click to expand C++ code...
derivative.control_points() = this.control_points() * M
For instance, since we have
Click to expand C++ code...
derivative.control_points().col(k) = this.control_points() * M.col(k),
constraining the kth control point of the `n`th derivative to be in [ub, lb], could be done with:
Click to expand C++ code...
auto M = curve.AsLinearInControlPoints(n); for (int i=0; i<curve.rows(); ++i) { auto c = std::make_shared<solvers::LinearConstraint>( M.col(k).transpose(), Vector1d(lb(i)), Vector1d(ub(i))); prog.AddConstraint(c, curve.row(i).transpose()); }
Iterating over the rows of the control points is the natural sparsity pattern here (since
M
is the same for all rows). For instance, we also haveClick to expand C++ code...
derivative.control_points().row(k).T = M.T * this.control_points().row(k).T,
or
Click to expand C++ code...
vec(derivative.control_points().T) = blockMT * vec(this.control_points().T), blockMT = [ M.T, 0, .... 0 ] [ 0, M.T, 0, ... ] [ ... ] [ ... , 0, M.T ].
- Precondition:
derivative_order >= 0.
- BernsteinBasis(self: pydrake.trajectories.BezierCurve_[AutoDiffXd], i: int, time: pydrake.autodiffutils.AutoDiffXd, order: Optional[int] = None) pydrake.autodiffutils.AutoDiffXd
Returns the value of the ith basis function of
order
(1 for linear, 2 for quadratic, etc) evaluated attime
. The default value for the optional argumentorder
is theorder()
ofthis
.
- control_points(self: pydrake.trajectories.BezierCurve_[AutoDiffXd]) numpy.ndarray[object[m, n]]
Returns a const reference to the control points which define the curve.
- ElevateOrder(self: pydrake.trajectories.BezierCurve_[AutoDiffXd]) None
Increases the order of the curve by 1. A Bézier curve of order n can be converted into a Bézier curve of order n + 1 with the same shape. The control points of
this
are modified to obtain the equivalent curve.
- GetExpression(self: pydrake.trajectories.BezierCurve_[AutoDiffXd], time: pydrake.symbolic.Variable = Variable('t', Continuous)) numpy.ndarray[object[m, 1]]
Extracts the expanded underlying polynomial expression of this curve in terms of variable
time
.
- order(self: pydrake.trajectories.BezierCurve_[AutoDiffXd]) int
Returns the order of the curve (1 for linear, 2 for quadratic, etc.).
- class pydrake.trajectories.BezierCurve_[Expression]
Bases:
pydrake.trajectories.Trajectory_[Expression]
A Bézier curve is defined by a set of control points p₀ through pₙ, where n is called the order of the curve (n = 1 for linear, 2 for quadratic, 3 for cubic, etc.). The first and last control points are always the endpoints of the curve; however, the intermediate control points (if any) generally do not lie on the curve, but the curve is guaranteed to stay within the convex hull of the control points.
See also BsplineTrajectory. A B-spline can be thought of as a composition of overlapping Bézier curves (where each evaluation only depends on a local subset of the control points). In contrast, evaluating a Bézier curve will use all of the control points.
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.BezierCurve_[Expression]) -> None
Default initializer. Constructs an empty Bézier curve over the interval t ∈ [0, 1].
__init__(self: pydrake.trajectories.BezierCurve_[Expression], start_time: float, end_time: float, control_points: numpy.ndarray[object[m, n], flags.f_contiguous]) -> None
Constructs a Bézier curve over the interval t ∈ [start_time,
end_time`] with control points defined in the columns of `control_points
.- Precondition:
end_time >= start_time.
- AsLinearInControlPoints(self: pydrake.trajectories.BezierCurve_[Expression], derivative_order: int = 1) scipy.sparse.csc_matrix[numpy.float64]
Supports writing optimizations using the control points as decision variables. This method returns the matrix,
M
, defining the control points of theorder
derivative in the form:Click to expand C++ code...
derivative.control_points() = this.control_points() * M
For instance, since we have
Click to expand C++ code...
derivative.control_points().col(k) = this.control_points() * M.col(k),
constraining the kth control point of the `n`th derivative to be in [ub, lb], could be done with:
Click to expand C++ code...
auto M = curve.AsLinearInControlPoints(n); for (int i=0; i<curve.rows(); ++i) { auto c = std::make_shared<solvers::LinearConstraint>( M.col(k).transpose(), Vector1d(lb(i)), Vector1d(ub(i))); prog.AddConstraint(c, curve.row(i).transpose()); }
Iterating over the rows of the control points is the natural sparsity pattern here (since
M
is the same for all rows). For instance, we also haveClick to expand C++ code...
derivative.control_points().row(k).T = M.T * this.control_points().row(k).T,
or
Click to expand C++ code...
vec(derivative.control_points().T) = blockMT * vec(this.control_points().T), blockMT = [ M.T, 0, .... 0 ] [ 0, M.T, 0, ... ] [ ... ] [ ... , 0, M.T ].
- Precondition:
derivative_order >= 0.
- BernsteinBasis(self: pydrake.trajectories.BezierCurve_[Expression], i: int, time: pydrake.symbolic.Expression, order: Optional[int] = None) pydrake.symbolic.Expression
Returns the value of the ith basis function of
order
(1 for linear, 2 for quadratic, etc) evaluated attime
. The default value for the optional argumentorder
is theorder()
ofthis
.
- control_points(self: pydrake.trajectories.BezierCurve_[Expression]) numpy.ndarray[object[m, n]]
Returns a const reference to the control points which define the curve.
- ElevateOrder(self: pydrake.trajectories.BezierCurve_[Expression]) None
Increases the order of the curve by 1. A Bézier curve of order n can be converted into a Bézier curve of order n + 1 with the same shape. The control points of
this
are modified to obtain the equivalent curve.
- GetExpression(self: pydrake.trajectories.BezierCurve_[Expression], time: pydrake.symbolic.Variable = Variable('t', Continuous)) numpy.ndarray[object[m, 1]]
Extracts the expanded underlying polynomial expression of this curve in terms of variable
time
.
- order(self: pydrake.trajectories.BezierCurve_[Expression]) int
Returns the order of the curve (1 for linear, 2 for quadratic, etc.).
- class pydrake.trajectories.BsplineTrajectory
Bases:
pydrake.trajectories.Trajectory
Represents a B-spline curve using a given
basis
with orderedcontrol_points
such that each control point is a matrix in ℝʳᵒʷˢ ˣ ᶜᵒˡˢ.See also
math::BsplineBasis
Note
This class is templated; see
BsplineTrajectory_
for the list of instantiations.- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.BsplineTrajectory) -> None
__init__(self: pydrake.trajectories.BsplineTrajectory, basis: pydrake.math.BsplineBasis, control_points: list[list[float]]) -> None
Constructs a B-spline trajectory with the given
basis
andcontrol_points
.- Precondition:
control_points.size() == basis.num_basis_functions()
__init__(self: pydrake.trajectories.BsplineTrajectory, basis: pydrake.math.BsplineBasis, control_points: list[numpy.ndarray[numpy.float64[m, n]]]) -> None
Constructs a B-spline trajectory with the given
basis
andcontrol_points
.- Precondition:
control_points.size() == basis.num_basis_functions()
- basis(self: pydrake.trajectories.BsplineTrajectory) pydrake.math.BsplineBasis
Returns the basis of this curve.
- control_points(self: pydrake.trajectories.BsplineTrajectory) list[numpy.ndarray[numpy.float64[m, n]]]
Returns the control points of this curve.
- CopyBlock(self: pydrake.trajectories.BsplineTrajectory, start_row: int, start_col: int, block_rows: int, block_cols: int) pydrake.trajectories.BsplineTrajectory
Returns a new BsplineTrajectory that uses the same basis as
this
, and whose control points are the result of callingpoint.block(start_row, start_col, block_rows, block_cols)
on eachpoint
inthis->control_points()
.
- CopyHead(self: pydrake.trajectories.BsplineTrajectory, n: int) pydrake.trajectories.BsplineTrajectory
Returns a new BsplineTrajectory that uses the same basis as
this
, and whose control points are the result of callingpoint.head(n)
on eachpoint
inthis->control_points()
.- Precondition:
this->cols() == 1
- Precondition:
control_points()[0].head(n) must be a valid operation.
- FinalValue(self: pydrake.trajectories.BsplineTrajectory) numpy.ndarray[numpy.float64[m, n]]
Returns this->value(this->end_time())
- InitialValue(self: pydrake.trajectories.BsplineTrajectory) numpy.ndarray[numpy.float64[m, n]]
Returns this->value(this->start_time())
- InsertKnots(self: pydrake.trajectories.BsplineTrajectory, additional_knots: list[float]) None
Adds new knots at the specified
additional_knots
without changing the behavior of the trajectory. The basis and control points of the trajectory are adjusted such that it produces the same value for any valid time before and after this method is called. The resulting trajectory is guaranteed to have the same level of continuity as the original, even if knot values are duplicated. Note thatadditional_knots
need not be sorted.- Precondition:
start_time() <= t <= end_time() for all t in
additional_knots
- num_control_points(self: pydrake.trajectories.BsplineTrajectory) int
Returns the number of control points in this curve.
- template pydrake.trajectories.BsplineTrajectory_
Instantiations:
BsplineTrajectory_[float]
,BsplineTrajectory_[AutoDiffXd]
,BsplineTrajectory_[Expression]
- class pydrake.trajectories.BsplineTrajectory_[AutoDiffXd]
Bases:
pydrake.trajectories.Trajectory_[AutoDiffXd]
Represents a B-spline curve using a given
basis
with orderedcontrol_points
such that each control point is a matrix in ℝʳᵒʷˢ ˣ ᶜᵒˡˢ.See also
math::BsplineBasis
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.BsplineTrajectory_[AutoDiffXd]) -> None
__init__(self: pydrake.trajectories.BsplineTrajectory_[AutoDiffXd], basis: pydrake.math.BsplineBasis_[AutoDiffXd], control_points: list[list[pydrake.autodiffutils.AutoDiffXd]]) -> None
Constructs a B-spline trajectory with the given
basis
andcontrol_points
.- Precondition:
control_points.size() == basis.num_basis_functions()
__init__(self: pydrake.trajectories.BsplineTrajectory_[AutoDiffXd], basis: pydrake.math.BsplineBasis_[AutoDiffXd], control_points: list[numpy.ndarray[object[m, n]]]) -> None
Constructs a B-spline trajectory with the given
basis
andcontrol_points
.- Precondition:
control_points.size() == basis.num_basis_functions()
- basis(self: pydrake.trajectories.BsplineTrajectory_[AutoDiffXd]) pydrake.math.BsplineBasis_[AutoDiffXd]
Returns the basis of this curve.
- Clone(self: pydrake.trajectories.BsplineTrajectory_[AutoDiffXd]) pydrake.trajectories.Trajectory_[AutoDiffXd]
- control_points(self: pydrake.trajectories.BsplineTrajectory_[AutoDiffXd]) list[numpy.ndarray[object[m, n]]]
Returns the control points of this curve.
- CopyBlock(self: pydrake.trajectories.BsplineTrajectory_[AutoDiffXd], start_row: int, start_col: int, block_rows: int, block_cols: int) pydrake.trajectories.BsplineTrajectory_[AutoDiffXd]
Returns a new BsplineTrajectory that uses the same basis as
this
, and whose control points are the result of callingpoint.block(start_row, start_col, block_rows, block_cols)
on eachpoint
inthis->control_points()
.
- CopyHead(self: pydrake.trajectories.BsplineTrajectory_[AutoDiffXd], n: int) pydrake.trajectories.BsplineTrajectory_[AutoDiffXd]
Returns a new BsplineTrajectory that uses the same basis as
this
, and whose control points are the result of callingpoint.head(n)
on eachpoint
inthis->control_points()
.- Precondition:
this->cols() == 1
- Precondition:
control_points()[0].head(n) must be a valid operation.
- FinalValue(self: pydrake.trajectories.BsplineTrajectory_[AutoDiffXd]) numpy.ndarray[object[m, n]]
Returns this->value(this->end_time())
- InitialValue(self: pydrake.trajectories.BsplineTrajectory_[AutoDiffXd]) numpy.ndarray[object[m, n]]
Returns this->value(this->start_time())
- InsertKnots(self: pydrake.trajectories.BsplineTrajectory_[AutoDiffXd], additional_knots: list[pydrake.autodiffutils.AutoDiffXd]) None
Adds new knots at the specified
additional_knots
without changing the behavior of the trajectory. The basis and control points of the trajectory are adjusted such that it produces the same value for any valid time before and after this method is called. The resulting trajectory is guaranteed to have the same level of continuity as the original, even if knot values are duplicated. Note thatadditional_knots
need not be sorted.- Precondition:
start_time() <= t <= end_time() for all t in
additional_knots
- num_control_points(self: pydrake.trajectories.BsplineTrajectory_[AutoDiffXd]) int
Returns the number of control points in this curve.
- class pydrake.trajectories.BsplineTrajectory_[Expression]
Bases:
pydrake.trajectories.Trajectory_[Expression]
Represents a B-spline curve using a given
basis
with orderedcontrol_points
such that each control point is a matrix in ℝʳᵒʷˢ ˣ ᶜᵒˡˢ.See also
math::BsplineBasis
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.BsplineTrajectory_[Expression]) -> None
__init__(self: pydrake.trajectories.BsplineTrajectory_[Expression], basis: pydrake.math.BsplineBasis_[Expression], control_points: list[list[pydrake.symbolic.Expression]]) -> None
Constructs a B-spline trajectory with the given
basis
andcontrol_points
.- Precondition:
control_points.size() == basis.num_basis_functions()
__init__(self: pydrake.trajectories.BsplineTrajectory_[Expression], basis: pydrake.math.BsplineBasis_[Expression], control_points: list[numpy.ndarray[object[m, n]]]) -> None
Constructs a B-spline trajectory with the given
basis
andcontrol_points
.- Precondition:
control_points.size() == basis.num_basis_functions()
- basis(self: pydrake.trajectories.BsplineTrajectory_[Expression]) pydrake.math.BsplineBasis_[Expression]
Returns the basis of this curve.
- Clone(self: pydrake.trajectories.BsplineTrajectory_[Expression]) pydrake.trajectories.Trajectory_[Expression]
- control_points(self: pydrake.trajectories.BsplineTrajectory_[Expression]) list[numpy.ndarray[object[m, n]]]
Returns the control points of this curve.
- CopyBlock(self: pydrake.trajectories.BsplineTrajectory_[Expression], start_row: int, start_col: int, block_rows: int, block_cols: int) pydrake.trajectories.BsplineTrajectory_[Expression]
Returns a new BsplineTrajectory that uses the same basis as
this
, and whose control points are the result of callingpoint.block(start_row, start_col, block_rows, block_cols)
on eachpoint
inthis->control_points()
.
- CopyHead(self: pydrake.trajectories.BsplineTrajectory_[Expression], n: int) pydrake.trajectories.BsplineTrajectory_[Expression]
Returns a new BsplineTrajectory that uses the same basis as
this
, and whose control points are the result of callingpoint.head(n)
on eachpoint
inthis->control_points()
.- Precondition:
this->cols() == 1
- Precondition:
control_points()[0].head(n) must be a valid operation.
- FinalValue(self: pydrake.trajectories.BsplineTrajectory_[Expression]) numpy.ndarray[object[m, n]]
Returns this->value(this->end_time())
- InitialValue(self: pydrake.trajectories.BsplineTrajectory_[Expression]) numpy.ndarray[object[m, n]]
Returns this->value(this->start_time())
- InsertKnots(self: pydrake.trajectories.BsplineTrajectory_[Expression], additional_knots: list[pydrake.symbolic.Expression]) None
Adds new knots at the specified
additional_knots
without changing the behavior of the trajectory. The basis and control points of the trajectory are adjusted such that it produces the same value for any valid time before and after this method is called. The resulting trajectory is guaranteed to have the same level of continuity as the original, even if knot values are duplicated. Note thatadditional_knots
need not be sorted.- Precondition:
start_time() <= t <= end_time() for all t in
additional_knots
- num_control_points(self: pydrake.trajectories.BsplineTrajectory_[Expression]) int
Returns the number of control points in this curve.
- class pydrake.trajectories.CompositeTrajectory
Bases:
pydrake.trajectories.PiecewiseTrajectory
A “composite trajectory” is a series of trajectories joined end to end where the end time of one trajectory coincides with the starting time of the next.
See also PiecewisePolynomial::ConcatenateInTime(), which might be preferred if all of the segments are PiecewisePolynomial.
Note
This class is templated; see
CompositeTrajectory_
for the list of instantiations.- __init__(self: pydrake.trajectories.CompositeTrajectory, segments: list[pydrake.trajectories.Trajectory]) None
Constructs a composite trajectory from a list of Trajectories.
- Precondition:
∀i,
segments[i].get() != nullptr
.- Precondition:
∀i,
segments[i+1].start_time() == segments[i].end_time()
.- Precondition:
∀i,
segments[i].rows() == segments[0].rows()
and segments[i].cols() == segments[0].cols()`.
- static AlignAndConcatenate(segments: list[pydrake.trajectories.Trajectory]) pydrake.trajectories.CompositeTrajectory
Constructs a composite trajectory from a list of trajectories whose start and end times may not coincide, by translating their start and end times.
- Precondition:
∀i,
segments[i].get() != nullptr
.- Precondition:
∀i,
segments[i].rows() == segments[0].rows()
and segments[i].cols() == segments[0].cols()`.
- segment(self: pydrake.trajectories.CompositeTrajectory, segment_index: int) pydrake.trajectories.Trajectory
Returns a reference to the
segment_index
trajectory.
- template pydrake.trajectories.CompositeTrajectory_
Instantiations:
CompositeTrajectory_[float]
,CompositeTrajectory_[AutoDiffXd]
,CompositeTrajectory_[Expression]
- class pydrake.trajectories.CompositeTrajectory_[AutoDiffXd]
Bases:
pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd]
A “composite trajectory” is a series of trajectories joined end to end where the end time of one trajectory coincides with the starting time of the next.
See also PiecewisePolynomial::ConcatenateInTime(), which might be preferred if all of the segments are PiecewisePolynomial.
- __init__(self: pydrake.trajectories.CompositeTrajectory_[AutoDiffXd], segments: list[pydrake.trajectories.Trajectory_[AutoDiffXd]]) None
Constructs a composite trajectory from a list of Trajectories.
- Precondition:
∀i,
segments[i].get() != nullptr
.- Precondition:
∀i,
segments[i+1].start_time() == segments[i].end_time()
.- Precondition:
∀i,
segments[i].rows() == segments[0].rows()
and segments[i].cols() == segments[0].cols()`.
- static AlignAndConcatenate(segments: list[pydrake.trajectories.Trajectory_[AutoDiffXd]]) pydrake.trajectories.CompositeTrajectory_[AutoDiffXd]
Constructs a composite trajectory from a list of trajectories whose start and end times may not coincide, by translating their start and end times.
- Precondition:
∀i,
segments[i].get() != nullptr
.- Precondition:
∀i,
segments[i].rows() == segments[0].rows()
and segments[i].cols() == segments[0].cols()`.
- segment(self: pydrake.trajectories.CompositeTrajectory_[AutoDiffXd], segment_index: int) pydrake.trajectories.Trajectory_[AutoDiffXd]
Returns a reference to the
segment_index
trajectory.
- class pydrake.trajectories.CompositeTrajectory_[Expression]
Bases:
pydrake.trajectories.PiecewiseTrajectory_[Expression]
A “composite trajectory” is a series of trajectories joined end to end where the end time of one trajectory coincides with the starting time of the next.
See also PiecewisePolynomial::ConcatenateInTime(), which might be preferred if all of the segments are PiecewisePolynomial.
- __init__(self: pydrake.trajectories.CompositeTrajectory_[Expression], segments: list[pydrake.trajectories.Trajectory_[Expression]]) None
Constructs a composite trajectory from a list of Trajectories.
- Precondition:
∀i,
segments[i].get() != nullptr
.- Precondition:
∀i,
segments[i+1].start_time() == segments[i].end_time()
.- Precondition:
∀i,
segments[i].rows() == segments[0].rows()
and segments[i].cols() == segments[0].cols()`.
- static AlignAndConcatenate(segments: list[pydrake.trajectories.Trajectory_[Expression]]) pydrake.trajectories.CompositeTrajectory_[Expression]
Constructs a composite trajectory from a list of trajectories whose start and end times may not coincide, by translating their start and end times.
- Precondition:
∀i,
segments[i].get() != nullptr
.- Precondition:
∀i,
segments[i].rows() == segments[0].rows()
and segments[i].cols() == segments[0].cols()`.
- segment(self: pydrake.trajectories.CompositeTrajectory_[Expression], segment_index: int) pydrake.trajectories.Trajectory_[Expression]
Returns a reference to the
segment_index
trajectory.
- class pydrake.trajectories.DerivativeTrajectory
Bases:
pydrake.trajectories.Trajectory
Trajectory objects provide derivatives by implementing
DoEvalDerivative
andDoMakeDerivative
. DoEvalDerivative evaluates the derivative value at a point in time.DoMakeDerivative
returns a new Trajectory object which represents the derivative.In some cases, it is easy to implement
DoEvalDerivative
, but difficult or inefficient to implementDoMakeDerivative
natively. And it may be just as efficient to useDoEvalDerivative
even in repeated evaluations of the derivative. The DerivativeTrajectory class helps with this case – given anominal
Trajectory, it provides a Trajectory interface that callsnominal.EvalDerivative()
to implementTrajectory::value()
.Note
This class is templated; see
DerivativeTrajectory_
for the list of instantiations.- __init__(self: pydrake.trajectories.DerivativeTrajectory, nominal: pydrake.trajectories.Trajectory, derivative_order: int = 1) None
Creates a DerivativeTrajectory representing the
derivative_order
derivatives ofnominal
. This constructor makes a Clone() ofnominal
and does not hold on to the reference.- Raises
RuntimeError if !nominal.has_derivative() –
RuntimeError if derivative_order < 0. –
- template pydrake.trajectories.DerivativeTrajectory_
Instantiations:
DerivativeTrajectory_[float]
,DerivativeTrajectory_[AutoDiffXd]
,DerivativeTrajectory_[Expression]
- class pydrake.trajectories.DerivativeTrajectory_[AutoDiffXd]
Bases:
pydrake.trajectories.Trajectory_[AutoDiffXd]
Trajectory objects provide derivatives by implementing
DoEvalDerivative
andDoMakeDerivative
. DoEvalDerivative evaluates the derivative value at a point in time.DoMakeDerivative
returns a new Trajectory object which represents the derivative.In some cases, it is easy to implement
DoEvalDerivative
, but difficult or inefficient to implementDoMakeDerivative
natively. And it may be just as efficient to useDoEvalDerivative
even in repeated evaluations of the derivative. The DerivativeTrajectory class helps with this case – given anominal
Trajectory, it provides a Trajectory interface that callsnominal.EvalDerivative()
to implementTrajectory::value()
.- __init__(self: pydrake.trajectories.DerivativeTrajectory_[AutoDiffXd], nominal: pydrake.trajectories.Trajectory_[AutoDiffXd], derivative_order: int = 1) None
Creates a DerivativeTrajectory representing the
derivative_order
derivatives ofnominal
. This constructor makes a Clone() ofnominal
and does not hold on to the reference.- Raises
RuntimeError if !nominal.has_derivative() –
RuntimeError if derivative_order < 0. –
- Clone(self: pydrake.trajectories.DerivativeTrajectory_[AutoDiffXd]) pydrake.trajectories.Trajectory_[AutoDiffXd]
- class pydrake.trajectories.DerivativeTrajectory_[Expression]
Bases:
pydrake.trajectories.Trajectory_[Expression]
Trajectory objects provide derivatives by implementing
DoEvalDerivative
andDoMakeDerivative
. DoEvalDerivative evaluates the derivative value at a point in time.DoMakeDerivative
returns a new Trajectory object which represents the derivative.In some cases, it is easy to implement
DoEvalDerivative
, but difficult or inefficient to implementDoMakeDerivative
natively. And it may be just as efficient to useDoEvalDerivative
even in repeated evaluations of the derivative. The DerivativeTrajectory class helps with this case – given anominal
Trajectory, it provides a Trajectory interface that callsnominal.EvalDerivative()
to implementTrajectory::value()
.- __init__(self: pydrake.trajectories.DerivativeTrajectory_[Expression], nominal: pydrake.trajectories.Trajectory_[Expression], derivative_order: int = 1) None
Creates a DerivativeTrajectory representing the
derivative_order
derivatives ofnominal
. This constructor makes a Clone() ofnominal
and does not hold on to the reference.- Raises
RuntimeError if !nominal.has_derivative() –
RuntimeError if derivative_order < 0. –
- Clone(self: pydrake.trajectories.DerivativeTrajectory_[Expression]) pydrake.trajectories.Trajectory_[Expression]
- class pydrake.trajectories.ExponentialPlusPiecewisePolynomial
Bases:
pydrake.trajectories.PiecewiseTrajectory
Represents a piecewise-trajectory with piece \(j\) given by:
\[x(t) = K e^{A (t - t_j)} \alpha_j + \sum_{i=0}^k \beta_{j,i}(t-t_j)^i,\]where \(k\) is the order of the
piecewise_polynomial_part
and \(t_j\) is the start time of the \(j\)-th segment.This particular form can represent the solution to a linear dynamical system driven by a piecewise-polynomial input:
\[\dot{x}(t) = A x(t) + B u(t),\]where the input \(u(t)\) is a piecewise-polynomial function of time. See [1] for details and a motivating use case.
[1] R. Tedrake, S. Kuindersma, R. Deits and K. Miura, “A closed-form solution for real-time ZMP gait generation and feedback stabilization,” 2015 IEEE-RAS 15th International Conference on Humanoid Robots (Humanoids), Seoul, 2015, pp. 936-940.
Note
This class is templated; see
ExponentialPlusPiecewisePolynomial_
for the list of instantiations.- __init__(self: pydrake.trajectories.ExponentialPlusPiecewisePolynomial, K: numpy.ndarray[numpy.float64[m, n]], A: numpy.ndarray[numpy.float64[m, n]], alpha: numpy.ndarray[numpy.float64[m, n]], piecewise_polynomial_part: pydrake.trajectories.PiecewisePolynomial) None
- Clone(self: pydrake.trajectories.ExponentialPlusPiecewisePolynomial) pydrake.trajectories.Trajectory
- shiftRight(self: pydrake.trajectories.ExponentialPlusPiecewisePolynomial, offset: float) None
- template pydrake.trajectories.ExponentialPlusPiecewisePolynomial_
Instantiations:
ExponentialPlusPiecewisePolynomial_[float]
- class pydrake.trajectories.PathParameterizedTrajectory
Bases:
pydrake.trajectories.Trajectory
A trajectory defined by a path and timing trajectory.
Using a path of form
r(s)
and a time_scaling of the forms(t)
, a full trajectory of formq(t) = r(s(t))
is modeled.Note
This class is templated; see
PathParameterizedTrajectory_
for the list of instantiations.- __init__(self: pydrake.trajectories.PathParameterizedTrajectory, path: pydrake.trajectories.Trajectory, time_scaling: pydrake.trajectories.Trajectory) None
Constructs a trajectory with the given
path
andtime_scaling
.- Precondition:
time_scaling.rows() == time_scaling.cols() == 1
- path(self: pydrake.trajectories.PathParameterizedTrajectory) pydrake.trajectories.Trajectory
Returns the path of this trajectory.
- time_scaling(self: pydrake.trajectories.PathParameterizedTrajectory) pydrake.trajectories.Trajectory
Returns the time_scaling of this trajectory.
- template pydrake.trajectories.PathParameterizedTrajectory_
Instantiations:
PathParameterizedTrajectory_[float]
,PathParameterizedTrajectory_[AutoDiffXd]
,PathParameterizedTrajectory_[Expression]
- class pydrake.trajectories.PathParameterizedTrajectory_[AutoDiffXd]
Bases:
pydrake.trajectories.Trajectory_[AutoDiffXd]
A trajectory defined by a path and timing trajectory.
Using a path of form
r(s)
and a time_scaling of the forms(t)
, a full trajectory of formq(t) = r(s(t))
is modeled.- __init__(self: pydrake.trajectories.PathParameterizedTrajectory_[AutoDiffXd], path: pydrake.trajectories.Trajectory_[AutoDiffXd], time_scaling: pydrake.trajectories.Trajectory_[AutoDiffXd]) None
Constructs a trajectory with the given
path
andtime_scaling
.- Precondition:
time_scaling.rows() == time_scaling.cols() == 1
- Clone(self: pydrake.trajectories.PathParameterizedTrajectory_[AutoDiffXd]) pydrake.trajectories.Trajectory_[AutoDiffXd]
- path(self: pydrake.trajectories.PathParameterizedTrajectory_[AutoDiffXd]) pydrake.trajectories.Trajectory_[AutoDiffXd]
Returns the path of this trajectory.
- time_scaling(self: pydrake.trajectories.PathParameterizedTrajectory_[AutoDiffXd]) pydrake.trajectories.Trajectory_[AutoDiffXd]
Returns the time_scaling of this trajectory.
- class pydrake.trajectories.PathParameterizedTrajectory_[Expression]
Bases:
pydrake.trajectories.Trajectory_[Expression]
A trajectory defined by a path and timing trajectory.
Using a path of form
r(s)
and a time_scaling of the forms(t)
, a full trajectory of formq(t) = r(s(t))
is modeled.- __init__(self: pydrake.trajectories.PathParameterizedTrajectory_[Expression], path: pydrake.trajectories.Trajectory_[Expression], time_scaling: pydrake.trajectories.Trajectory_[Expression]) None
Constructs a trajectory with the given
path
andtime_scaling
.- Precondition:
time_scaling.rows() == time_scaling.cols() == 1
- Clone(self: pydrake.trajectories.PathParameterizedTrajectory_[Expression]) pydrake.trajectories.Trajectory_[Expression]
- path(self: pydrake.trajectories.PathParameterizedTrajectory_[Expression]) pydrake.trajectories.Trajectory_[Expression]
Returns the path of this trajectory.
- time_scaling(self: pydrake.trajectories.PathParameterizedTrajectory_[Expression]) pydrake.trajectories.Trajectory_[Expression]
Returns the time_scaling of this trajectory.
- class pydrake.trajectories.PiecewisePolynomial
Bases:
pydrake.trajectories.PiecewiseTrajectory
A scalar multi-variate piecewise polynomial.
PiecewisePolynomial represents a list of contiguous segments in a scalar independent variable (typically corresponding to time) with Polynomials defined at each segment. We call the output from evaluating the PiecewisePolynomial at the scalar independent variable “the output”, and that output can be either a Eigen MatrixX<T> (if evaluated using value()) or a scalar (if evaluated using scalar_value()).
An example of a piecewise polynomial is a function of m segments in time, where a different polynomial is defined for each segment. For a specific example, consider the absolute value function over the interval [-1, 1]. We can define a PiecewisePolynomial over this interval using breaks at t = { -1.0, 0.0, 1.0 }, and “samples” of abs(t).
Click to expand C++ code...
// Construct the PiecewisePolynomial. const std::vector<double> breaks = { -1.0, 0.0, 1.0 }; std::vector<Eigen::MatrixXd> samples(3); for (int i = 0; i < static_cast<int>(breaks.size()); ++i) { samples[i].resize(1, 1); samples[i](0, 0) = std::abs(breaks[i]); } const auto pp = PiecewisePolynomial<double>::FirstOrderHold(breaks, samples); const int row = 0, col = 0; // Evaluate the PiecewisePolynomial at some values. std::cout << pp.value(-.5)(row, col) << std::endl; // Outputs 0.5. std::cout << pp.value(0.0)(row, col) << std::endl; // Outputs 0.0; // Show how we can evaluate the first derivative (outputs -1.0). std::cout << pp.derivative(1).value(-.5)(row, col) << std::endl;
A note on terminology. For piecewise-polynomial interpolation, we use
breaks
to indicate the scalar (e.g. times) which form the boundary of each segment. We usesamples
to indicate the function value at thebreaks
, e.g.p(breaks[i]) = samples[i]
. The termknot
should be reserved for the “(x,y)” coordinate, hereknot[i] = (breaks[i], samples[i])
, though it is used inconsistently in the interpolation literature (sometimes forbreaks
, sometimes forsamples
), so we try to mostly avoid it here.PiecewisePolynomial objects can be added, subtracted, and multiplied. They cannot be divided because Polynomials are not closed under division.
Warning
PiecewisePolynomial silently clips input evaluations outside of the range defined by the breaks. So
pp.value(-2.0, row, col)
in the example above would evaluate to -1.0. See value().Note
This class is templated; see
PiecewisePolynomial_
for the list of instantiations.- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.PiecewisePolynomial) -> None
Constructs an empty piecewise polynomial.
__init__(self: pydrake.trajectories.PiecewisePolynomial, arg0: numpy.ndarray[numpy.float64[m, n], flags.f_contiguous]) -> None
Single segment, constant value constructor over the interval [-∞, ∞]. The constructed PiecewisePolynomial will return
constant_value
at every evaluated point (i.e.,value(t) = constant_value
∀t ∈ [-∞, ∞]).__init__(self: pydrake.trajectories.PiecewisePolynomial, arg0: list[numpy.ndarray[object[m, n]]], arg1: list[float]) -> None
Constructs a PiecewisePolynomial using matrix-output Polynomials defined over each segment.
- Precondition:
polynomials.size() == breaks.size() - 1
__init__(self: pydrake.trajectories.PiecewisePolynomial, arg0: list[pydrake.polynomial.Polynomial], arg1: list[float]) -> None
Constructs a PiecewisePolynomial using scalar-output Polynomials defined over each segment.
- Precondition:
polynomials.size() == breaks.size() - 1
- AppendCubicHermiteSegment(self: pydrake.trajectories.PiecewisePolynomial, time: float, sample: numpy.ndarray[numpy.float64[m, n], flags.f_contiguous], sample_dot: numpy.ndarray[numpy.float64[m, n], flags.f_contiguous]) None
The CubicHermite spline construction has a nice property of being incremental (each segment can be solved independently). Given a new sample and it’s derivative, this method adds one segment to the end of
this
where the start sample and derivative are taken as the value and derivative at the final break ofthis
.- Precondition:
this
is not empty()- Precondition:
time
> end_time()- Precondition:
sample
andsample_dot
must have size rows() x cols().
- AppendFirstOrderSegment(self: pydrake.trajectories.PiecewisePolynomial, time: float, sample: numpy.ndarray[numpy.float64[m, n], flags.f_contiguous]) None
Given a new sample, this method adds one segment to the end of
this
using a first-order hold, where the start sample is taken as the value at the final break ofthis
.
- Block(self: pydrake.trajectories.PiecewisePolynomial, start_row: int, start_col: int, block_rows: int, block_cols: int) pydrake.trajectories.PiecewisePolynomial
Extracts a trajectory representing a block of size (block_rows, block_cols) starting at (start_row, start_col) from the PiecewisePolynomial.
- Returns
a PiecewisePolynomial such that ret.value(t) = this.value(t).block(i,j,p,q);
- ConcatenateInTime(self: pydrake.trajectories.PiecewisePolynomial, other: pydrake.trajectories.PiecewisePolynomial) None
Concatenates
other
to the end ofthis
.Warning
The resulting PiecewisePolynomial will only be continuous to the degree that the first Polynomial of
other
is continuous with the last Polynomial ofthis
. See warning about evaluating discontinuous derivatives at breaks in derivative().- Parameter
other
: PiecewisePolynomial instance to concatenate.
- Raises
RuntimeError if trajectories' dimensions do not match each other –
(either rows() or cols() does not match between this and –
other`) –
RuntimeError if this->end_time() and other->start_time() –
are not within PiecewiseTrajectory<T>::kEpsilonTime from each –
other. –
- Parameter
- static CubicHermite(*args, **kwargs)
Overloaded function.
CubicHermite(breaks: list[float], samples: list[list[float]], samples_dot: list[list[float]]) -> pydrake.trajectories.PiecewisePolynomial
Version of CubicHermite(breaks, samples, samples_dot) that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Corresponding columns of
samples
andsamples_dot
are used as the sample point and independent variable derivative, respectively.- Precondition:
samples.cols() == samples_dot.cols() == breaks.size()
.
CubicHermite(breaks: list[float], samples: list[numpy.ndarray[numpy.float64[m, n]]], samples_dot: list[numpy.ndarray[numpy.float64[m, n]]]) -> pydrake.trajectories.PiecewisePolynomial
Constructs a third order PiecewisePolynomial using matrix samples and derivatives of samples (
samples_dot
); each matrix element ofsamples_dot
represents the derivative with respect to the independent variable (e.g., the time derivative) of the corresponding entry insamples
. Each segment is fully specified bysamples
andsample_dot
at both ends. Second derivatives are not continuous.
- static CubicShapePreserving(*args, **kwargs)
Overloaded function.
CubicShapePreserving(breaks: list[float], samples: list[list[float]], zero_end_point_derivatives: bool = False) -> pydrake.trajectories.PiecewisePolynomial
Version of CubicShapePreserving(breaks, samples, zero_end_point_derivatives) that uses vector samples and Eigen VectorXd and MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
.
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
CubicShapePreserving(breaks: list[float], samples: list[numpy.ndarray[numpy.float64[m, n]]], zero_end_point_derivatives: bool = False) -> pydrake.trajectories.PiecewisePolynomial
Constructs a third order PiecewisePolynomial using vector samples, where each column of
samples
represents a sample point. First derivatives are chosen to be “shape preserving”, i.e. ifsamples
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.MATLAB calls this method “pchip” (short for “Piecewise Cubic Hermite Interpolating Polynomial”), and provides a nice description in their documentation. http://home.uchicago.edu/~sctchoi/courses/cs138/interp.pdf is also a good reference.
If
zero_end_point_derivatives
isFalse
, the first and last first derivative is chosen using a non-centered, shape-preserving three-point 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
isTrue
, they are set to zeros.If
zero_end_point_derivatives
isFalse
, breaks andsamples
must have at least 3 elements for the algorithm to determine the first derivatives.If
zero_end_point_derivatives
isTrue
, breaks andsamples
may have 2 or more elements. For the 2 elements case, the result is equivalent to computing a cubic polynomial whose values are given bysamples
, and derivatives set to zero.- Raises
RuntimeError if –
breaks
has length smaller than 3 and
zero_end_point_derivatives` is False, - breaks has lengt –
smaller than 2 and zero_end_point_derivatives is true. –
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
- static CubicWithContinuousSecondDerivatives(*args, **kwargs)
Overloaded function.
CubicWithContinuousSecondDerivatives(breaks: list[float], samples: list[list[float]], sample_dot_at_start: numpy.ndarray[numpy.float64[m, n]], sample_dot_at_end: numpy.ndarray[numpy.float64[m, n]]) -> pydrake.trajectories.PiecewisePolynomial
Version of CubicWithContinuousSecondDerivatives() that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
.
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
CubicWithContinuousSecondDerivatives(breaks: list[float], samples: list[numpy.ndarray[numpy.float64[m, n]]], sample_dot_at_start: numpy.ndarray[numpy.float64[m, n]], sample_dot_at_end: numpy.ndarray[numpy.float64[m, n]]) -> pydrake.trajectories.PiecewisePolynomial
Constructs a third order PiecewisePolynomial using matrix samples. The PiecewisePolynomial is constructed such that the interior segments have the same value, first and second derivatives at
breaks
. sample_dot_at_start andsample_dot_at_end
are used for the first and last first derivatives.- Raises
RuntimeError if sample_dot_at_start or sample_dot_at_end –
and samples have inconsistent dimensions. –
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
CubicWithContinuousSecondDerivatives(breaks: list[float], samples: list[list[float]], periodic_end_condition: bool = False) -> pydrake.trajectories.PiecewisePolynomial
Version of CubicWithContinuousSecondDerivatives(breaks, samples) that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
.
CubicWithContinuousSecondDerivatives(breaks: list[float], samples: list[numpy.ndarray[numpy.float64[m, n]]], periodic_end: bool) -> pydrake.trajectories.PiecewisePolynomial
Constructs a third order PiecewisePolynomial using matrix samples. The PiecewisePolynomial is constructed such that the interior segments have the same value, first and second derivatives at
breaks
. Ifperiodic_end_condition
isFalse
(default), then the “Not-a-sample” end condition is used here, which means the third derivatives are continuous for the first two and last two segments. Ifperiodic_end_condition
isTrue
, then the first and second derivatives between the end of the last segment and the beginning of the first segment will be continuous. Note that the periodic end condition does not require the first and last sample to be collocated, nor does it add an additional sample to connect the first and last segments. Only first and second derivative continuity is enforced. See https://en.wikipedia.org/wiki/Spline_interpolation and https://web.archive.org/web/20140125011904/https://www.math.uh.edu/~jingqiu/math4364/spline.pdf for more about cubic splines and their end conditions. The MATLAB docs for methods “spline” and “csape” are also good references.- Precondition:
breaks
andsamples
must have at least 3 elements. Ifperiodic_end_condition
isTrue
, then for two samples, it would produce a straight line (useFirstOrderHold
for this instead), and ifperiodic_end_condition
isFalse
the problem is ill-defined.
- derivative(self: pydrake.trajectories.PiecewisePolynomial, derivative_order: int = 1) pydrake.trajectories.PiecewisePolynomial
Returns a PiecewisePolynomial where each segment is the specified derivative of the corresponding segment in
this
. Any rules or limitations of Polynomial::derivative() also apply to this function.Derivatives evaluated at non-differentiable points return the value at the left hand side of the interval.
- Parameter
derivative_order
: The order of the derivative, namely, if
derivative_order
= n, the n’th derivative of the polynomial will be returned.
Warning
In the event of discontinuous derivatives evaluated at breaks, it is not defined which polynomial (i.e., to the left or right of the break) will be the one that is evaluated at the break.
- Parameter
- static FirstOrderHold(*args, **kwargs)
Overloaded function.
FirstOrderHold(breaks: list[float], samples: list[list[float]]) -> pydrake.trajectories.PiecewisePolynomial
Version of FirstOrderHold(breaks, samples) that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
FirstOrderHold(breaks: list[float], samples: list[numpy.ndarray[numpy.float64[m, n]]]) -> pydrake.trajectories.PiecewisePolynomial
Constructs a piecewise linear PiecewisePolynomial using matrix samples.
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
- getPolynomial(self: pydrake.trajectories.PiecewisePolynomial, segment_index: int, row: int = 0, col: int = 0) pydrake.polynomial.Polynomial
Gets the Polynomial with the given matrix row and column index that corresponds to the given segment index. Equivalent to
getPolynomialMatrix(segment_index)(row, col)
.Note
Calls PiecewiseTrajectory<T>::segment_number_range_check() to validate
segment_index
.
- getPolynomialMatrix(self: pydrake.trajectories.PiecewisePolynomial, segment_index: int) numpy.ndarray[object[m, n]]
Gets the matrix of Polynomials corresponding to the given segment index.
Warning
segment_index
is not checked for validity.
- getSegmentPolynomialDegree(self: pydrake.trajectories.PiecewisePolynomial, segment_index: int, row: int = 0, col: int = 0) int
Gets the degree of the Polynomial with the given matrix row and column index that corresponds to the given segment index. Equivalent to
getPolynomial(segment_index, row, col).GetDegree()
.
- isApprox(self: pydrake.trajectories.PiecewisePolynomial, other: pydrake.trajectories.PiecewisePolynomial, tol: float, tol_type: pydrake.common.ToleranceType = <ToleranceType.kRelative: 1>) bool
Checks whether a PiecewisePolynomial is approximately equal to this one by calling Polynomial<T>::CoefficientsAlmostEqual() on every element of every segment.
See also
Polynomial<T>::CoefficientsAlmostEqual().
- static LagrangeInterpolatingPolynomial(*args, **kwargs)
Overloaded function.
LagrangeInterpolatingPolynomial(times: list[float], samples: list[list[float]]) -> pydrake.trajectories.PiecewisePolynomial
Version of LagrangeInterpolatingPolynomial(times, samples) that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == times.size()
.
LagrangeInterpolatingPolynomial(times: list[float], samples: list[numpy.ndarray[numpy.float64[m, n]]]) -> pydrake.trajectories.PiecewisePolynomial
Constructs a polynomial with a single segment of the lowest possible degree that passes through all of the sample points. See “polynomial interpolation” and/or “Lagrange polynomial” on Wikipedia for more information.
- Precondition:
times
must be monotonically increasing.- Precondition:
samples.size() == times.size()
.
- RemoveFinalSegment(self: pydrake.trajectories.PiecewisePolynomial) None
Removes the final segment from the trajectory, reducing the number of segments by 1.
- Precondition:
this
is not empty()
- Reshape(self: pydrake.trajectories.PiecewisePolynomial, rows: int, cols: int) None
Reshapes the dimensions of the Eigen::MatrixX<T> returned by value(), EvalDerivative(), etc.
- Precondition:
rows
xcols
must equal this.rows() * this.cols().
See also
Eigen::PlainObjectBase::resize().
- ReverseTime(self: pydrake.trajectories.PiecewisePolynomial) None
Modifies the trajectory so that pp_after(t) = pp_before(-t).
Note
The new trajectory will evaluate differently at precisely the break points if the original trajectory was discontinuous at the break points. This is because the segments are defined on the half-open intervals [breaks(i), breaks(i+1)), and the order of the breaks have been reversed.
- ScaleTime(self: pydrake.trajectories.PiecewisePolynomial, scale: float) None
Scales the time of the trajectory by non-negative
scale
(use ReverseTime() if you want to also negate time). The resulting polynomial evaluates to pp_after(t) = pp_before(t/scale).As an example, `scale`=2 will result in a trajectory that is twice as long (start_time() and end_time() have both doubled).
- setPolynomialMatrixBlock(self: pydrake.trajectories.PiecewisePolynomial, replacement: numpy.ndarray[object[m, n]], segment_index: int, row_start: int = 0, col_start: int = 0) None
Replaces the specified block of the PolynomialMatrix at the given segment index.
Note
Calls PiecewiseTrajectory<T>::segment_number_range_check() to validate
segment_index
.Warning
This code relies upon Eigen to verify that the replacement block is not too large.
- shiftRight(self: pydrake.trajectories.PiecewisePolynomial, offset: float) None
Adds
offset
to all of the breaks.offset
need not be a non-negative number. The resulting polynomial will evaluate to pp_after(t) = pp_before(t-offset).As an example, `offset`=2 will result in the start_time() and end_time() being 2 seconds later.
- slice(self: pydrake.trajectories.PiecewisePolynomial, start_segment_index: int, num_segments: int) pydrake.trajectories.PiecewisePolynomial
Returns the PiecewisePolynomial comprising the
num_segments
segments starting at the specifiedstart_segment_index
.Note
Calls PiecewiseTrajectory<T>::segment_number_range_check() to validate
segment_index
.
- Transpose(self: pydrake.trajectories.PiecewisePolynomial) pydrake.trajectories.PiecewisePolynomial
Constructs a new PiecewisePolynomial for which value(t) == this.value(t).transpose().
- static ZeroOrderHold(*args, **kwargs)
Overloaded function.
ZeroOrderHold(breaks: list[float], samples: list[list[float]]) -> pydrake.trajectories.PiecewisePolynomial
Version of ZeroOrderHold(breaks, samples) that uses vector samples and Eigen VectorXd/MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
ZeroOrderHold(breaks: list[float], samples: list[numpy.ndarray[numpy.float64[m, n]]]) -> pydrake.trajectories.PiecewisePolynomial
Constructs a piecewise constant PiecewisePolynomial using matrix samples. Note that constructing a PiecewisePolynomial requires at least two sample points, although in this case, the second sample point’s value is ignored, and only its break time is used.
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
- template pydrake.trajectories.PiecewisePolynomial_
Instantiations:
PiecewisePolynomial_[float]
,PiecewisePolynomial_[AutoDiffXd]
,PiecewisePolynomial_[Expression]
- class pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Bases:
pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd]
A scalar multi-variate piecewise polynomial.
PiecewisePolynomial represents a list of contiguous segments in a scalar independent variable (typically corresponding to time) with Polynomials defined at each segment. We call the output from evaluating the PiecewisePolynomial at the scalar independent variable “the output”, and that output can be either a Eigen MatrixX<T> (if evaluated using value()) or a scalar (if evaluated using scalar_value()).
An example of a piecewise polynomial is a function of m segments in time, where a different polynomial is defined for each segment. For a specific example, consider the absolute value function over the interval [-1, 1]. We can define a PiecewisePolynomial over this interval using breaks at t = { -1.0, 0.0, 1.0 }, and “samples” of abs(t).
Click to expand C++ code...
// Construct the PiecewisePolynomial. const std::vector<double> breaks = { -1.0, 0.0, 1.0 }; std::vector<Eigen::MatrixXd> samples(3); for (int i = 0; i < static_cast<int>(breaks.size()); ++i) { samples[i].resize(1, 1); samples[i](0, 0) = std::abs(breaks[i]); } const auto pp = PiecewisePolynomial<double>::FirstOrderHold(breaks, samples); const int row = 0, col = 0; // Evaluate the PiecewisePolynomial at some values. std::cout << pp.value(-.5)(row, col) << std::endl; // Outputs 0.5. std::cout << pp.value(0.0)(row, col) << std::endl; // Outputs 0.0; // Show how we can evaluate the first derivative (outputs -1.0). std::cout << pp.derivative(1).value(-.5)(row, col) << std::endl;
A note on terminology. For piecewise-polynomial interpolation, we use
breaks
to indicate the scalar (e.g. times) which form the boundary of each segment. We usesamples
to indicate the function value at thebreaks
, e.g.p(breaks[i]) = samples[i]
. The termknot
should be reserved for the “(x,y)” coordinate, hereknot[i] = (breaks[i], samples[i])
, though it is used inconsistently in the interpolation literature (sometimes forbreaks
, sometimes forsamples
), so we try to mostly avoid it here.PiecewisePolynomial objects can be added, subtracted, and multiplied. They cannot be divided because Polynomials are not closed under division.
Warning
PiecewisePolynomial silently clips input evaluations outside of the range defined by the breaks. So
pp.value(-2.0, row, col)
in the example above would evaluate to -1.0. See value().- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]) -> None
Constructs an empty piecewise polynomial.
__init__(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], arg0: numpy.ndarray[object[m, n], flags.f_contiguous]) -> None
Single segment, constant value constructor over the interval [-∞, ∞]. The constructed PiecewisePolynomial will return
constant_value
at every evaluated point (i.e.,value(t) = constant_value
∀t ∈ [-∞, ∞]).__init__(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], arg0: list[numpy.ndarray[object[m, n]]], arg1: list[pydrake.autodiffutils.AutoDiffXd]) -> None
Constructs a PiecewisePolynomial using matrix-output Polynomials defined over each segment.
- Precondition:
polynomials.size() == breaks.size() - 1
__init__(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], arg0: list[pydrake.polynomial.Polynomial_[AutoDiffXd]], arg1: list[pydrake.autodiffutils.AutoDiffXd]) -> None
Constructs a PiecewisePolynomial using scalar-output Polynomials defined over each segment.
- Precondition:
polynomials.size() == breaks.size() - 1
- AppendCubicHermiteSegment(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], time: pydrake.autodiffutils.AutoDiffXd, sample: numpy.ndarray[object[m, n], flags.f_contiguous], sample_dot: numpy.ndarray[object[m, n], flags.f_contiguous]) None
The CubicHermite spline construction has a nice property of being incremental (each segment can be solved independently). Given a new sample and it’s derivative, this method adds one segment to the end of
this
where the start sample and derivative are taken as the value and derivative at the final break ofthis
.- Precondition:
this
is not empty()- Precondition:
time
> end_time()- Precondition:
sample
andsample_dot
must have size rows() x cols().
- AppendFirstOrderSegment(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], time: pydrake.autodiffutils.AutoDiffXd, sample: numpy.ndarray[object[m, n], flags.f_contiguous]) None
Given a new sample, this method adds one segment to the end of
this
using a first-order hold, where the start sample is taken as the value at the final break ofthis
.
- Block(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], start_row: int, start_col: int, block_rows: int, block_cols: int) pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Extracts a trajectory representing a block of size (block_rows, block_cols) starting at (start_row, start_col) from the PiecewisePolynomial.
- Returns
a PiecewisePolynomial such that ret.value(t) = this.value(t).block(i,j,p,q);
- Clone(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]) pydrake.trajectories.Trajectory_[AutoDiffXd]
- ConcatenateInTime(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], other: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]) None
Concatenates
other
to the end ofthis
.Warning
The resulting PiecewisePolynomial will only be continuous to the degree that the first Polynomial of
other
is continuous with the last Polynomial ofthis
. See warning about evaluating discontinuous derivatives at breaks in derivative().- Parameter
other
: PiecewisePolynomial instance to concatenate.
- Raises
RuntimeError if trajectories' dimensions do not match each other –
(either rows() or cols() does not match between this and –
other`) –
RuntimeError if this->end_time() and other->start_time() –
are not within PiecewiseTrajectory<T>::kEpsilonTime from each –
other. –
- Parameter
- static CubicHermite(*args, **kwargs)
Overloaded function.
CubicHermite(breaks: list[pydrake.autodiffutils.AutoDiffXd], samples: list[list[pydrake.autodiffutils.AutoDiffXd]], samples_dot: list[list[pydrake.autodiffutils.AutoDiffXd]]) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Version of CubicHermite(breaks, samples, samples_dot) that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Corresponding columns of
samples
andsamples_dot
are used as the sample point and independent variable derivative, respectively.- Precondition:
samples.cols() == samples_dot.cols() == breaks.size()
.
CubicHermite(breaks: list[pydrake.autodiffutils.AutoDiffXd], samples: list[numpy.ndarray[object[m, n]]], samples_dot: list[numpy.ndarray[object[m, n]]]) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Constructs a third order PiecewisePolynomial using matrix samples and derivatives of samples (
samples_dot
); each matrix element ofsamples_dot
represents the derivative with respect to the independent variable (e.g., the time derivative) of the corresponding entry insamples
. Each segment is fully specified bysamples
andsample_dot
at both ends. Second derivatives are not continuous.
- static CubicShapePreserving(*args, **kwargs)
Overloaded function.
CubicShapePreserving(breaks: list[pydrake.autodiffutils.AutoDiffXd], samples: list[list[pydrake.autodiffutils.AutoDiffXd]], zero_end_point_derivatives: bool = False) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Version of CubicShapePreserving(breaks, samples, zero_end_point_derivatives) that uses vector samples and Eigen VectorXd and MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
.
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
CubicShapePreserving(breaks: list[pydrake.autodiffutils.AutoDiffXd], samples: list[numpy.ndarray[object[m, n]]], zero_end_point_derivatives: bool = False) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Constructs a third order PiecewisePolynomial using vector samples, where each column of
samples
represents a sample point. First derivatives are chosen to be “shape preserving”, i.e. ifsamples
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.MATLAB calls this method “pchip” (short for “Piecewise Cubic Hermite Interpolating Polynomial”), and provides a nice description in their documentation. http://home.uchicago.edu/~sctchoi/courses/cs138/interp.pdf is also a good reference.
If
zero_end_point_derivatives
isFalse
, the first and last first derivative is chosen using a non-centered, shape-preserving three-point 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
isTrue
, they are set to zeros.If
zero_end_point_derivatives
isFalse
, breaks andsamples
must have at least 3 elements for the algorithm to determine the first derivatives.If
zero_end_point_derivatives
isTrue
, breaks andsamples
may have 2 or more elements. For the 2 elements case, the result is equivalent to computing a cubic polynomial whose values are given bysamples
, and derivatives set to zero.- Raises
RuntimeError if –
breaks
has length smaller than 3 and
zero_end_point_derivatives` is False, - breaks has lengt –
smaller than 2 and zero_end_point_derivatives is true. –
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
- static CubicWithContinuousSecondDerivatives(*args, **kwargs)
Overloaded function.
CubicWithContinuousSecondDerivatives(breaks: list[pydrake.autodiffutils.AutoDiffXd], samples: list[list[pydrake.autodiffutils.AutoDiffXd]], sample_dot_at_start: numpy.ndarray[object[m, n]], sample_dot_at_end: numpy.ndarray[object[m, n]]) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Version of CubicWithContinuousSecondDerivatives() that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
.
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
CubicWithContinuousSecondDerivatives(breaks: list[pydrake.autodiffutils.AutoDiffXd], samples: list[numpy.ndarray[object[m, n]]], sample_dot_at_start: numpy.ndarray[object[m, n]], sample_dot_at_end: numpy.ndarray[object[m, n]]) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Constructs a third order PiecewisePolynomial using matrix samples. The PiecewisePolynomial is constructed such that the interior segments have the same value, first and second derivatives at
breaks
. sample_dot_at_start andsample_dot_at_end
are used for the first and last first derivatives.- Raises
RuntimeError if sample_dot_at_start or sample_dot_at_end –
and samples have inconsistent dimensions. –
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
CubicWithContinuousSecondDerivatives(breaks: list[pydrake.autodiffutils.AutoDiffXd], samples: list[list[pydrake.autodiffutils.AutoDiffXd]], periodic_end_condition: bool = False) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Version of CubicWithContinuousSecondDerivatives(breaks, samples) that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
.
CubicWithContinuousSecondDerivatives(breaks: list[pydrake.autodiffutils.AutoDiffXd], samples: list[numpy.ndarray[object[m, n]]], periodic_end: bool) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Constructs a third order PiecewisePolynomial using matrix samples. The PiecewisePolynomial is constructed such that the interior segments have the same value, first and second derivatives at
breaks
. Ifperiodic_end_condition
isFalse
(default), then the “Not-a-sample” end condition is used here, which means the third derivatives are continuous for the first two and last two segments. Ifperiodic_end_condition
isTrue
, then the first and second derivatives between the end of the last segment and the beginning of the first segment will be continuous. Note that the periodic end condition does not require the first and last sample to be collocated, nor does it add an additional sample to connect the first and last segments. Only first and second derivative continuity is enforced. See https://en.wikipedia.org/wiki/Spline_interpolation and https://web.archive.org/web/20140125011904/https://www.math.uh.edu/~jingqiu/math4364/spline.pdf for more about cubic splines and their end conditions. The MATLAB docs for methods “spline” and “csape” are also good references.- Precondition:
breaks
andsamples
must have at least 3 elements. Ifperiodic_end_condition
isTrue
, then for two samples, it would produce a straight line (useFirstOrderHold
for this instead), and ifperiodic_end_condition
isFalse
the problem is ill-defined.
- derivative(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], derivative_order: int = 1) pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Returns a PiecewisePolynomial where each segment is the specified derivative of the corresponding segment in
this
. Any rules or limitations of Polynomial::derivative() also apply to this function.Derivatives evaluated at non-differentiable points return the value at the left hand side of the interval.
- Parameter
derivative_order
: The order of the derivative, namely, if
derivative_order
= n, the n’th derivative of the polynomial will be returned.
Warning
In the event of discontinuous derivatives evaluated at breaks, it is not defined which polynomial (i.e., to the left or right of the break) will be the one that is evaluated at the break.
- Parameter
- static FirstOrderHold(*args, **kwargs)
Overloaded function.
FirstOrderHold(breaks: list[pydrake.autodiffutils.AutoDiffXd], samples: list[list[pydrake.autodiffutils.AutoDiffXd]]) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Version of FirstOrderHold(breaks, samples) that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
FirstOrderHold(breaks: list[pydrake.autodiffutils.AutoDiffXd], samples: list[numpy.ndarray[object[m, n]]]) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Constructs a piecewise linear PiecewisePolynomial using matrix samples.
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
- getPolynomial(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], segment_index: int, row: int = 0, col: int = 0) pydrake.polynomial.Polynomial_[AutoDiffXd]
Gets the Polynomial with the given matrix row and column index that corresponds to the given segment index. Equivalent to
getPolynomialMatrix(segment_index)(row, col)
.Note
Calls PiecewiseTrajectory<T>::segment_number_range_check() to validate
segment_index
.
- getPolynomialMatrix(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], segment_index: int) numpy.ndarray[object[m, n]]
Gets the matrix of Polynomials corresponding to the given segment index.
Warning
segment_index
is not checked for validity.
- getSegmentPolynomialDegree(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], segment_index: int, row: int = 0, col: int = 0) int
Gets the degree of the Polynomial with the given matrix row and column index that corresponds to the given segment index. Equivalent to
getPolynomial(segment_index, row, col).GetDegree()
.
- isApprox(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], other: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], tol: float, tol_type: pydrake.common.ToleranceType = <ToleranceType.kRelative: 1>) bool
Checks whether a PiecewisePolynomial is approximately equal to this one by calling Polynomial<T>::CoefficientsAlmostEqual() on every element of every segment.
See also
Polynomial<T>::CoefficientsAlmostEqual().
- static LagrangeInterpolatingPolynomial(*args, **kwargs)
Overloaded function.
LagrangeInterpolatingPolynomial(times: list[pydrake.autodiffutils.AutoDiffXd], samples: list[list[pydrake.autodiffutils.AutoDiffXd]]) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Version of LagrangeInterpolatingPolynomial(times, samples) that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == times.size()
.
LagrangeInterpolatingPolynomial(times: list[pydrake.autodiffutils.AutoDiffXd], samples: list[numpy.ndarray[object[m, n]]]) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Constructs a polynomial with a single segment of the lowest possible degree that passes through all of the sample points. See “polynomial interpolation” and/or “Lagrange polynomial” on Wikipedia for more information.
- Precondition:
times
must be monotonically increasing.- Precondition:
samples.size() == times.size()
.
- RemoveFinalSegment(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]) None
Removes the final segment from the trajectory, reducing the number of segments by 1.
- Precondition:
this
is not empty()
- Reshape(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], rows: int, cols: int) None
Reshapes the dimensions of the Eigen::MatrixX<T> returned by value(), EvalDerivative(), etc.
- Precondition:
rows
xcols
must equal this.rows() * this.cols().
See also
Eigen::PlainObjectBase::resize().
- ReverseTime(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]) None
Modifies the trajectory so that pp_after(t) = pp_before(-t).
Note
The new trajectory will evaluate differently at precisely the break points if the original trajectory was discontinuous at the break points. This is because the segments are defined on the half-open intervals [breaks(i), breaks(i+1)), and the order of the breaks have been reversed.
- ScaleTime(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], scale: pydrake.autodiffutils.AutoDiffXd) None
Scales the time of the trajectory by non-negative
scale
(use ReverseTime() if you want to also negate time). The resulting polynomial evaluates to pp_after(t) = pp_before(t/scale).As an example, `scale`=2 will result in a trajectory that is twice as long (start_time() and end_time() have both doubled).
- setPolynomialMatrixBlock(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], replacement: numpy.ndarray[object[m, n]], segment_index: int, row_start: int = 0, col_start: int = 0) None
Replaces the specified block of the PolynomialMatrix at the given segment index.
Note
Calls PiecewiseTrajectory<T>::segment_number_range_check() to validate
segment_index
.Warning
This code relies upon Eigen to verify that the replacement block is not too large.
- shiftRight(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], offset: pydrake.autodiffutils.AutoDiffXd) None
Adds
offset
to all of the breaks.offset
need not be a non-negative number. The resulting polynomial will evaluate to pp_after(t) = pp_before(t-offset).As an example, `offset`=2 will result in the start_time() and end_time() being 2 seconds later.
- slice(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], start_segment_index: int, num_segments: int) pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Returns the PiecewisePolynomial comprising the
num_segments
segments starting at the specifiedstart_segment_index
.Note
Calls PiecewiseTrajectory<T>::segment_number_range_check() to validate
segment_index
.
- Transpose(self: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]) pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Constructs a new PiecewisePolynomial for which value(t) == this.value(t).transpose().
- static ZeroOrderHold(*args, **kwargs)
Overloaded function.
ZeroOrderHold(breaks: list[pydrake.autodiffutils.AutoDiffXd], samples: list[list[pydrake.autodiffutils.AutoDiffXd]]) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Version of ZeroOrderHold(breaks, samples) that uses vector samples and Eigen VectorXd/MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
ZeroOrderHold(breaks: list[pydrake.autodiffutils.AutoDiffXd], samples: list[numpy.ndarray[object[m, n]]]) -> pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Constructs a piecewise constant PiecewisePolynomial using matrix samples. Note that constructing a PiecewisePolynomial requires at least two sample points, although in this case, the second sample point’s value is ignored, and only its break time is used.
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
- class pydrake.trajectories.PiecewisePolynomial_[Expression]
Bases:
pydrake.trajectories.PiecewiseTrajectory_[Expression]
A scalar multi-variate piecewise polynomial.
PiecewisePolynomial represents a list of contiguous segments in a scalar independent variable (typically corresponding to time) with Polynomials defined at each segment. We call the output from evaluating the PiecewisePolynomial at the scalar independent variable “the output”, and that output can be either a Eigen MatrixX<T> (if evaluated using value()) or a scalar (if evaluated using scalar_value()).
An example of a piecewise polynomial is a function of m segments in time, where a different polynomial is defined for each segment. For a specific example, consider the absolute value function over the interval [-1, 1]. We can define a PiecewisePolynomial over this interval using breaks at t = { -1.0, 0.0, 1.0 }, and “samples” of abs(t).
Click to expand C++ code...
// Construct the PiecewisePolynomial. const std::vector<double> breaks = { -1.0, 0.0, 1.0 }; std::vector<Eigen::MatrixXd> samples(3); for (int i = 0; i < static_cast<int>(breaks.size()); ++i) { samples[i].resize(1, 1); samples[i](0, 0) = std::abs(breaks[i]); } const auto pp = PiecewisePolynomial<double>::FirstOrderHold(breaks, samples); const int row = 0, col = 0; // Evaluate the PiecewisePolynomial at some values. std::cout << pp.value(-.5)(row, col) << std::endl; // Outputs 0.5. std::cout << pp.value(0.0)(row, col) << std::endl; // Outputs 0.0; // Show how we can evaluate the first derivative (outputs -1.0). std::cout << pp.derivative(1).value(-.5)(row, col) << std::endl;
A note on terminology. For piecewise-polynomial interpolation, we use
breaks
to indicate the scalar (e.g. times) which form the boundary of each segment. We usesamples
to indicate the function value at thebreaks
, e.g.p(breaks[i]) = samples[i]
. The termknot
should be reserved for the “(x,y)” coordinate, hereknot[i] = (breaks[i], samples[i])
, though it is used inconsistently in the interpolation literature (sometimes forbreaks
, sometimes forsamples
), so we try to mostly avoid it here.PiecewisePolynomial objects can be added, subtracted, and multiplied. They cannot be divided because Polynomials are not closed under division.
Warning
PiecewisePolynomial silently clips input evaluations outside of the range defined by the breaks. So
pp.value(-2.0, row, col)
in the example above would evaluate to -1.0. See value().- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.PiecewisePolynomial_[Expression]) -> None
Constructs an empty piecewise polynomial.
__init__(self: pydrake.trajectories.PiecewisePolynomial_[Expression], arg0: numpy.ndarray[object[m, n], flags.f_contiguous]) -> None
Single segment, constant value constructor over the interval [-∞, ∞]. The constructed PiecewisePolynomial will return
constant_value
at every evaluated point (i.e.,value(t) = constant_value
∀t ∈ [-∞, ∞]).__init__(self: pydrake.trajectories.PiecewisePolynomial_[Expression], arg0: list[numpy.ndarray[object[m, n]]], arg1: list[pydrake.symbolic.Expression]) -> None
Constructs a PiecewisePolynomial using matrix-output Polynomials defined over each segment.
- Precondition:
polynomials.size() == breaks.size() - 1
__init__(self: pydrake.trajectories.PiecewisePolynomial_[Expression], arg0: list[pydrake.polynomial.Polynomial_[Expression]], arg1: list[pydrake.symbolic.Expression]) -> None
Constructs a PiecewisePolynomial using scalar-output Polynomials defined over each segment.
- Precondition:
polynomials.size() == breaks.size() - 1
- AppendCubicHermiteSegment(self: pydrake.trajectories.PiecewisePolynomial_[Expression], time: pydrake.symbolic.Expression, sample: numpy.ndarray[object[m, n], flags.f_contiguous], sample_dot: numpy.ndarray[object[m, n], flags.f_contiguous]) None
The CubicHermite spline construction has a nice property of being incremental (each segment can be solved independently). Given a new sample and it’s derivative, this method adds one segment to the end of
this
where the start sample and derivative are taken as the value and derivative at the final break ofthis
.- Precondition:
this
is not empty()- Precondition:
time
> end_time()- Precondition:
sample
andsample_dot
must have size rows() x cols().
- AppendFirstOrderSegment(self: pydrake.trajectories.PiecewisePolynomial_[Expression], time: pydrake.symbolic.Expression, sample: numpy.ndarray[object[m, n], flags.f_contiguous]) None
Given a new sample, this method adds one segment to the end of
this
using a first-order hold, where the start sample is taken as the value at the final break ofthis
.
- Block(self: pydrake.trajectories.PiecewisePolynomial_[Expression], start_row: int, start_col: int, block_rows: int, block_cols: int) pydrake.trajectories.PiecewisePolynomial_[Expression]
Extracts a trajectory representing a block of size (block_rows, block_cols) starting at (start_row, start_col) from the PiecewisePolynomial.
- Returns
a PiecewisePolynomial such that ret.value(t) = this.value(t).block(i,j,p,q);
- Clone(self: pydrake.trajectories.PiecewisePolynomial_[Expression]) pydrake.trajectories.Trajectory_[Expression]
- ConcatenateInTime(self: pydrake.trajectories.PiecewisePolynomial_[Expression], other: pydrake.trajectories.PiecewisePolynomial_[Expression]) None
Concatenates
other
to the end ofthis
.Warning
The resulting PiecewisePolynomial will only be continuous to the degree that the first Polynomial of
other
is continuous with the last Polynomial ofthis
. See warning about evaluating discontinuous derivatives at breaks in derivative().- Parameter
other
: PiecewisePolynomial instance to concatenate.
- Raises
RuntimeError if trajectories' dimensions do not match each other –
(either rows() or cols() does not match between this and –
other`) –
RuntimeError if this->end_time() and other->start_time() –
are not within PiecewiseTrajectory<T>::kEpsilonTime from each –
other. –
- Parameter
- static CubicHermite(*args, **kwargs)
Overloaded function.
CubicHermite(breaks: list[pydrake.symbolic.Expression], samples: list[list[pydrake.symbolic.Expression]], samples_dot: list[list[pydrake.symbolic.Expression]]) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Version of CubicHermite(breaks, samples, samples_dot) that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Corresponding columns of
samples
andsamples_dot
are used as the sample point and independent variable derivative, respectively.- Precondition:
samples.cols() == samples_dot.cols() == breaks.size()
.
CubicHermite(breaks: list[pydrake.symbolic.Expression], samples: list[numpy.ndarray[object[m, n]]], samples_dot: list[numpy.ndarray[object[m, n]]]) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Constructs a third order PiecewisePolynomial using matrix samples and derivatives of samples (
samples_dot
); each matrix element ofsamples_dot
represents the derivative with respect to the independent variable (e.g., the time derivative) of the corresponding entry insamples
. Each segment is fully specified bysamples
andsample_dot
at both ends. Second derivatives are not continuous.
- static CubicShapePreserving(*args, **kwargs)
Overloaded function.
CubicShapePreserving(breaks: list[pydrake.symbolic.Expression], samples: list[list[pydrake.symbolic.Expression]], zero_end_point_derivatives: bool = False) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Version of CubicShapePreserving(breaks, samples, zero_end_point_derivatives) that uses vector samples and Eigen VectorXd and MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
.
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
CubicShapePreserving(breaks: list[pydrake.symbolic.Expression], samples: list[numpy.ndarray[object[m, n]]], zero_end_point_derivatives: bool = False) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Constructs a third order PiecewisePolynomial using vector samples, where each column of
samples
represents a sample point. First derivatives are chosen to be “shape preserving”, i.e. ifsamples
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.MATLAB calls this method “pchip” (short for “Piecewise Cubic Hermite Interpolating Polynomial”), and provides a nice description in their documentation. http://home.uchicago.edu/~sctchoi/courses/cs138/interp.pdf is also a good reference.
If
zero_end_point_derivatives
isFalse
, the first and last first derivative is chosen using a non-centered, shape-preserving three-point 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
isTrue
, they are set to zeros.If
zero_end_point_derivatives
isFalse
, breaks andsamples
must have at least 3 elements for the algorithm to determine the first derivatives.If
zero_end_point_derivatives
isTrue
, breaks andsamples
may have 2 or more elements. For the 2 elements case, the result is equivalent to computing a cubic polynomial whose values are given bysamples
, and derivatives set to zero.- Raises
RuntimeError if –
breaks
has length smaller than 3 and
zero_end_point_derivatives` is False, - breaks has lengt –
smaller than 2 and zero_end_point_derivatives is true. –
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
- static CubicWithContinuousSecondDerivatives(*args, **kwargs)
Overloaded function.
CubicWithContinuousSecondDerivatives(breaks: list[pydrake.symbolic.Expression], samples: list[list[pydrake.symbolic.Expression]], sample_dot_at_start: numpy.ndarray[object[m, n]], sample_dot_at_end: numpy.ndarray[object[m, n]]) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Version of CubicWithContinuousSecondDerivatives() that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
.
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
CubicWithContinuousSecondDerivatives(breaks: list[pydrake.symbolic.Expression], samples: list[numpy.ndarray[object[m, n]]], sample_dot_at_start: numpy.ndarray[object[m, n]], sample_dot_at_end: numpy.ndarray[object[m, n]]) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Constructs a third order PiecewisePolynomial using matrix samples. The PiecewisePolynomial is constructed such that the interior segments have the same value, first and second derivatives at
breaks
. sample_dot_at_start andsample_dot_at_end
are used for the first and last first derivatives.- Raises
RuntimeError if sample_dot_at_start or sample_dot_at_end –
and samples have inconsistent dimensions. –
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
CubicWithContinuousSecondDerivatives(breaks: list[pydrake.symbolic.Expression], samples: list[list[pydrake.symbolic.Expression]], periodic_end_condition: bool = False) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Version of CubicWithContinuousSecondDerivatives(breaks, samples) that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
.
CubicWithContinuousSecondDerivatives(breaks: list[pydrake.symbolic.Expression], samples: list[numpy.ndarray[object[m, n]]], periodic_end: bool) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Constructs a third order PiecewisePolynomial using matrix samples. The PiecewisePolynomial is constructed such that the interior segments have the same value, first and second derivatives at
breaks
. Ifperiodic_end_condition
isFalse
(default), then the “Not-a-sample” end condition is used here, which means the third derivatives are continuous for the first two and last two segments. Ifperiodic_end_condition
isTrue
, then the first and second derivatives between the end of the last segment and the beginning of the first segment will be continuous. Note that the periodic end condition does not require the first and last sample to be collocated, nor does it add an additional sample to connect the first and last segments. Only first and second derivative continuity is enforced. See https://en.wikipedia.org/wiki/Spline_interpolation and https://web.archive.org/web/20140125011904/https://www.math.uh.edu/~jingqiu/math4364/spline.pdf for more about cubic splines and their end conditions. The MATLAB docs for methods “spline” and “csape” are also good references.- Precondition:
breaks
andsamples
must have at least 3 elements. Ifperiodic_end_condition
isTrue
, then for two samples, it would produce a straight line (useFirstOrderHold
for this instead), and ifperiodic_end_condition
isFalse
the problem is ill-defined.
- derivative(self: pydrake.trajectories.PiecewisePolynomial_[Expression], derivative_order: int = 1) pydrake.trajectories.PiecewisePolynomial_[Expression]
Returns a PiecewisePolynomial where each segment is the specified derivative of the corresponding segment in
this
. Any rules or limitations of Polynomial::derivative() also apply to this function.Derivatives evaluated at non-differentiable points return the value at the left hand side of the interval.
- Parameter
derivative_order
: The order of the derivative, namely, if
derivative_order
= n, the n’th derivative of the polynomial will be returned.
Warning
In the event of discontinuous derivatives evaluated at breaks, it is not defined which polynomial (i.e., to the left or right of the break) will be the one that is evaluated at the break.
- Parameter
- static FirstOrderHold(*args, **kwargs)
Overloaded function.
FirstOrderHold(breaks: list[pydrake.symbolic.Expression], samples: list[list[pydrake.symbolic.Expression]]) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Version of FirstOrderHold(breaks, samples) that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
FirstOrderHold(breaks: list[pydrake.symbolic.Expression], samples: list[numpy.ndarray[object[m, n]]]) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Constructs a piecewise linear PiecewisePolynomial using matrix samples.
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
- getPolynomial(self: pydrake.trajectories.PiecewisePolynomial_[Expression], segment_index: int, row: int = 0, col: int = 0) pydrake.polynomial.Polynomial_[Expression]
Gets the Polynomial with the given matrix row and column index that corresponds to the given segment index. Equivalent to
getPolynomialMatrix(segment_index)(row, col)
.Note
Calls PiecewiseTrajectory<T>::segment_number_range_check() to validate
segment_index
.
- getPolynomialMatrix(self: pydrake.trajectories.PiecewisePolynomial_[Expression], segment_index: int) numpy.ndarray[object[m, n]]
Gets the matrix of Polynomials corresponding to the given segment index.
Warning
segment_index
is not checked for validity.
- getSegmentPolynomialDegree(self: pydrake.trajectories.PiecewisePolynomial_[Expression], segment_index: int, row: int = 0, col: int = 0) int
Gets the degree of the Polynomial with the given matrix row and column index that corresponds to the given segment index. Equivalent to
getPolynomial(segment_index, row, col).GetDegree()
.
- isApprox(self: pydrake.trajectories.PiecewisePolynomial_[Expression], other: pydrake.trajectories.PiecewisePolynomial_[Expression], tol: float, tol_type: pydrake.common.ToleranceType = <ToleranceType.kRelative: 1>) bool
Checks whether a PiecewisePolynomial is approximately equal to this one by calling Polynomial<T>::CoefficientsAlmostEqual() on every element of every segment.
See also
Polynomial<T>::CoefficientsAlmostEqual().
- static LagrangeInterpolatingPolynomial(*args, **kwargs)
Overloaded function.
LagrangeInterpolatingPolynomial(times: list[pydrake.symbolic.Expression], samples: list[list[pydrake.symbolic.Expression]]) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Version of LagrangeInterpolatingPolynomial(times, samples) that uses vector samples and Eigen VectorXd / MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == times.size()
.
LagrangeInterpolatingPolynomial(times: list[pydrake.symbolic.Expression], samples: list[numpy.ndarray[object[m, n]]]) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Constructs a polynomial with a single segment of the lowest possible degree that passes through all of the sample points. See “polynomial interpolation” and/or “Lagrange polynomial” on Wikipedia for more information.
- Precondition:
times
must be monotonically increasing.- Precondition:
samples.size() == times.size()
.
- RemoveFinalSegment(self: pydrake.trajectories.PiecewisePolynomial_[Expression]) None
Removes the final segment from the trajectory, reducing the number of segments by 1.
- Precondition:
this
is not empty()
- Reshape(self: pydrake.trajectories.PiecewisePolynomial_[Expression], rows: int, cols: int) None
Reshapes the dimensions of the Eigen::MatrixX<T> returned by value(), EvalDerivative(), etc.
- Precondition:
rows
xcols
must equal this.rows() * this.cols().
See also
Eigen::PlainObjectBase::resize().
- ReverseTime(self: pydrake.trajectories.PiecewisePolynomial_[Expression]) None
Modifies the trajectory so that pp_after(t) = pp_before(-t).
Note
The new trajectory will evaluate differently at precisely the break points if the original trajectory was discontinuous at the break points. This is because the segments are defined on the half-open intervals [breaks(i), breaks(i+1)), and the order of the breaks have been reversed.
- ScaleTime(self: pydrake.trajectories.PiecewisePolynomial_[Expression], scale: pydrake.symbolic.Expression) None
Scales the time of the trajectory by non-negative
scale
(use ReverseTime() if you want to also negate time). The resulting polynomial evaluates to pp_after(t) = pp_before(t/scale).As an example, `scale`=2 will result in a trajectory that is twice as long (start_time() and end_time() have both doubled).
- setPolynomialMatrixBlock(self: pydrake.trajectories.PiecewisePolynomial_[Expression], replacement: numpy.ndarray[object[m, n]], segment_index: int, row_start: int = 0, col_start: int = 0) None
Replaces the specified block of the PolynomialMatrix at the given segment index.
Note
Calls PiecewiseTrajectory<T>::segment_number_range_check() to validate
segment_index
.Warning
This code relies upon Eigen to verify that the replacement block is not too large.
- shiftRight(self: pydrake.trajectories.PiecewisePolynomial_[Expression], offset: pydrake.symbolic.Expression) None
Adds
offset
to all of the breaks.offset
need not be a non-negative number. The resulting polynomial will evaluate to pp_after(t) = pp_before(t-offset).As an example, `offset`=2 will result in the start_time() and end_time() being 2 seconds later.
- slice(self: pydrake.trajectories.PiecewisePolynomial_[Expression], start_segment_index: int, num_segments: int) pydrake.trajectories.PiecewisePolynomial_[Expression]
Returns the PiecewisePolynomial comprising the
num_segments
segments starting at the specifiedstart_segment_index
.Note
Calls PiecewiseTrajectory<T>::segment_number_range_check() to validate
segment_index
.
- Transpose(self: pydrake.trajectories.PiecewisePolynomial_[Expression]) pydrake.trajectories.PiecewisePolynomial_[Expression]
Constructs a new PiecewisePolynomial for which value(t) == this.value(t).transpose().
- static ZeroOrderHold(*args, **kwargs)
Overloaded function.
ZeroOrderHold(breaks: list[pydrake.symbolic.Expression], samples: list[list[pydrake.symbolic.Expression]]) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Version of ZeroOrderHold(breaks, samples) that uses vector samples and Eigen VectorXd/MatrixX<T> arguments. Each column of
samples
represents a sample point.- Precondition:
samples.cols() == breaks.size()
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
ZeroOrderHold(breaks: list[pydrake.symbolic.Expression], samples: list[numpy.ndarray[object[m, n]]]) -> pydrake.trajectories.PiecewisePolynomial_[Expression]
Constructs a piecewise constant PiecewisePolynomial using matrix samples. Note that constructing a PiecewisePolynomial requires at least two sample points, although in this case, the second sample point’s value is ignored, and only its break time is used.
- Raises
RuntimeError under the conditions specified under –
coefficient_construction_methods. –
- class pydrake.trajectories.PiecewisePose
Bases:
pydrake.trajectories.PiecewiseTrajectory
A wrapper class that represents a pose trajectory, whose rotation part is a PiecewiseQuaternionSlerp and the translation part is a PiecewisePolynomial.
Note
This class is templated; see
PiecewisePose_
for the list of instantiations.- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.PiecewisePose) -> None
Constructs an empty piecewise pose trajectory.
__init__(self: pydrake.trajectories.PiecewisePose, position_trajectory: pydrake.trajectories.PiecewisePolynomial, orientation_trajectory: pydrake.trajectories.PiecewiseQuaternionSlerp) -> None
Constructor.
- Parameter
pos_traj
: Position trajectory.
- Parameter
rot_traj
: Orientation trajectory.
- get_orientation_trajectory(self: pydrake.trajectories.PiecewisePose) pydrake.trajectories.PiecewiseQuaternionSlerp
Returns the orientation trajectory.
- get_position_trajectory(self: pydrake.trajectories.PiecewisePose) pydrake.trajectories.PiecewisePolynomial
Returns the position trajectory.
- GetAcceleration(self: pydrake.trajectories.PiecewisePose, time: float) numpy.ndarray[numpy.float64[6, 1]]
Returns the interpolated acceleration at
time
or zero iftime
is before this trajectory’s start time or after its end time.
- GetPose(self: pydrake.trajectories.PiecewisePose, time: float) pydrake.math.RigidTransform
Returns the interpolated pose at
time
.
- GetVelocity(self: pydrake.trajectories.PiecewisePose, time: float) numpy.ndarray[numpy.float64[6, 1]]
Returns the interpolated velocity at
time
or zero iftime
is before this trajectory’s start time or after its end time.
- IsApprox(self: pydrake.trajectories.PiecewisePose, other: pydrake.trajectories.PiecewisePose, tol: float) bool
Returns true if the position and orientation trajectories are both within
tol
from the other’s.
- static MakeCubicLinearWithEndLinearVelocity(times: list[float], poses: list[pydrake.math.RigidTransform], start_vel: numpy.ndarray[numpy.float64[3, 1]] = array([0., 0., 0.]), end_vel: numpy.ndarray[numpy.float64[3, 1]] = array([0., 0., 0.])) pydrake.trajectories.PiecewisePose
Constructs a PiecewisePose from given
times
andposes
. A cubic polynomial with given end velocities is used to construct the position part. The rotational part is represented by a piecewise quaterion trajectory. There must be at least two elements intimes
andposes
.- Parameter
times
: Breaks used to build the splines.
- Parameter
poses
: Knots used to build the splines.
- Parameter
start_vel
: Start linear velocity.
- Parameter
end_vel
: End linear velocity.
- Parameter
- static MakeLinear(times: list[float], poses: list[pydrake.math.RigidTransform]) pydrake.trajectories.PiecewisePose
Constructs a PiecewisePose from given
times
andposes
. The positions trajectory is constructed as a first-order hold. The orientation is constructed using the quaternion slerp. There must be at least two elements intimes
andposes
.- Parameter
times
: Breaks used to build the splines.
- Parameter
poses
: Knots used to build the splines.
- Parameter
- template pydrake.trajectories.PiecewisePose_
Instantiations:
PiecewisePose_[float]
,PiecewisePose_[AutoDiffXd]
,PiecewisePose_[Expression]
- class pydrake.trajectories.PiecewisePose_[AutoDiffXd]
Bases:
pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd]
A wrapper class that represents a pose trajectory, whose rotation part is a PiecewiseQuaternionSlerp and the translation part is a PiecewisePolynomial.
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.PiecewisePose_[AutoDiffXd]) -> None
Constructs an empty piecewise pose trajectory.
__init__(self: pydrake.trajectories.PiecewisePose_[AutoDiffXd], position_trajectory: pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd], orientation_trajectory: pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd]) -> None
Constructor.
- Parameter
pos_traj
: Position trajectory.
- Parameter
rot_traj
: Orientation trajectory.
- get_orientation_trajectory(self: pydrake.trajectories.PiecewisePose_[AutoDiffXd]) pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd]
Returns the orientation trajectory.
- get_position_trajectory(self: pydrake.trajectories.PiecewisePose_[AutoDiffXd]) pydrake.trajectories.PiecewisePolynomial_[AutoDiffXd]
Returns the position trajectory.
- GetAcceleration(self: pydrake.trajectories.PiecewisePose_[AutoDiffXd], time: pydrake.autodiffutils.AutoDiffXd) numpy.ndarray[object[6, 1]]
Returns the interpolated acceleration at
time
or zero iftime
is before this trajectory’s start time or after its end time.
- GetPose(self: pydrake.trajectories.PiecewisePose_[AutoDiffXd], time: pydrake.autodiffutils.AutoDiffXd) pydrake.math.RigidTransform_[AutoDiffXd]
Returns the interpolated pose at
time
.
- GetVelocity(self: pydrake.trajectories.PiecewisePose_[AutoDiffXd], time: pydrake.autodiffutils.AutoDiffXd) numpy.ndarray[object[6, 1]]
Returns the interpolated velocity at
time
or zero iftime
is before this trajectory’s start time or after its end time.
- IsApprox(self: pydrake.trajectories.PiecewisePose_[AutoDiffXd], other: pydrake.trajectories.PiecewisePose_[AutoDiffXd], tol: float) bool
Returns true if the position and orientation trajectories are both within
tol
from the other’s.
- static MakeCubicLinearWithEndLinearVelocity(times: list[pydrake.autodiffutils.AutoDiffXd], poses: list[pydrake.math.RigidTransform_[AutoDiffXd]], start_vel: numpy.ndarray[object[3, 1]] = array([<AutoDiffXd 0.0 nderiv=0>, <AutoDiffXd 0.0 nderiv=0>, <AutoDiffXd 0.0 nderiv=0>], dtype=object), end_vel: numpy.ndarray[object[3, 1]] = array([<AutoDiffXd 0.0 nderiv=0>, <AutoDiffXd 0.0 nderiv=0>, <AutoDiffXd 0.0 nderiv=0>], dtype=object)) pydrake.trajectories.PiecewisePose_[AutoDiffXd]
Constructs a PiecewisePose from given
times
andposes
. A cubic polynomial with given end velocities is used to construct the position part. The rotational part is represented by a piecewise quaterion trajectory. There must be at least two elements intimes
andposes
.- Parameter
times
: Breaks used to build the splines.
- Parameter
poses
: Knots used to build the splines.
- Parameter
start_vel
: Start linear velocity.
- Parameter
end_vel
: End linear velocity.
- Parameter
- static MakeLinear(times: list[pydrake.autodiffutils.AutoDiffXd], poses: list[pydrake.math.RigidTransform_[AutoDiffXd]]) pydrake.trajectories.PiecewisePose_[AutoDiffXd]
Constructs a PiecewisePose from given
times
andposes
. The positions trajectory is constructed as a first-order hold. The orientation is constructed using the quaternion slerp. There must be at least two elements intimes
andposes
.- Parameter
times
: Breaks used to build the splines.
- Parameter
poses
: Knots used to build the splines.
- Parameter
- class pydrake.trajectories.PiecewisePose_[Expression]
Bases:
pydrake.trajectories.PiecewiseTrajectory_[Expression]
A wrapper class that represents a pose trajectory, whose rotation part is a PiecewiseQuaternionSlerp and the translation part is a PiecewisePolynomial.
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.PiecewisePose_[Expression]) -> None
Constructs an empty piecewise pose trajectory.
__init__(self: pydrake.trajectories.PiecewisePose_[Expression], position_trajectory: pydrake.trajectories.PiecewisePolynomial_[Expression], orientation_trajectory: pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression]) -> None
Constructor.
- Parameter
pos_traj
: Position trajectory.
- Parameter
rot_traj
: Orientation trajectory.
- get_orientation_trajectory(self: pydrake.trajectories.PiecewisePose_[Expression]) pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression]
Returns the orientation trajectory.
- get_position_trajectory(self: pydrake.trajectories.PiecewisePose_[Expression]) pydrake.trajectories.PiecewisePolynomial_[Expression]
Returns the position trajectory.
- GetAcceleration(self: pydrake.trajectories.PiecewisePose_[Expression], time: pydrake.symbolic.Expression) numpy.ndarray[object[6, 1]]
Returns the interpolated acceleration at
time
or zero iftime
is before this trajectory’s start time or after its end time.
- GetPose(self: pydrake.trajectories.PiecewisePose_[Expression], time: pydrake.symbolic.Expression) pydrake.math.RigidTransform_[Expression]
Returns the interpolated pose at
time
.
- GetVelocity(self: pydrake.trajectories.PiecewisePose_[Expression], time: pydrake.symbolic.Expression) numpy.ndarray[object[6, 1]]
Returns the interpolated velocity at
time
or zero iftime
is before this trajectory’s start time or after its end time.
- IsApprox(self: pydrake.trajectories.PiecewisePose_[Expression], other: pydrake.trajectories.PiecewisePose_[Expression], tol: float) bool
Returns true if the position and orientation trajectories are both within
tol
from the other’s.
- static MakeCubicLinearWithEndLinearVelocity(times: list[pydrake.symbolic.Expression], poses: list[pydrake.math.RigidTransform_[Expression]], start_vel: numpy.ndarray[object[3, 1]] = array([<Expression "0">, <Expression "0">, <Expression "0">], dtype=object), end_vel: numpy.ndarray[object[3, 1]] = array([<Expression "0">, <Expression "0">, <Expression "0">], dtype=object)) pydrake.trajectories.PiecewisePose_[Expression]
Constructs a PiecewisePose from given
times
andposes
. A cubic polynomial with given end velocities is used to construct the position part. The rotational part is represented by a piecewise quaterion trajectory. There must be at least two elements intimes
andposes
.- Parameter
times
: Breaks used to build the splines.
- Parameter
poses
: Knots used to build the splines.
- Parameter
start_vel
: Start linear velocity.
- Parameter
end_vel
: End linear velocity.
- Parameter
- static MakeLinear(times: list[pydrake.symbolic.Expression], poses: list[pydrake.math.RigidTransform_[Expression]]) pydrake.trajectories.PiecewisePose_[Expression]
Constructs a PiecewisePose from given
times
andposes
. The positions trajectory is constructed as a first-order hold. The orientation is constructed using the quaternion slerp. There must be at least two elements intimes
andposes
.- Parameter
times
: Breaks used to build the splines.
- Parameter
poses
: Knots used to build the splines.
- Parameter
- class pydrake.trajectories.PiecewiseQuaternionSlerp
Bases:
pydrake.trajectories.PiecewiseTrajectory
A class representing a trajectory for quaternions that are interpolated using piecewise slerp (spherical linear interpolation). All the orientation samples are expected to be with respect to the same parent reference frame, i.e. q_i represents the rotation R_PBi for the orientation of frame B at the ith sample in a fixed parent frame P. The world frame is a common choice for the parent frame. The angular velocity and acceleration are also relative to the parent frame and expressed in the parent frame. Since there is a sign ambiguity when using quaternions to represent orientation, namely q and -q represent the same orientation, the internal quaternion representations ensure that q_n.dot(q_{n+1}) >= 0. Another intuitive way to think about this is that consecutive quaternions have the shortest geodesic distance on the unit sphere. Note that the quarternion value is in w, x, y, z order when represented as a Vector4.
Note
This class is templated; see
PiecewiseQuaternionSlerp_
for the list of instantiations.- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp) -> None
Builds an empty PiecewiseQuaternionSlerp.
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp, breaks: list[float], quaternions: list[pydrake.common.eigen_geometry.Quaternion]) -> None
Builds a PiecewiseQuaternionSlerp.
- Raises
RuntimeError if breaks and quaternions have different length, or –
breaks have length < 2. –
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp, breaks: list[float], rotation_matrices: list[numpy.ndarray[numpy.float64[3, 3]]]) -> None
Builds a PiecewiseQuaternionSlerp.
- Raises
RuntimeError if breaks and rot_matrices have different length, or –
breaks have length < 2. –
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp, breaks: list[float], rotation_matrices: list[pydrake.math.RotationMatrix]) -> None
Builds a PiecewiseQuaternionSlerp.
- Raises
RuntimeError if breaks and rot_matrices have different length, or –
breaks have length < 2. –
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp, breaks: list[float], angle_axes: list[pydrake.common.eigen_geometry.AngleAxis]) -> None
Builds a PiecewiseQuaternionSlerp.
- Raises
RuntimeError if breaks and ang_axes have different length, or –
breaks have length < 2. –
- angular_acceleration(self: pydrake.trajectories.PiecewiseQuaternionSlerp, time: float) numpy.ndarray[numpy.float64[3, 1]]
Interpolates angular acceleration.
- Parameter
time
: Time for interpolation.
- Returns
The interpolated angular acceleration at
time
, which is always zero for slerp.
- Parameter
- angular_velocity(self: pydrake.trajectories.PiecewiseQuaternionSlerp, time: float) numpy.ndarray[numpy.float64[3, 1]]
Interpolates angular velocity.
- Parameter
time
: Time for interpolation.
- Returns
The interpolated angular velocity at
time
, which is constant per segment.
- Parameter
- Append(*args, **kwargs)
Overloaded function.
Append(self: pydrake.trajectories.PiecewiseQuaternionSlerp, time: float, quaternion: pydrake.common.eigen_geometry.Quaternion) -> None
Given a new Quaternion, this method adds one segment to the end of
this
.Append(self: pydrake.trajectories.PiecewiseQuaternionSlerp, time: float, rotation_matrix: pydrake.math.RotationMatrix) -> None
Given a new RotationMatrix, this method adds one segment to the end of
this
.Append(self: pydrake.trajectories.PiecewiseQuaternionSlerp, time: float, angle_axis: pydrake.common.eigen_geometry.AngleAxis) -> None
Given a new AngleAxis, this method adds one segment to the end of
this
.
- orientation(self: pydrake.trajectories.PiecewiseQuaternionSlerp, time: float) pydrake.common.eigen_geometry.Quaternion
Interpolates orientation.
- Parameter
time
: Time for interpolation.
- Returns
The interpolated quaternion at
time
.
- Parameter
- template pydrake.trajectories.PiecewiseQuaternionSlerp_
Instantiations:
PiecewiseQuaternionSlerp_[float]
,PiecewiseQuaternionSlerp_[AutoDiffXd]
,PiecewiseQuaternionSlerp_[Expression]
- class pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd]
Bases:
pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd]
A class representing a trajectory for quaternions that are interpolated using piecewise slerp (spherical linear interpolation). All the orientation samples are expected to be with respect to the same parent reference frame, i.e. q_i represents the rotation R_PBi for the orientation of frame B at the ith sample in a fixed parent frame P. The world frame is a common choice for the parent frame. The angular velocity and acceleration are also relative to the parent frame and expressed in the parent frame. Since there is a sign ambiguity when using quaternions to represent orientation, namely q and -q represent the same orientation, the internal quaternion representations ensure that q_n.dot(q_{n+1}) >= 0. Another intuitive way to think about this is that consecutive quaternions have the shortest geodesic distance on the unit sphere. Note that the quarternion value is in w, x, y, z order when represented as a Vector4.
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd]) -> None
Builds an empty PiecewiseQuaternionSlerp.
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd], breaks: list[pydrake.autodiffutils.AutoDiffXd], quaternions: list[pydrake.common.eigen_geometry.Quaternion_[AutoDiffXd]]) -> None
Builds a PiecewiseQuaternionSlerp.
- Raises
RuntimeError if breaks and quaternions have different length, or –
breaks have length < 2. –
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd], breaks: list[pydrake.autodiffutils.AutoDiffXd], rotation_matrices: list[numpy.ndarray[object[3, 3]]]) -> None
Builds a PiecewiseQuaternionSlerp.
- Raises
RuntimeError if breaks and rot_matrices have different length, or –
breaks have length < 2. –
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd], breaks: list[pydrake.autodiffutils.AutoDiffXd], rotation_matrices: list[pydrake.math.RotationMatrix_[AutoDiffXd]]) -> None
Builds a PiecewiseQuaternionSlerp.
- Raises
RuntimeError if breaks and rot_matrices have different length, or –
breaks have length < 2. –
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd], breaks: list[pydrake.autodiffutils.AutoDiffXd], angle_axes: list[pydrake.common.eigen_geometry.AngleAxis_[AutoDiffXd]]) -> None
Builds a PiecewiseQuaternionSlerp.
- Raises
RuntimeError if breaks and ang_axes have different length, or –
breaks have length < 2. –
- angular_acceleration(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd], time: pydrake.autodiffutils.AutoDiffXd) numpy.ndarray[object[3, 1]]
Interpolates angular acceleration.
- Parameter
time
: Time for interpolation.
- Returns
The interpolated angular acceleration at
time
, which is always zero for slerp.
- Parameter
- angular_velocity(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd], time: pydrake.autodiffutils.AutoDiffXd) numpy.ndarray[object[3, 1]]
Interpolates angular velocity.
- Parameter
time
: Time for interpolation.
- Returns
The interpolated angular velocity at
time
, which is constant per segment.
- Parameter
- Append(*args, **kwargs)
Overloaded function.
Append(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd], time: pydrake.autodiffutils.AutoDiffXd, quaternion: pydrake.common.eigen_geometry.Quaternion_[AutoDiffXd]) -> None
Given a new Quaternion, this method adds one segment to the end of
this
.Append(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd], time: pydrake.autodiffutils.AutoDiffXd, rotation_matrix: pydrake.math.RotationMatrix_[AutoDiffXd]) -> None
Given a new RotationMatrix, this method adds one segment to the end of
this
.Append(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd], time: pydrake.autodiffutils.AutoDiffXd, angle_axis: pydrake.common.eigen_geometry.AngleAxis_[AutoDiffXd]) -> None
Given a new AngleAxis, this method adds one segment to the end of
this
.
- orientation(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[AutoDiffXd], time: pydrake.autodiffutils.AutoDiffXd) pydrake.common.eigen_geometry.Quaternion_[AutoDiffXd]
Interpolates orientation.
- Parameter
time
: Time for interpolation.
- Returns
The interpolated quaternion at
time
.
- Parameter
- class pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression]
Bases:
pydrake.trajectories.PiecewiseTrajectory_[Expression]
A class representing a trajectory for quaternions that are interpolated using piecewise slerp (spherical linear interpolation). All the orientation samples are expected to be with respect to the same parent reference frame, i.e. q_i represents the rotation R_PBi for the orientation of frame B at the ith sample in a fixed parent frame P. The world frame is a common choice for the parent frame. The angular velocity and acceleration are also relative to the parent frame and expressed in the parent frame. Since there is a sign ambiguity when using quaternions to represent orientation, namely q and -q represent the same orientation, the internal quaternion representations ensure that q_n.dot(q_{n+1}) >= 0. Another intuitive way to think about this is that consecutive quaternions have the shortest geodesic distance on the unit sphere. Note that the quarternion value is in w, x, y, z order when represented as a Vector4.
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression]) -> None
Builds an empty PiecewiseQuaternionSlerp.
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression], breaks: list[pydrake.symbolic.Expression], quaternions: list[pydrake.common.eigen_geometry.Quaternion_[Expression]]) -> None
Builds a PiecewiseQuaternionSlerp.
- Raises
RuntimeError if breaks and quaternions have different length, or –
breaks have length < 2. –
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression], breaks: list[pydrake.symbolic.Expression], rotation_matrices: list[numpy.ndarray[object[3, 3]]]) -> None
Builds a PiecewiseQuaternionSlerp.
- Raises
RuntimeError if breaks and rot_matrices have different length, or –
breaks have length < 2. –
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression], breaks: list[pydrake.symbolic.Expression], rotation_matrices: list[pydrake.math.RotationMatrix_[Expression]]) -> None
Builds a PiecewiseQuaternionSlerp.
- Raises
RuntimeError if breaks and rot_matrices have different length, or –
breaks have length < 2. –
__init__(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression], breaks: list[pydrake.symbolic.Expression], angle_axes: list[pydrake.common.eigen_geometry.AngleAxis_[Expression]]) -> None
Builds a PiecewiseQuaternionSlerp.
- Raises
RuntimeError if breaks and ang_axes have different length, or –
breaks have length < 2. –
- angular_acceleration(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression], time: pydrake.symbolic.Expression) numpy.ndarray[object[3, 1]]
Interpolates angular acceleration.
- Parameter
time
: Time for interpolation.
- Returns
The interpolated angular acceleration at
time
, which is always zero for slerp.
- Parameter
- angular_velocity(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression], time: pydrake.symbolic.Expression) numpy.ndarray[object[3, 1]]
Interpolates angular velocity.
- Parameter
time
: Time for interpolation.
- Returns
The interpolated angular velocity at
time
, which is constant per segment.
- Parameter
- Append(*args, **kwargs)
Overloaded function.
Append(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression], time: pydrake.symbolic.Expression, quaternion: pydrake.common.eigen_geometry.Quaternion_[Expression]) -> None
Given a new Quaternion, this method adds one segment to the end of
this
.Append(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression], time: pydrake.symbolic.Expression, rotation_matrix: pydrake.math.RotationMatrix_[Expression]) -> None
Given a new RotationMatrix, this method adds one segment to the end of
this
.Append(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression], time: pydrake.symbolic.Expression, angle_axis: pydrake.common.eigen_geometry.AngleAxis_[Expression]) -> None
Given a new AngleAxis, this method adds one segment to the end of
this
.
- orientation(self: pydrake.trajectories.PiecewiseQuaternionSlerp_[Expression], time: pydrake.symbolic.Expression) pydrake.common.eigen_geometry.Quaternion_[Expression]
Interpolates orientation.
- Parameter
time
: Time for interpolation.
- Returns
The interpolated quaternion at
time
.
- 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”.Note
This class is templated; see
PiecewiseTrajectory_
for the list of instantiations.- __init__(*args, **kwargs)
- duration(self: pydrake.trajectories.PiecewiseTrajectory, segment_index: int) float
- end_time(*args, **kwargs)
Overloaded function.
end_time(self: pydrake.trajectories.PiecewiseTrajectory, segment_index: 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, t: float) int
- get_segment_times(self: pydrake.trajectories.PiecewiseTrajectory) list[float]
- is_time_in_range(self: pydrake.trajectories.PiecewiseTrajectory, t: float) bool
Returns true iff
t >= getStartTime() && t <= getEndTime()
.
- start_time(*args, **kwargs)
Overloaded function.
start_time(self: pydrake.trajectories.PiecewiseTrajectory, segment_index: int) -> float
start_time(self: pydrake.trajectories.PiecewiseTrajectory) -> float
- template pydrake.trajectories.PiecewiseTrajectory_
Instantiations:
PiecewiseTrajectory_[float]
,PiecewiseTrajectory_[AutoDiffXd]
,PiecewiseTrajectory_[Expression]
- class pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd]
Bases:
pydrake.trajectories.Trajectory_[AutoDiffXd]
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”.- __init__(*args, **kwargs)
- duration(self: pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd], segment_index: int) pydrake.autodiffutils.AutoDiffXd
- end_time(*args, **kwargs)
Overloaded function.
end_time(self: pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd], segment_index: int) -> pydrake.autodiffutils.AutoDiffXd
end_time(self: pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd]) -> pydrake.autodiffutils.AutoDiffXd
- get_number_of_segments(self: pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd]) int
- get_segment_index(self: pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd], t: pydrake.autodiffutils.AutoDiffXd) int
- get_segment_times(self: pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd]) list[pydrake.autodiffutils.AutoDiffXd]
- is_time_in_range(self: pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd], t: pydrake.autodiffutils.AutoDiffXd) bool
Returns true iff
t >= getStartTime() && t <= getEndTime()
.
- start_time(*args, **kwargs)
Overloaded function.
start_time(self: pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd], segment_index: int) -> pydrake.autodiffutils.AutoDiffXd
start_time(self: pydrake.trajectories.PiecewiseTrajectory_[AutoDiffXd]) -> pydrake.autodiffutils.AutoDiffXd
- class pydrake.trajectories.PiecewiseTrajectory_[Expression]
Bases:
pydrake.trajectories.Trajectory_[Expression]
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”.- __init__(*args, **kwargs)
- duration(self: pydrake.trajectories.PiecewiseTrajectory_[Expression], segment_index: int) pydrake.symbolic.Expression
- end_time(*args, **kwargs)
Overloaded function.
end_time(self: pydrake.trajectories.PiecewiseTrajectory_[Expression], segment_index: int) -> pydrake.symbolic.Expression
end_time(self: pydrake.trajectories.PiecewiseTrajectory_[Expression]) -> pydrake.symbolic.Expression
- get_number_of_segments(self: pydrake.trajectories.PiecewiseTrajectory_[Expression]) int
- get_segment_index(self: pydrake.trajectories.PiecewiseTrajectory_[Expression], t: pydrake.symbolic.Expression) int
- get_segment_times(self: pydrake.trajectories.PiecewiseTrajectory_[Expression]) list[pydrake.symbolic.Expression]
- is_time_in_range(self: pydrake.trajectories.PiecewiseTrajectory_[Expression], t: pydrake.symbolic.Expression) pydrake.symbolic.Formula
Returns true iff
t >= getStartTime() && t <= getEndTime()
.
- start_time(*args, **kwargs)
Overloaded function.
start_time(self: pydrake.trajectories.PiecewiseTrajectory_[Expression], segment_index: int) -> pydrake.symbolic.Expression
start_time(self: pydrake.trajectories.PiecewiseTrajectory_[Expression]) -> pydrake.symbolic.Expression
- class pydrake.trajectories.StackedTrajectory
Bases:
pydrake.trajectories.Trajectory
A StackedTrajectory stacks the values from one or more underlying Trajectory objects into a single Trajectory, without changing the
%start_time()
or%end_time()
.For sequencing trajectories in time instead, see CompositeTrajectory.
All of the underlying Trajectory objects must have the same
%start_time()
and%end_time()
.When constructed with
rowwise
set to true, all of the underlying Trajectory objects must have the same number of%cols()
and thevalue()
matrix will be the vstack of the the trajectories in the order they were added.When constructed with
rowwise
set to false, all of the underlying Trajectory objects must have the same number of%rows()
and thevalue()
matrix will be the hstack of the the trajectories in the order they were added.Note
This class is templated; see
StackedTrajectory_
for the list of instantiations.- __init__(self: pydrake.trajectories.StackedTrajectory, rowwise: bool = True) None
Creates an empty trajectory.
- Parameter
rowwise
: governs the stacking order
- Parameter
- Append(self: pydrake.trajectories.StackedTrajectory, arg0: pydrake.trajectories.Trajectory) None
Stacks another sub-Trajectory onto this. Refer to the class overview documentation for details.
- Raises
RuntimeError if the matrix dimension is incompatible. –
- template pydrake.trajectories.StackedTrajectory_
Instantiations:
StackedTrajectory_[float]
,StackedTrajectory_[AutoDiffXd]
,StackedTrajectory_[Expression]
- class pydrake.trajectories.StackedTrajectory_[AutoDiffXd]
Bases:
pydrake.trajectories.Trajectory_[AutoDiffXd]
A StackedTrajectory stacks the values from one or more underlying Trajectory objects into a single Trajectory, without changing the
%start_time()
or%end_time()
.For sequencing trajectories in time instead, see CompositeTrajectory.
All of the underlying Trajectory objects must have the same
%start_time()
and%end_time()
.When constructed with
rowwise
set to true, all of the underlying Trajectory objects must have the same number of%cols()
and thevalue()
matrix will be the vstack of the the trajectories in the order they were added.When constructed with
rowwise
set to false, all of the underlying Trajectory objects must have the same number of%rows()
and thevalue()
matrix will be the hstack of the the trajectories in the order they were added.- __init__(self: pydrake.trajectories.StackedTrajectory_[AutoDiffXd], rowwise: bool = True) None
Creates an empty trajectory.
- Parameter
rowwise
: governs the stacking order
- Parameter
- Append(self: pydrake.trajectories.StackedTrajectory_[AutoDiffXd], arg0: pydrake.trajectories.Trajectory_[AutoDiffXd]) None
Stacks another sub-Trajectory onto this. Refer to the class overview documentation for details.
- Raises
RuntimeError if the matrix dimension is incompatible. –
- Clone(self: pydrake.trajectories.StackedTrajectory_[AutoDiffXd]) pydrake.trajectories.Trajectory_[AutoDiffXd]
- class pydrake.trajectories.StackedTrajectory_[Expression]
Bases:
pydrake.trajectories.Trajectory_[Expression]
A StackedTrajectory stacks the values from one or more underlying Trajectory objects into a single Trajectory, without changing the
%start_time()
or%end_time()
.For sequencing trajectories in time instead, see CompositeTrajectory.
All of the underlying Trajectory objects must have the same
%start_time()
and%end_time()
.When constructed with
rowwise
set to true, all of the underlying Trajectory objects must have the same number of%cols()
and thevalue()
matrix will be the vstack of the the trajectories in the order they were added.When constructed with
rowwise
set to false, all of the underlying Trajectory objects must have the same number of%rows()
and thevalue()
matrix will be the hstack of the the trajectories in the order they were added.- __init__(self: pydrake.trajectories.StackedTrajectory_[Expression], rowwise: bool = True) None
Creates an empty trajectory.
- Parameter
rowwise
: governs the stacking order
- Parameter
- Append(self: pydrake.trajectories.StackedTrajectory_[Expression], arg0: pydrake.trajectories.Trajectory_[Expression]) None
Stacks another sub-Trajectory onto this. Refer to the class overview documentation for details.
- Raises
RuntimeError if the matrix dimension is incompatible. –
- Clone(self: pydrake.trajectories.StackedTrajectory_[Expression]) pydrake.trajectories.Trajectory_[Expression]
- class pydrake.trajectories.Trajectory
A Trajectory represents a time-varying matrix, indexed by a single scalar time.
Note
This class is templated; see
Trajectory_
for the list of instantiations.- __init__(self: pydrake.trajectories.Trajectory) None
- cols(self: pydrake.trajectories.Trajectory) int
- Returns
The number of columns in the matrix returned by value().
- end_time(self: pydrake.trajectories.Trajectory) float
- EvalDerivative(self: pydrake.trajectories.Trajectory, t: float, derivative_order: int = 1) numpy.ndarray[numpy.float64[m, n]]
Evaluates the derivative of
this
at the given timet
. Returns the nth derivative, wheren
is the value ofderivative_order
.- Raises
RuntimeError if derivative_order is negative. –
- has_derivative(self: pydrake.trajectories.Trajectory) bool
Returns true iff the Trajectory provides and implementation for EvalDerivative() and MakeDerivative(). The derivative need not be continuous, but should return a result for all t for which value(t) returns a result.
- MakeDerivative(self: pydrake.trajectories.Trajectory, derivative_order: int = 1) pydrake.trajectories.Trajectory
Takes the derivative of this Trajectory.
- Parameter
derivative_order
: The number of times to take the derivative before returning.
- Returns
The nth derivative of this object.
- Raises
RuntimeError if derivative_order is negative. –
- Parameter
- rows(self: pydrake.trajectories.Trajectory) int
- Returns
The number of rows in the matrix returned by value().
- start_time(self: pydrake.trajectories.Trajectory) float
- value(self: pydrake.trajectories.Trajectory, t: float) numpy.ndarray[numpy.float64[m, n]]
Evaluates the trajectory at the given time
t
.- Parameter
t
: The time at which to evaluate the trajectory.
- Returns
The matrix of evaluated values.
- Parameter
- vector_values(self: pydrake.trajectories.Trajectory, t: list[float]) numpy.ndarray[numpy.float64[m, n]]
If cols()==1, then evaluates the trajectory at each time
t
, and returns the results as a Matrix with the ith column corresponding to the ith time. Otherwise, if rows()==1, then evaluates the trajectory at each timet
, and returns the results as a Matrix with the ith row corresponding to the ith time.- Raises
RuntimeError if both cols and rows are not equal to 1. –
- template pydrake.trajectories.Trajectory_
Instantiations:
Trajectory_[float]
,Trajectory_[AutoDiffXd]
,Trajectory_[Expression]
- class pydrake.trajectories.Trajectory_[AutoDiffXd]
A Trajectory represents a time-varying matrix, indexed by a single scalar time.
- __init__(self: pydrake.trajectories.Trajectory_[AutoDiffXd]) None
- cols(self: pydrake.trajectories.Trajectory_[AutoDiffXd]) int
- Returns
The number of columns in the matrix returned by value().
- end_time(self: pydrake.trajectories.Trajectory_[AutoDiffXd]) pydrake.autodiffutils.AutoDiffXd
- EvalDerivative(self: pydrake.trajectories.Trajectory_[AutoDiffXd], t: pydrake.autodiffutils.AutoDiffXd, derivative_order: int = 1) numpy.ndarray[object[m, n]]
Evaluates the derivative of
this
at the given timet
. Returns the nth derivative, wheren
is the value ofderivative_order
.- Raises
RuntimeError if derivative_order is negative. –
- has_derivative(self: pydrake.trajectories.Trajectory_[AutoDiffXd]) bool
Returns true iff the Trajectory provides and implementation for EvalDerivative() and MakeDerivative(). The derivative need not be continuous, but should return a result for all t for which value(t) returns a result.
- MakeDerivative(self: pydrake.trajectories.Trajectory_[AutoDiffXd], derivative_order: int = 1) pydrake.trajectories.Trajectory_[AutoDiffXd]
Takes the derivative of this Trajectory.
- Parameter
derivative_order
: The number of times to take the derivative before returning.
- Returns
The nth derivative of this object.
- Raises
RuntimeError if derivative_order is negative. –
- Parameter
- rows(self: pydrake.trajectories.Trajectory_[AutoDiffXd]) int
- Returns
The number of rows in the matrix returned by value().
- start_time(self: pydrake.trajectories.Trajectory_[AutoDiffXd]) pydrake.autodiffutils.AutoDiffXd
- value(self: pydrake.trajectories.Trajectory_[AutoDiffXd], t: pydrake.autodiffutils.AutoDiffXd) numpy.ndarray[object[m, n]]
Evaluates the trajectory at the given time
t
.- Parameter
t
: The time at which to evaluate the trajectory.
- Returns
The matrix of evaluated values.
- Parameter
- vector_values(self: pydrake.trajectories.Trajectory_[AutoDiffXd], t: list[pydrake.autodiffutils.AutoDiffXd]) numpy.ndarray[object[m, n]]
If cols()==1, then evaluates the trajectory at each time
t
, and returns the results as a Matrix with the ith column corresponding to the ith time. Otherwise, if rows()==1, then evaluates the trajectory at each timet
, and returns the results as a Matrix with the ith row corresponding to the ith time.- Raises
RuntimeError if both cols and rows are not equal to 1. –
- class pydrake.trajectories.Trajectory_[Expression]
A Trajectory represents a time-varying matrix, indexed by a single scalar time.
- __init__(self: pydrake.trajectories.Trajectory_[Expression]) None
- cols(self: pydrake.trajectories.Trajectory_[Expression]) int
- Returns
The number of columns in the matrix returned by value().
- end_time(self: pydrake.trajectories.Trajectory_[Expression]) pydrake.symbolic.Expression
- EvalDerivative(self: pydrake.trajectories.Trajectory_[Expression], t: pydrake.symbolic.Expression, derivative_order: int = 1) numpy.ndarray[object[m, n]]
Evaluates the derivative of
this
at the given timet
. Returns the nth derivative, wheren
is the value ofderivative_order
.- Raises
RuntimeError if derivative_order is negative. –
- has_derivative(self: pydrake.trajectories.Trajectory_[Expression]) bool
Returns true iff the Trajectory provides and implementation for EvalDerivative() and MakeDerivative(). The derivative need not be continuous, but should return a result for all t for which value(t) returns a result.
- MakeDerivative(self: pydrake.trajectories.Trajectory_[Expression], derivative_order: int = 1) pydrake.trajectories.Trajectory_[Expression]
Takes the derivative of this Trajectory.
- Parameter
derivative_order
: The number of times to take the derivative before returning.
- Returns
The nth derivative of this object.
- Raises
RuntimeError if derivative_order is negative. –
- Parameter
- rows(self: pydrake.trajectories.Trajectory_[Expression]) int
- Returns
The number of rows in the matrix returned by value().
- start_time(self: pydrake.trajectories.Trajectory_[Expression]) pydrake.symbolic.Expression
- value(self: pydrake.trajectories.Trajectory_[Expression], t: pydrake.symbolic.Expression) numpy.ndarray[object[m, n]]
Evaluates the trajectory at the given time
t
.- Parameter
t
: The time at which to evaluate the trajectory.
- Returns
The matrix of evaluated values.
- Parameter
- vector_values(self: pydrake.trajectories.Trajectory_[Expression], t: list[pydrake.symbolic.Expression]) numpy.ndarray[object[m, n]]
If cols()==1, then evaluates the trajectory at each time
t
, and returns the results as a Matrix with the ith column corresponding to the ith time. Otherwise, if rows()==1, then evaluates the trajectory at each timet
, and returns the results as a Matrix with the ith row corresponding to the ith time.- Raises
RuntimeError if both cols and rows are not equal to 1. –