pydrake.math¶
Bindings for //math.

class
pydrake.math.
BarycentricMesh
¶ Represents a multilinear function (from vector inputs to vector outputs) by interpolating between points on a mesh using (triangular) barycentric interpolation.
For a technical description of barycentric interpolation, see e.g. Remi Munos and Andrew Moore, “Barycentric Interpolators for Continuous Space and Time Reinforcement Learning”, NIPS 1998
 Template parameter
T
:  The vector element type, which must be a valid Eigen scalar.
Instantiated templates for the following kinds of T’s are provided:
 double

Eval
(self: pydrake.math.BarycentricMesh, arg0: numpy.ndarray[float64[m, n], flags.f_contiguous], arg1: numpy.ndarray[float64[m, 1]]) → numpy.ndarray[float64[m, 1]]¶ Returns the function evaluated at
input
.

EvalBarycentricWeights
(self: pydrake.math.BarycentricMesh, arg0: numpy.ndarray[float64[m, 1]]) → Tuple[numpy.ndarray[int32[m, 1]], numpy.ndarray[float64[m, 1]]]¶ Writes the mesh indices used for interpolation to
mesh_indices
, and the interpolating coefficients toweights
. Inputs that are outside the bounding box of the input_grid are interpolated as though they were projected (elementwise) to the closest face of the defined mesh. Parameter
input
:  must be a vector of length get_num_inputs().
 Parameter
mesh_indices
:  is a pointer to a vector of length get_num_interpolants().
 Parameter
weights
:  is a vector of coefficients (which sum to 1) of length get_num_interpolants().
 Parameter

MeshValuesFrom
(self: pydrake.math.BarycentricMesh, arg0: Callable[[numpy.ndarray[float64[m, 1]]], numpy.ndarray[float64[m, 1]]]) → numpy.ndarray[float64[m, n]]¶ Evaluates
vector_func
at all input mesh points and extracts the mesh value matrix that should be used to approximate the function with this barycentric interpolation.MatrixXd mesh_values = bary.MeshValuesFrom( [](const auto& x) { return Vector1d(std::sin(x[0])); });

__init__
(self: pydrake.math.BarycentricMesh, arg0: List[Set[float]]) → None¶ Constructs the mesh.

get_all_mesh_points
(self: pydrake.math.BarycentricMesh) → numpy.ndarray[float64[m, n]]¶ Returns a matrix with all of the mesh points, one per column.

get_input_grid
(self: pydrake.math.BarycentricMesh) → List[Set[float]]¶

get_input_size
(self: pydrake.math.BarycentricMesh) → int¶

get_mesh_point
(self: pydrake.math.BarycentricMesh, arg0: int) → numpy.ndarray[float64[m, 1]]¶ Returns the position of a mesh point in the input space referenced by its scalar index to
point
. Parameter
index
:  must be in [0, get_num_mesh_points).
 Parameter

get_num_interpolants
(self: pydrake.math.BarycentricMesh) → int¶

get_num_mesh_points
(self: pydrake.math.BarycentricMesh) → int¶
 Template parameter

pydrake.math.
ComputeBasisFromAxis
(axis_index: int, axis_W: numpy.ndarray[float64[3, 1]]) → numpy.ndarray[float64[3, 3]]¶ Creates a righthanded local basis from a given axis. Defines two other arbitrary axes such that the basis is orthonormal. The basis is R_WL, where W is the frame in which the input axis is expressed and L is a local basis such that v_W = R_WL * v_L.
 Parameter
axis_index
:  The index of the axis (in the range [0,2]), with 0 corresponding to the xaxis, 1 corresponding to the yaxis, and zcorresponding to the zaxis.
 Parameter
axis_W
:  The vector defining the basis’s given axis expressed in frame W. The vector need not be a unit vector: this routine will normalize it.
 Returns
R_WL
:  The computed basis.
Raises:  RuntimeError if the norm of
axis_W
is within 1e10 to zero or axis_index
does not lie in the range [0,2].
 Parameter

pydrake.math.
ContinuousAlgebraicRiccatiEquation
(A: numpy.ndarray[float64[m, n], flags.f_contiguous], B: numpy.ndarray[float64[m, n], flags.f_contiguous], Q: numpy.ndarray[float64[m, n], flags.f_contiguous], R: numpy.ndarray[float64[m, n], flags.f_contiguous]) → numpy.ndarray[float64[m, n]]¶ Computes the unique stabilizing solution S to the continuoustime algebraic Riccati equation:
S A + A' S  S B inv(R) B' S + Q = 0
Raises: RuntimeError if R is not positive definite. Based on the Matrix Sign Function method outlined in this paper: http://www.engr.iupui.edu/~skoskie/ECE684/Riccati_algorithms.pdf

pydrake.math.
DecomposePSDmatrixIntoXtransposeTimesX
(Y: numpy.ndarray[float64[m, n], flags.f_contiguous], zero_tol: float) → numpy.ndarray[float64[m, n]]¶ For a symmetric positive semidefinite matrix Y, decompose it into XᵀX, where the number of rows in X equals to the rank of Y. Notice that this decomposition is not unique. For any orthonormal matrix U, s.t UᵀU = identity, X_prime = UX also satisfies X_primeᵀX_prime = Y. Here we only return one valid decomposition.
 Parameter
Y
:  A symmetric positive semidefinite matrix.
 Parameter
zero_tol
:  We will need to check if some value (for example, the absolute value of Y’s eigenvalues) is smaller than zero_tol. If it is, then we deem that value as 0.
 Returns
X
:  . The matrix X satisfies XᵀX = Y and X.rows() = rank(Y).
Precondition: 1. Y is positive semidefinite.
 zero_tol is nonnegative.
$Raises:
RuntimeError when the preconditions are not satisfied.
 Parameter

pydrake.math.
DecomposePositiveQuadraticForm
(Q: numpy.ndarray[float64[m, n], flags.f_contiguous], b: numpy.ndarray[float64[m, 1]], c: float, tol: float = 0) → Tuple[numpy.ndarray[float64[m, n]], numpy.ndarray[float64[m, n]]]¶ Rewrite a quadratic form xᵀQx + bᵀx + c to (Rx+d)ᵀ(Rx+d) where RᵀR = Q Rᵀd = b / 2 Notice that this decomposition is not unique. For example, with any permutation matrix P, we can define R₁ = P*R d₁ = P*d Then (R₁*x+d₁)ᵀ(R₁*x+d₁) gives the same quadratic form.
 Parameter
Q
:  The square matrix.
 Parameter
b
:  The vector containing the linear coefficients.
 Parameter
c
:  The constatnt term.
 Parameter
tol
:  We will determine if this quadratic form is always nonnegative, by checking the Eigen values of the matrix [Q b/2] [bᵀ/2 c] are all greater than tol. $*Default:* is 0.
 Returns
(R
:  , d). R and d have the same number of rows. R.cols() == x.rows(). The matrix X = [R d] has the same number of rows as the rank of
[Q b/2] [bᵀ/2 c]
Precondition: 1. The quadratic form is always nonnegative, namely the matrix
[Q b/2] [bᵀ/2 c]
is positive semidefinite. 2.
Q
andb
are of the correct size. 3.tol
is nonnegative.Raises: RuntimeError if the precondition is not satisfied.  Parameter

pydrake.math.
DiscreteAlgebraicRiccatiEquation
(A: numpy.ndarray[float64[m, n], flags.f_contiguous], B: numpy.ndarray[float64[m, n], flags.f_contiguous], Q: numpy.ndarray[float64[m, n], flags.f_contiguous], R: numpy.ndarray[float64[m, n], flags.f_contiguous]) → numpy.ndarray[float64[m, n]]¶ Computes the unique stabilizing solution X to the discretetime algebraic Riccati equation:
\[A'XA  X  A'XB(B'XB+R)^{1}B'XA + Q = 0\]Raises: RuntimeError if Q is not positive semidefinite. Raises: RuntimeError if R is not positive definite. Based on the Schur Vector approach outlined in this paper: “On the Numerical Solution of the DiscreteTime Algebraic Riccati Equation” by Thrasyvoulos Pappas, Alan J. Laub, and Nils R. Sandell

pydrake.math.
RealContinuousLyapunovEquation
(A: numpy.ndarray[float64[m, n], flags.f_contiguous], Q: numpy.ndarray[float64[m, n], flags.f_contiguous]) → numpy.ndarray[float64[m, n]]¶  Parameter
A
:  A user defined real square matrix.
 Parameter
Q
:  A user defined real symmetric matrix.
 Precondition:
 Q is a symmetric matrix.
Computes a unique solution X to the continuous Lyapunov equation:
AᵀX + XA + Q = 0
, where A is real and square, and Q is real, symmetric and of equal size as A.Raises:  RuntimeError if A or Q are not square matrices or do not have the
 same size.
Limitations: Given the Eigenvalues of A as λ₁, …, λₙ, there exists a unique solution if and only if λᵢ + λ̅ⱼ ≠ 0 ∀ i,j, where λ̅ⱼ is the complex conjugate of λⱼ.
Raises: RuntimeError if the solution is not unique. There are no further limitations on the eigenvalues of A. Further, if all λᵢ have negative real parts, and if Q is positive semidefinite, then X is also positive semidefinite [1]. Therefore, if one searches for a Lyapunov function V(z) = zᵀXz for the stable linear system ż = Az, then the solution of the Lyapunov Equation
AᵀX + XA + Q = 0
only returns a valid Lyapunov function if Q is positive semidefinite.The implementation is based on SLICOT routine SB03MD [2]. Note the transformation Q = C. The complexity of this routine is O(n³). If A is larger than 2by2, then a Schur factorization is performed.
Raises: RuntimeError if Schur factorization failed. A tolerance of ε is used to check if a double variable is equal to zero, where the default value for ε is 1e10. It has been used to check (1) if λᵢ + λ̅ⱼ = 0, ∀ i,j; (2) if A is a 1by1 zero matrix; (3) if A’s trace or determinant is 0 when A is a 2by2 matrix.
[1] Bartels, R.H. and G.W. Stewart, “Solution of the Matrix Equation AX + XB = C,” Comm. of the ACM, Vol. 15, No. 9, 1972.
[2] http://slicot.org/objects/software/shared/doc/SB03MD.html
 Parameter

pydrake.math.
RealDiscreteLyapunovEquation
(A: numpy.ndarray[float64[m, n], flags.f_contiguous], Q: numpy.ndarray[float64[m, n], flags.f_contiguous]) → numpy.ndarray[float64[m, n]]¶  Parameter
A
:  A user defined real square matrix.
 Parameter
Q
:  A user defined real symmetric matrix.
 Precondition:
 Q is a symmetric matrix.
Computes the unique solution X to the discrete Lyapunov equation:
AᵀXA  X + Q = 0
, where A is real and square, and Q is real, symmetric and of equal size as A.Raises:  RuntimeError if A or Q are not square matrices or do not have the
 same size.
Limitations: Given the Eigenvalues of A as λ₁, …, λₙ, there exists a unique solution if and only if λᵢ * λⱼ ≠ 1 ∀ i,j and λᵢ ≠ ±1, ∀ i [1].
Raises: RuntimeError if the solution is not unique.[3] There are no further limitations on the eigenvalues of A. Further, if λᵢ<1, ∀ i, and if Q is positive semidefinite, then X is also positive semidefinite [2]. Therefore, if one searches for a Lyapunov function V(z) = zᵀXz for the stable linear system zₙ₊₁ = Azₙ, then the solution of the Lyapunov Equation
AᵀXA  X + Q = 0
only returns a valid Lyapunov function if Q is positive semidefinite.The implementation is based on SLICOT routine SB03MD [2]. Note the transformation Q = C. The complexity of this routine is O(n³). If A is larger than 2by2, then a Schur factorization is performed.
Raises: RuntimeError if Schur factorization fails. A tolerance of ε is used to check if a double variable is equal to zero, where the default value for ε is 1e10. It has been used to check (1) if λᵢ = ±1 ∀ i; (2) if λᵢ * λⱼ = 1, i ≠ j.
[1] Barraud, A.Y., “A numerical algorithm to solve AᵀXA  X = Q,” IEEE® Trans. Auto. Contr., AC22, pp. 883885, 1977.
[2] http://slicot.org/objects/software/shared/doc/SB03MD.html
 Parameter

class
pydrake.math.
RigidTransform
¶ This class represents a proper rigid transform between two frames which can be regarded in two ways. It can be regarded as a distancepreserving linear operator that can rotate and/or translate a rigid body without changing its shape or size (rigid) and without mirroring/reflecting the body (proper), e.g., it can add one position vector to another and express the result in a particular basis as
p_AoQ_A = X_AB * p_BoQ_B
(Q is any point). Alternately, a rigid transform describes the pose between two frames A and B (i.e., the relative orientation and position of A to B). Herein, the terms rotation/orientation and translation/position are used interchangeably. The class stores a RotationMatrix that relates righthanded orthogonal unit vectors Ax, Ay, Az fixed in frame A to righthanded orthogonal unit vectors Bx, By, Bz fixed in frame B. The class also stores a position vector from Ao (the origin of frame A) to Bo (the origin of frame B). The position vector is expressed in frame A. The monogram notation for the transform relating frame A to B isX_AB
. The monogram notation for the rotation matrix relating A to B isR_AB
. The monogram notation for the position vector from Ao to Bo isp_AoBo_A
. See multibody_quantities for monogram notation for dynamics.Note
This class does not store the frames associated with the transform and cannot enforce correct usage of this class. For example, it makes sense to multiply RigidTransforms as
X_AB * X_BC
, but notX_AB * X_CB
.Note
This class is not a 4x4 transformation matrix – even though its operator*() methods act like 4x4 matrix multiplication. Instead, this class contains a rotation matrix class as well as a 3x1 position vector. To form a 4x4 matrix, use GetAsMatrix(). GetAsIsometry() is treated similarly.
Note
An isometry is sometimes regarded as synonymous with rigid transform. The RigidTransform class has important advantages over Eigen::Isometry.  RigidTransform is built on an underlying rigorous 3x3 RotationMatrix class that has significant functionality for 3D orientation.  In Debug builds, RigidTransform requires a valid 3x3 rotation matrix and a valid (nonNAN) position vector. Eigen::Isometry does not.  RigidTransform catches bugs that are undetected by Eigen::Isometry.  RigidTransform has additional functionality and easeofuse, resulting in shorter, easier to write, and easier to read code.  The name Isometry is unfamiliar to many roboticists and dynamicists and for them Isometry.linear() is (for example) a counterintuitive method name to return a rotation matrix.
Note
One of the constructors in this class provides an implicit conversion from an Eigen Translation to RigidTransform.
 Authors:
 Paul Mitiguy (2018) Original author.
 Authors:
 Drake team (see https://drake.mit.edu/credits).
 Template parameter
T
:  The underlying scalar type. Must be a valid Eigen scalar.

GetAsIsometry3
(self: pydrake.math.RigidTransform) → pydrake.common.eigen_geometry.Isometry3¶ Returns the isometry in ℜ³ that is equivalent to a RigidTransform.

GetAsMatrix34
(self: pydrake.math.RigidTransform) → numpy.ndarray[float64[3, 4]]¶ Returns the 3x4 matrix associated with this RigidTransform, i.e., X_AB.
┌ ┐ │ R_AB p_AoBo_A │ └ ┘

GetAsMatrix4
(self: pydrake.math.RigidTransform) → numpy.ndarray[float64[4, 4]]¶ Returns the 4x4 matrix associated with this RigidTransform, i.e., X_AB.
┌ ┐ │ R_AB p_AoBo_A │ │ │ │ 0 1 │ └ ┘

Identity
() → pydrake.math.RigidTransform¶ Returns the identity RigidTransform (corresponds to coincident frames).
Returns: the RigidTransform that corresponds to aligning the two frames so unit vectors Ax = Bx, Ay = By, Az = Bz and point Ao is coincident with Bo. Hence, the returned RigidTransform contains a 3x3 identity matrix and a zero position vector.

SetFromIsometry3
(self: pydrake.math.RigidTransform, pose: pydrake.common.eigen_geometry.Isometry3) → None¶ Sets
this
RigidTransform from an Eigen Isometry3. Parameter
pose
:  Isometry3 that contains an allegedly valid rotation matrix
R_AB
and also contains a position vectorp_AoBo_A
from frame A’s origin to frame B’s origin.p_AoBo_A
must be expressed in frame A.
Raises:  RuntimeError in debug builds if R_AB is not a proper orthonormal
 3x3 rotation matrix.
Note
No attempt is made to orthogonalize the 3x3 rotation matrix part of
pose
. As needed, use RotationMatrix::ProjectToRotationMatrix(). Parameter

SetIdentity
(self: pydrake.math.RigidTransform) → pydrake.math.RigidTransform¶ Sets
this
RigidTransform so it corresponds to aligning the two frames so unit vectors Ax = Bx, Ay = By, Az = Bz and point Ao is coincident with Bo. Hence,this
RigidTransform contains a 3x3 identity matrix and a zero position vector.

__init__
(*args, **kwargs)¶ Overloaded function.
 __init__(self: pydrake.math.RigidTransform) > None
Constructs the RigidTransform that corresponds to aligning the two frames so unit vectors Ax = Bx, Ay = By, Az = Bz and point Ao is coincident with Bo. Hence, the constructed RigidTransform contains an identity RotationMatrix and a zero position vector.
 __init__(self: pydrake.math.RigidTransform, other: pydrake.math.RigidTransform) > None
 __init__(self: pydrake.math.RigidTransform, R: drake::math::RotationMatrix<double>, p: numpy.ndarray[float64[3, 1]]) > None
Constructs a RigidTransform from a rotation matrix and a position vector.
 Parameter
R
:  rotation matrix relating frames A and B (e.g.,
R_AB
).  Parameter
p
:  position vector from frame A’s origin to frame B’s origin,
expressed in frame A. In monogram notation p is denoted
p_AoBo_A
.
 __init__(self: pydrake.math.RigidTransform, rpy: drake::math::RollPitchYaw<double>, p: numpy.ndarray[float64[3, 1]]) > None
Constructs a RigidTransform from a RollPitchYaw and a position vector.
 Parameter
rpy
:  a RollPitchYaw which is a Spacefixed (extrinsic) XYZ rotation
with “rollpitchyaw” angles
[r, p, y]
or equivalently a Body fixed (intrinsic) ZYX rotation with “yawpitchroll” angles[y, p, r]
.
See also
RotationMatrix::RotationMatrix(const RollPitchYaw<T>&)
 Parameter
p
:  position vector from frame A’s origin to frame B’s origin,
expressed in frame A. In monogram notation p is denoted
p_AoBo_A
.
 __init__(self: pydrake.math.RigidTransform, quaternion: pydrake.common.eigen_geometry.Quaternion, p: numpy.ndarray[float64[3, 1]]) > None
Constructs a RigidTransform from a Quaternion and a position vector.
 Parameter
quaternion
:  a nonzero, finite quaternion which may or may not have unit
length [i.e.,
quaternion.norm()
does not have to be 1].  Parameter
p
:  position vector from frame A’s origin to frame B’s origin,
expressed in frame A. In monogram notation p is denoted
p_AoBo_A
.
Raises:  RuntimeError in debug builds if the rotation matrix that is built
 from
quaternion
is invalid.
See also
RotationMatrix::RotationMatrix(const Eigen::Quaternion<T>&)
 __init__(self: pydrake.math.RigidTransform, theta_lambda: pydrake.common.eigen_geometry.AngleAxis, p: numpy.ndarray[float64[3, 1]]) > None
Constructs a RigidTransform from a AngleAxis and a position vector.
 Parameter
theta_lambda
:  an Eigen::AngleAxis whose associated axis (vector direction herein
called
lambda
) is nonzero and finite, but which may or may not have unit length [i.e.,lambda.norm()
does not have to be 1].  Parameter
p
:  position vector from frame A’s origin to frame B’s origin, expressed in frame A. In monogram notation p is denoted ``p_AoBo_A
Raises:  RuntimeError in debug builds if the rotation matrix that is built
 from theta_lambda` is invalid.
See also
RotationMatrix::RotationMatrix(const Eigen::AngleAxis<T>&)
 __init__(self: pydrake.math.RigidTransform, R: drake::math::RotationMatrix<double>) > None
Constructs a RigidTransform with a given RotationMatrix and a zero position vector.
 Parameter
R
:  rotation matrix relating frames A and B (e.g.,
R_AB
).
 __init__(self: pydrake.math.RigidTransform, p: numpy.ndarray[float64[3, 1]]) > None
Constructs a RigidTransform with an identity RotationMatrix and a given position vector ‘p’.
 Parameter
p
:  position vector from frame A’s origin to frame B’s origin,
expressed in frame A. In monogram notation p is denoted
p_AoBo_A
.
 __init__(self: pydrake.math.RigidTransform, pose: pydrake.common.eigen_geometry.Isometry3) > None
Constructs a RigidTransform from an Eigen Isometry3.
 Parameter
pose
:  Isometry3 that contains an allegedly valid rotation matrix
R_AB
and also contains a position vectorp_AoBo_A
from frame A’s origin to frame B’s origin.p_AoBo_A
must be expressed in frame A.
Raises:  RuntimeError in debug builds if R_AB is not a proper orthonormal
 3x3 rotation matrix.
Note
No attempt is made to orthogonalize the 3x3 rotation matrix part of
pose
. As needed, use RotationMatrix::ProjectToRotationMatrix().

inverse
(self: pydrake.math.RigidTransform) → pydrake.math.RigidTransform¶ Returns X_BA = X_AB⁻¹, the inverse of
this
RigidTransform.Note
The inverse of RigidTransform X_AB is X_BA, which contains the rotation matrix R_BA = R_AB⁻¹ = R_ABᵀ and the position vector
p_BoAo_B_
(position from B’s origin Bo to A’s origin Ao, expressed in frame B).Note
: The squareroot of a RigidTransform’s condition number is roughly the magnitude of the position vector. The accuracy of the calculation for the inverse of a RigidTransform drops off with the sqrt condition number.

linear
(self: pydrake.math.RigidTransform) → numpy.ndarray[float64[3, 3]]¶ DO NOT USE!. We only offer this API for backwards compatibility with Isometry3 and it will be deprecated soon with the resolution of #9865. This will be removed on or around 20190626.

matrix
(self: pydrake.math.RigidTransform) → numpy.ndarray[float64[4, 4]]¶ DO NOT USE!. We only offer this API for backwards compatibility with Isometry3 and it will be deprecated soon with the resolution of #9865. This will be removed on or around 20190626.

multiply
(*args, **kwargs)¶ Overloaded function.
 multiply(self: pydrake.math.RigidTransform, other: pydrake.math.RigidTransform) > pydrake.math.RigidTransform
Multiplies
this
RigidTransformX_AB
by theother
RigidTransformX_BC
and returns the RigidTransformX_AC = X_AB * X_BC
. multiply(self: pydrake.math.RigidTransform, p_BoQ_B: numpy.ndarray[float64[3, 1]]) > numpy.ndarray[float64[3, 1]]
Calculates
this
RigidTransformX_AB
multiplied by the position vector ‘p_BoQ_B` which is from Bo (B’s origin) to an arbitrary point Q. Parameter
p_BoQ_B
:  position vector from Bo to Q, expressed in frame B.
 Returns
p_AoQ_A
:  position vector from Ao to Q, expressed in frame A.
 multiply(self: pydrake.math.RigidTransform, other: pydrake.common.eigen_geometry.Isometry3) > pydrake.math.RigidTransform
DO NOT USE!. We only offer this API for backwards compatibility with Isometry3 and it will be deprecated soon with the resolution of #9865. This will be removed on or around 20190626.

rotation
(self: pydrake.math.RigidTransform) → drake::math::RotationMatrix<double>¶ Returns R_AB, the rotation matrix portion of
this
RigidTransform. Returns
R_AB
:  the rotation matrix portion of
this
RigidTransform.
 Returns

set
(self: pydrake.math.RigidTransform, R: drake::math::RotationMatrix<double>, p: numpy.ndarray[float64[3, 1]]) → None¶ Sets
this
RigidTransform from a RotationMatrix and a position vector. Parameter
R
:  rotation matrix relating frames A and B (e.g.,
R_AB
).  Parameter
p
:  position vector from frame A’s origin to frame B’s origin,
expressed in frame A. In monogram notation p is denoted
p_AoBo_A
.
 Parameter

set_rotation
(self: pydrake.math.RigidTransform, R: drake::math::RotationMatrix<double>) → None¶ Sets the RotationMatrix portion of
this
RigidTransform. Parameter
R
:  rotation matrix relating frames A and B (e.g.,
R_AB
).
 Parameter

set_translation
(self: pydrake.math.RigidTransform, p: numpy.ndarray[float64[3, 1]]) → None¶ Sets the position vector portion of
this
RigidTransform. Parameter
p
:  position vector from Ao (frame A’s origin) to Bo (frame B’s origin) expressed in frame A. In monogram notation p is denoted p_AoBo_A.
 Parameter

translation
(self: pydrake.math.RigidTransform) → numpy.ndarray[float64[3, 1]]¶ Returns
p_AoBo_A
, the position vector portion ofthis
RigidTransform, i.e., position vector from Ao (frame A’s origin) to Bo (frame B’s origin).

class
pydrake.math.
RollPitchYaw
¶ This class represents the orientation between two arbitrary frames A and D associated with a Spacefixed (extrinsic) XYZ rotation by “rollpitchyaw” angles
[r, p, y]
, which is equivalent to a Bodyfixed (intrinsic) ZYX rotation by “yawpitchroll” angles[y, p, r]
. The rotation matrixR_AD
associated with this rollpitchyaw[r, p, y]
rotation sequence is equal to the matrix multiplication shown below.⎡cos(y) sin(y) 0⎤ ⎡ cos(p) 0 sin(p)⎤ ⎡1 0 0 ⎤ R_AD = ⎢sin(y) cos(y) 0⎥ * ⎢ 0 1 0 ⎥ * ⎢0 cos(r) sin(r)⎥ ⎣ 0 0 1⎦ ⎣sin(p) 0 cos(p)⎦ ⎣0 sin(r) cos(r)⎦ = R_AB * R_BC * R_CD
Note
In this discussion, A is the Space frame and D is the Body frame. One way to visualize this rotation sequence is by introducing intermediate frames B and C (useful constructs to understand this rotation sequence). Initially, the frames are aligned so
Di = Ci = Bi = Ai (i = x, y, z)
where Dx, Dy, Dz and Ax, Ay, Az are orthogonal unit vectors fixed in frames D and A respectively. Similarly for Bx, By, Bz and Cx, Cy, Cz in frame B, C. Then D is subjected to successive righthanded rotations relative to A. 1st rotation R_CD: Frame D rotates relative to frames C, B, A by a
roll angle
r
aboutDx = Cx
. Note: D and C are no longer aligned. 2nd rotation R_BC: Frames D, C (collectively – as if welded together)
rotate relative to frame B, A by a pitch angle
p
aboutCy = By
. Note: C and B are no longer aligned. 3rd rotation R_AB: Frames D, C, B (collectively – as if welded)
rotate relative to frame A by a roll angle
y
aboutBz = Az
. Note: B and A are no longer aligned. The monogram notation for the rotation matrix relating A to D isR_AD
.See also
multibody_quantities for monogram notation for dynamics and orientation_discussion “a discussion on rotation matrices”.
Note
This class does not store the frames associated with this rotation sequence.
 Template parameter
T
:  The underlying scalar type. Must be a valid Eigen scalar.
Instantiated templates for the following kinds of T’s are provided:
 double
 AutoDiffXd
 symbolic::Expression

CalcAngularVelocityInChildFromRpyDt
(self: pydrake.math.RollPitchYaw, rpyDt: numpy.ndarray[float64[3, 1]]) → numpy.ndarray[float64[3, 1]]¶ Calculates angular velocity from
this
RollPitchYaw whose rollpitchyaw angles[r; p; y]
relate the orientation of two generic frames A and D. Parameter
rpyDt
:  Timederivative of
[r; p; y]
, i.e.,[ṙ; ṗ; ẏ]
.
Returns: w_AD_D, frame D’s angular velocity in frame A, expressed in D.  Parameter

CalcAngularVelocityInParentFromRpyDt
(self: pydrake.math.RollPitchYaw, rpyDt: numpy.ndarray[float64[3, 1]]) → numpy.ndarray[float64[3, 1]]¶ Calculates angular velocity from
this
RollPitchYaw whose rollpitchyaw angles[r; p; y]
relate the orientation of two generic frames A and D. Parameter
rpyDt
:  Timederivative of
[r; p; y]
, i.e.,[ṙ; ṗ; ẏ]
.
Returns: w_AD_A, frame D’s angular velocity in frame A, expressed in A.  Parameter

CalcRotationMatrixDt
(self: pydrake.math.RollPitchYaw, rpyDt: numpy.ndarray[float64[3, 1]]) → numpy.ndarray[float64[3, 3]]¶ Forms Ṙ, the ordinary derivative of the RotationMatrix
R
with respect to an independent variablet
(t usually denotes time) andR
is the RotationMatrix formed bythis
RollPitchYaw. The rollpitchyaw angles r, p, y are regarded as functions oft
[i.e., r(t), p(t), y(t)]. Parameter
rpyDt
:  Ordinary derivative of rpy with respect to an independent variable
t
(t usually denotes time, but not necessarily).
Returns: Ṙ, the ordinary derivative of R
with respect tot
, calculated as Ṙ = ∂R/∂r * ṙ + ∂R/∂p * ṗ + ∂R/∂y * ẏ. In other words, the returned (i, j) element is ∂Rij/∂r * ṙ + ∂Rij/∂p * ṗ + ∂Rij/∂y * ẏ. Parameter

CalcRpyDDtFromAngularAccelInChild
(self: pydrake.math.RollPitchYaw, rpyDt: numpy.ndarray[float64[3, 1]], alpha_AD_D: numpy.ndarray[float64[3, 1]]) → numpy.ndarray[float64[3, 1]]¶ Uses angular acceleration to compute the 2ⁿᵈ timederivative of
this
RollPitchYaw whose angles[r; p; y]
orient two generic frames A and D. Parameter
rpyDt
:  timederivative of
[r; p; y]
, i.e.,[ṙ; ṗ; ẏ]
.  Parameter
alpha_AD_D
:  , frame D’s angular acceleration in frame A, expressed in frame D.
Returns: [r̈, p̈, ÿ]
, the 2ⁿᵈ timederivative ofthis
RollPitchYaw.Raises: RuntimeError if cos(p) ≈ 0
(p is near gimballock).Note
This method has a dividebyzero error (singularity) when the cosine of the pitch angle
p
is zero [i.e.,cos(p) = 0`]. This problem (called "gimbal lock") occurs when `p = n π + π / 2
, where n is any integer. There are associated precision problems (inaccuracies) in the neighborhood of these pitch angles, i.e., whencos(p) ≈ 0
. Parameter

CalcRpyDDtFromRpyDtAndAngularAccelInParent
(self: pydrake.math.RollPitchYaw, rpyDt: numpy.ndarray[float64[3, 1]], alpha_AD_A: numpy.ndarray[float64[3, 1]]) → numpy.ndarray[float64[3, 1]]¶ Uses angular acceleration to compute the 2ⁿᵈ timederivative of
this
RollPitchYaw whose angles[r; p; y]
orient two generic frames A and D. Parameter
rpyDt
:  timederivative of
[r; p; y]
, i.e.,[ṙ; ṗ; ẏ]
.  Parameter
alpha_AD_A
:  , frame D’s angular acceleration in frame A, expressed in frame A.
Returns: [r̈, p̈, ÿ]
, the 2ⁿᵈ timederivative ofthis
RollPitchYaw.Raises: RuntimeError if cos(p) ≈ 0
(p is near gimballock).Note
This method has a dividebyzero error (singularity) when the cosine of the pitch angle
p
is zero [i.e.,cos(p) = 0`]. This problem (called "gimbal lock") occurs when `p = n π + π / 2
, where n is any integer. There are associated precision problems (inaccuracies) in the neighborhood of these pitch angles, i.e., whencos(p) ≈ 0
. Parameter

CalcRpyDtFromAngularVelocityInParent
(self: pydrake.math.RollPitchYaw, w_AD_A: numpy.ndarray[float64[3, 1]]) → numpy.ndarray[float64[3, 1]]¶ Uses angular velocity to compute the 1ˢᵗ timederivative of
this
RollPitchYaw whose angles[r; p; y]
orient two generic frames A and D. Parameter
w_AD_A
:  , frame D’s angular velocity in frame A, expressed in A.
Returns: [ṙ; ṗ; ẏ]
, the 1ˢᵗ timederivative ofthis
RollPitchYaw.Raises: RuntimeError if cos(p) ≈ 0
(p is near gimballock).Note
This method has a dividebyzero error (singularity) when the cosine of the pitch angle
p
is zero [i.e.,cos(p) = 0`]. This problem (called "gimbal lock") occurs when `p = n π + π / 2
, where n is any integer. There are associated precision problems (inaccuracies) in the neighborhood of these pitch angles, i.e., whencos(p) ≈ 0
. Parameter

ToQuaternion
(self: pydrake.math.RollPitchYaw) → pydrake.common.eigen_geometry.Quaternion¶ Returns a quaternion representation of
this
RollPitchYaw.

ToRotationMatrix
(self: pydrake.math.RollPitchYaw) → drake::math::RotationMatrix<double>¶ Returns the RotationMatrix representation of
this
RollPitchYaw.

__init__
(*args, **kwargs)¶ Overloaded function.
 __init__(self: pydrake.math.RollPitchYaw, other: pydrake.math.RollPitchYaw) > None
 __init__(self: pydrake.math.RollPitchYaw, rpy: numpy.ndarray[float64[3, 1]]) > None
Constructs a RollPitchYaw from a 3x1 array of angles.
 Parameter
rpy
:  3x1 array with roll, pitch, yaw angles (units of radians).
Raises: RuntimeError in debug builds if !IsValid(rpy).  __init__(self: pydrake.math.RollPitchYaw, roll: float, pitch: float, yaw: float) > None
Constructs a RollPitchYaw from roll, pitch, yaw angles (radian units).
 Parameter
roll
:  xdirected angle in SpaceXYZ rotation sequence.
 Parameter
pitch
:  ydirected angle in SpaceXYZ rotation sequence.
 Parameter
yaw
:  zdirected angle in SpaceXYZ rotation sequence.
Raises:  RuntimeError in debug builds if !IsValid(Vector3<T>(roll, pitch,
yaw)).
 __init__(self: pydrake.math.RollPitchYaw, R: drake::math::RotationMatrix<double>) > None
Uses a RotationMatrix to construct a RollPitchYaw with rollpitchyaw angles
[r, p, y]
in the rangeπ <= r <= π
, π/2 <= p <= π/2, `π <= y <= π``. Parameter
R
:  a RotationMatrix.
Note
This new highaccuracy algorithm avoids numerical roundoff issues encountered by some algorithms when pitch is within 1E6 of π/2 or π/2.
 __init__(self: pydrake.math.RollPitchYaw, quaternion: pydrake.common.eigen_geometry.Quaternion) > None
Uses a Quaternion to construct a RollPitchYaw with rollpitchyaw angles
[r, p, y]
in the rangeπ <= r <= π
, π/2 <= p <= π/2, `π <= y <= π``. Parameter
quaternion
:  unit Quaternion.
Note
This new highaccuracy algorithm avoids numerical roundoff issues encountered by some algorithms when pitch is within 1E6 of π/2 or π/2.
Raises: RuntimeError in debug builds if !IsValid(rpy).  __init__(self: pydrake.math.RollPitchYaw, matrix: numpy.ndarray[float64[3, 3]]) > None
Construct from raw rotation matrix. See RotationMatrix overload for more information.

pitch_angle
(self: pydrake.math.RollPitchYaw) → float¶ Returns the pitchangle underlying
this
RollPitchYaw.

roll_angle
(self: pydrake.math.RollPitchYaw) → float¶ Returns the rollangle underlying
this
RollPitchYaw.

vector
(self: pydrake.math.RollPitchYaw) → numpy.ndarray[float64[3, 1]]¶ Returns the Vector3 underlying
this
RollPitchYaw.

yaw_angle
(self: pydrake.math.RollPitchYaw) → float¶ Returns the yawangle underlying
this
RollPitchYaw.

class
pydrake.math.
RotationMatrix
¶ This class represents a 3x3 rotation matrix between two arbitrary frames A and B and helps ensure users create valid rotation matrices. This class relates righthanded orthogonal unit vectors Ax, Ay, Az fixed in frame A to righthanded orthogonal unit vectors Bx, By, Bz fixed in frame B. The monogram notation for the rotation matrix relating A to B is
R_AB
. An example that gives context to this rotation matrix isv_A = R_AB * v_B
, wherev_B
denotes an arbitrary vector v expressed in terms of Bx, By, Bz andv_A
denotes vector v expressed in terms of Ax, Ay, Az. See multibody_quantities for monogram notation for dynamics. See orientation_discussion “a discussion on rotation matrices”.Note
This class does not store the frames associated with a rotation matrix nor does it enforce strict proper usage of this class with vectors.
Note
When assertions are enabled, several methods in this class do a validity check and throw an exception (RuntimeError) if the rotation matrix is invalid. When assertions are disabled, many of these validity checks are skipped (which helps improve speed). In addition, these validity tests are only performed for scalar types for which drake::scalar_predicate<T>::is_bool is
True
. For instance, validity checks are not performed when T is symbolic::Expression. Authors:
 Paul Mitiguy (2018) Original author.
 Authors:
 Drake team (see https://drake.mit.edu/credits).
 Template parameter
T
:  The underlying scalar type. Must be a valid Eigen scalar.
Instantiated templates for the following kinds of T’s are provided:
 double
 AutoDiffXd
 symbolic::Expression

Identity
() → pydrake.math.RotationMatrix¶

ToQuaternion
(self: pydrake.math.RotationMatrix) → pydrake.common.eigen_geometry.Quaternion¶ Returns a quaternion q that represents
this
RotationMatrix. Since the quaternionq
andq
represent the same RotationMatrix, this method chooses to return a canonical quaternion, i.e., with q(0) >= 0.

__init__
(*args, **kwargs)¶ Overloaded function.
 __init__(self: pydrake.math.RotationMatrix) > None
Constructs a 3x3 identity RotationMatrix – which corresponds to aligning two frames (so that unit vectors Ax = Bx, Ay = By, Az = Bz).
 __init__(self: pydrake.math.RotationMatrix, other: pydrake.math.RotationMatrix) > None
 __init__(self: pydrake.math.RotationMatrix, R: numpy.ndarray[float64[3, 3]]) > None
Constructs a RotationMatrix from a Matrix3.
 Parameter
R
:  an allegedly valid rotation matrix.
Raises: RuntimeError in debug builds if R fails IsValid(R).  __init__(self: pydrake.math.RotationMatrix, quaternion: pydrake.common.eigen_geometry.Quaternion) > None
Constructs a RotationMatrix from an Eigen::Quaternion.
 Parameter
quaternion
:  a nonzero, finite quaternion which may or may not have unit
length [i.e.,
quaternion.norm()
does not have to be 1].
Raises:  RuntimeError in debug builds if the rotation matrix R that is
 built from
quaternion
fails IsValid(R). For example, an  exception is thrown if
quaternion
is zero or contains a NaN or infinity.
Note
This method has the effect of normalizing its
quaternion
argument, without the inefficiency of the squareroot associated with normalization. __init__(self: pydrake.math.RotationMatrix, rpy: pydrake.math.RollPitchYaw) > None
Constructs a RotationMatrix from an RollPitchYaw. In other words, makes the RotationMatrix for a Spacefixed (extrinsic) XYZ rotation by “rollpitchyaw” angles
[r, p, y]
, which is equivalent to a Bodyfixed (intrinsic) ZYX rotation by “yawpitchroll” angles[y, p, r]
. Parameter
rpy
:  radian measures of three angles [roll, pitch, yaw].
 Parameter
rpy
:  a RollPitchYaw which is a Spacefixed (extrinsic) XYZ rotation
with “rollpitchyaw” angles
[r, p, y]
or equivalently a Body fixed (intrinsic) ZYX rotation with “yawpitchroll” angles[y, p, r]
.
Note
Denoting roll
r
, pitchp
, yawy
, this method returns a rotation matrixR_AD
equal to the matrix multiplication shown below.⎡cos(y) sin(y) 0⎤ ⎡ cos(p) 0 sin(p)⎤ ⎡1 0 0 ⎤ R_AD = ⎢sin(y) cos(y) 0⎥ * ⎢ 0 1 0 ⎥ * ⎢0 cos(r) sin(r)⎥ ⎣ 0 0 1⎦ ⎣sin(p) 0 cos(p)⎦ ⎣0 sin(r) cos(r)⎦ = R_AB * R_BC * R_CD
Note
In this discussion, A is the Space frame and D is the Body frame. One way to visualize this rotation sequence is by introducing intermediate frames B and C (useful constructs to understand this rotation sequence). Initially, the frames are aligned so
Di = Ci = Bi = Ai (i = x, y, z)
. Then D is subjected to successive righthanded rotations relative to A. 1st rotation R_CD: Frame D rotates relative to frames C, B, A by a
roll angle
r
aboutDx = Cx
. Note: D and C are no longer aligned. 2nd rotation R_BC: Frames D, C (collectively – as if welded together)
rotate relative to frame B, A by a pitch angle
p
aboutCy = By
. Note: C and B are no longer aligned. 3rd rotation R_AB: Frames D, C, B (collectively – as if welded)
rotate relative to frame A by a roll angle
y
aboutBz = Az
. Note: B and A are no longer aligned.

inverse
(self: pydrake.math.RotationMatrix) → pydrake.math.RotationMatrix¶

matrix
(self: pydrake.math.RotationMatrix) → numpy.ndarray[float64[3, 3]]¶ Returns the Matrix3 underlying a RotationMatrix.
See also
col(), row()

multiply
(self: pydrake.math.RotationMatrix, arg0: pydrake.math.RotationMatrix) → pydrake.math.RotationMatrix¶ Calculates
this
rotation matrixR_AB
multiplied byother
rotation matrixR_BC
, returning the compositionR_AB * R_BC
. Parameter
other
:  RotationMatrix that postmultiplies
this
.
Returns: rotation matrix that results from this
multiplied byother
.Note
It is possible (albeit improbable) to create an invalid rotation matrix by accumulating roundoff error with a large number of multiplies.
 Parameter

pydrake.math.
abs
(*args, **kwargs)¶ Overloaded function.
 abs(arg0: float) > float
 abs(arg0: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 abs(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
acos
(*args, **kwargs)¶ Overloaded function.
 acos(arg0: float) > float
 acos(arg0: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 acos(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
asin
(*args, **kwargs)¶ Overloaded function.
 asin(arg0: float) > float
 asin(arg0: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 asin(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
atan
(*args, **kwargs)¶ Overloaded function.
 atan(arg0: float) > float
 atan(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
atan2
(*args, **kwargs)¶ Overloaded function.
 atan2(y: float, x: float) > float
 atan2(arg0: pydrake.autodiffutils.AutoDiffXd, arg1: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 atan2(arg0: pydrake.symbolic.Expression, arg1: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
ceil
(*args, **kwargs)¶ Overloaded function.
 ceil(arg0: float) > float
 ceil(arg0: pydrake.autodiffutils.AutoDiffXd) > float
 ceil(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
cos
(*args, **kwargs)¶ Overloaded function.
 cos(arg0: float) > float
 cos(arg0: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 cos(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
cosh
(*args, **kwargs)¶ Overloaded function.
 cosh(arg0: float) > float
 cosh(arg0: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 cosh(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
exp
(*args, **kwargs)¶ Overloaded function.
 exp(arg0: float) > float
 exp(arg0: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 exp(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
floor
(*args, **kwargs)¶ Overloaded function.
 floor(arg0: float) > float
 floor(arg0: pydrake.autodiffutils.AutoDiffXd) > float
 floor(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
inv
(*args, **kwargs)¶ Overloaded function.
 inv(arg0: numpy.ndarray[float64[m, n]]) > numpy.ndarray[float64[m, n]]
 inv(arg0: numpy.ndarray[object[m, n]]) > numpy.ndarray[object[m, n]]
 inv(arg0: numpy.ndarray[object[m, n]]) > numpy.ndarray[object[m, n]]

pydrake.math.
log
(*args, **kwargs)¶ Overloaded function.
 log(arg0: float) > float
 log(arg0: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 log(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
max
(*args, **kwargs)¶ Overloaded function.
 max(arg0: float, arg1: float) > float
 max(arg0: pydrake.autodiffutils.AutoDiffXd, arg1: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 max(arg0: pydrake.symbolic.Expression, arg1: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
min
(*args, **kwargs)¶ Overloaded function.
 min(arg0: float, arg1: float) > float
 min(arg0: pydrake.autodiffutils.AutoDiffXd, arg1: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 min(arg0: pydrake.symbolic.Expression, arg1: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
pow
(*args, **kwargs)¶ Overloaded function.
 pow(arg0: float, arg1: float) > float
 pow(arg0: pydrake.autodiffutils.AutoDiffXd, arg1: int) > pydrake.autodiffutils.AutoDiffXd
 pow(arg0: pydrake.symbolic.Expression, arg1: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
sin
(*args, **kwargs)¶ Overloaded function.
 sin(arg0: float) > float
 sin(arg0: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 sin(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
sinh
(*args, **kwargs)¶ Overloaded function.
 sinh(arg0: float) > float
 sinh(arg0: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 sinh(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
sqrt
(*args, **kwargs)¶ Overloaded function.
 sqrt(arg0: float) > float
 sqrt(arg0: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 sqrt(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
tan
(*args, **kwargs)¶ Overloaded function.
 tan(arg0: float) > float
 tan(arg0: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 tan(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
tanh
(*args, **kwargs)¶ Overloaded function.
 tanh(arg0: float) > float
 tanh(arg0: pydrake.autodiffutils.AutoDiffXd) > pydrake.autodiffutils.AutoDiffXd
 tanh(arg0: pydrake.symbolic.Expression) > pydrake.symbolic.Expression

pydrake.math.
wrap_to
(value: float, low: float, high: float) → float¶ For variables that are meant to be periodic, (e.g. over a 2π interval), wraps
value
into the interval[low, high)
. Precisely,wrap_to
returns: value + k*(highlow) for the unique integer valuek
that lands the output in the desired interval.low
andhigh
must be finite, and low < high.