Drake
Drake C++ Documentation
PiecewiseQuaternionSlerp< T > Class Template Referencefinal

Detailed Description

template<typename T>
class drake::trajectories::PiecewiseQuaternionSlerp< T >

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.

Template Parameters
TThe scalar type, which must be one of the default scalars.

#include <drake/common/trajectories/piecewise_quaternion.h>

Public Member Functions

 PiecewiseQuaternionSlerp ()=default
 Builds an empty PiecewiseQuaternionSlerp. More...
 
 PiecewiseQuaternionSlerp (const std::vector< T > &breaks, const std::vector< Quaternion< T >> &quaternions)
 Builds a PiecewiseQuaternionSlerp. More...
 
 PiecewiseQuaternionSlerp (const std::vector< T > &breaks, const std::vector< Matrix3< T >> &rotation_matrices)
 Builds a PiecewiseQuaternionSlerp. More...
 
 PiecewiseQuaternionSlerp (const std::vector< T > &breaks, const std::vector< math::RotationMatrix< T >> &rotation_matrices)
 Builds a PiecewiseQuaternionSlerp. More...
 
 PiecewiseQuaternionSlerp (const std::vector< T > &breaks, const std::vector< AngleAxis< T >> &angle_axes)
 Builds a PiecewiseQuaternionSlerp. More...
 
 ~PiecewiseQuaternionSlerp () override
 
std::unique_ptr< Trajectory< T > > Clone () const override
 
Eigen::Index rows () const override
 
Eigen::Index cols () const override
 
Quaternion< T > orientation (const T &time) const
 Interpolates orientation. More...
 
MatrixX< T > value (const T &time) const override
 Evaluates the trajectory at the given time t. More...
 
Vector3< T > angular_velocity (const T &time) const
 Interpolates angular velocity. More...
 
Vector3< T > angular_acceleration (const T &time) const
 Interpolates angular acceleration. More...
 
const std::vector< Quaternion< T > > & get_quaternion_samples () const
 Getter for the internal quaternion samples. More...
 
bool is_approx (const PiecewiseQuaternionSlerp< T > &other, double tol) const
 Returns true if all the corresponding segment times are within tol seconds, and the angle difference between the corresponding quaternion sample points are within tol (using ExtractDoubleOrThrow). More...
 
void Append (const T &time, const Quaternion< T > &quaternion)
 Given a new Quaternion, this method adds one segment to the end of this. More...
 
void Append (const T &time, const math::RotationMatrix< T > &rotation_matrix)
 Given a new RotationMatrix, this method adds one segment to the end of this. More...
 
void Append (const T &time, const AngleAxis< T > &angle_axis)
 Given a new AngleAxis, this method adds one segment to the end of this. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 PiecewiseQuaternionSlerp (const PiecewiseQuaternionSlerp &)=default
 
PiecewiseQuaternionSlerpoperator= (const PiecewiseQuaternionSlerp &)=default
 
 PiecewiseQuaternionSlerp (PiecewiseQuaternionSlerp &&)=default
 
PiecewiseQuaternionSlerpoperator= (PiecewiseQuaternionSlerp &&)=default
 
- Public Member Functions inherited from PiecewiseTrajectory< T >
 ~PiecewiseTrajectory () override
 
int get_number_of_segments () const
 
start_time (int segment_number) const
 
end_time (int segment_number) const
 
duration (int segment_number) const
 
start_time () const override
 
end_time () const override
 
boolean< T > is_time_in_range (const T &t) const
 Returns true iff t >= getStartTime() && t <= getEndTime(). More...
 
int get_segment_index (const T &t) const
 
const std::vector< T > & get_segment_times () const
 
void segment_number_range_check (int segment_number) const
 
- Public Member Functions inherited from Trajectory< T >
virtual ~Trajectory ()
 
MatrixX< T > vector_values (const std::vector< T > &t) const
 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. More...
 
MatrixX< T > vector_values (const Eigen::Ref< const VectorX< T >> &t) const
 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. More...
 
bool has_derivative () const
 Returns true iff the Trajectory provides and implementation for EvalDerivative() and MakeDerivative(). More...
 
MatrixX< T > EvalDerivative (const T &t, int derivative_order=1) const
 Evaluates the derivative of this at the given time t. More...
 
std::unique_ptr< Trajectory< T > > MakeDerivative (int derivative_order=1) const
 Takes the derivative of this Trajectory. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from PiecewiseTrajectory< T >
static std::vector< T > RandomSegmentTimes (int num_segments, std::default_random_engine &generator)
 
- Static Public Attributes inherited from PiecewiseTrajectory< T >
static constexpr double kEpsilonTime = std::numeric_limits<double>::epsilon()
 Minimum delta quantity used for comparing time. More...
 
- Protected Member Functions inherited from PiecewiseTrajectory< T >
 PiecewiseTrajectory ()=default
 
 PiecewiseTrajectory (const std::vector< T > &breaks)
 breaks increments must be greater or equal to kEpsilonTime. More...
 
bool SegmentTimesEqual (const PiecewiseTrajectory &b, double tol=kEpsilonTime) const
 
const std::vector< T > & breaks () const
 
std::vector< T > & get_mutable_breaks ()
 
 PiecewiseTrajectory (const PiecewiseTrajectory &)=default
 
PiecewiseTrajectoryoperator= (const PiecewiseTrajectory &)=default
 
 PiecewiseTrajectory (PiecewiseTrajectory &&)=default
 
PiecewiseTrajectoryoperator= (PiecewiseTrajectory &&)=default
 
- Protected Member Functions inherited from Trajectory< T >
 Trajectory ()=default
 
 Trajectory (const Trajectory &)=default
 
Trajectoryoperator= (const Trajectory &)=default
 
 Trajectory (Trajectory &&)=default
 
Trajectoryoperator= (Trajectory &&)=default
 

Constructor & Destructor Documentation

◆ PiecewiseQuaternionSlerp() [1/7]

◆ PiecewiseQuaternionSlerp() [2/7]

◆ PiecewiseQuaternionSlerp() [3/7]

Builds an empty PiecewiseQuaternionSlerp.

◆ PiecewiseQuaternionSlerp() [4/7]

PiecewiseQuaternionSlerp ( const std::vector< T > &  breaks,
const std::vector< Quaternion< T >> &  quaternions 
)

Builds a PiecewiseQuaternionSlerp.

Exceptions
std::exceptionif breaks and quaternions have different length, or breaks have length < 2.

◆ PiecewiseQuaternionSlerp() [5/7]

PiecewiseQuaternionSlerp ( const std::vector< T > &  breaks,
const std::vector< Matrix3< T >> &  rotation_matrices 
)

Builds a PiecewiseQuaternionSlerp.

Exceptions
std::exceptionif breaks and rot_matrices have different length, or breaks have length < 2.

◆ PiecewiseQuaternionSlerp() [6/7]

PiecewiseQuaternionSlerp ( const std::vector< T > &  breaks,
const std::vector< math::RotationMatrix< T >> &  rotation_matrices 
)

Builds a PiecewiseQuaternionSlerp.

Exceptions
std::exceptionif breaks and rot_matrices have different length, or breaks have length < 2.

◆ PiecewiseQuaternionSlerp() [7/7]

PiecewiseQuaternionSlerp ( const std::vector< T > &  breaks,
const std::vector< AngleAxis< T >> &  angle_axes 
)

Builds a PiecewiseQuaternionSlerp.

Exceptions
std::exceptionif breaks and ang_axes have different length, or breaks have length < 2.

◆ ~PiecewiseQuaternionSlerp()

~PiecewiseQuaternionSlerp ( )
override

Member Function Documentation

◆ angular_acceleration()

Vector3<T> angular_acceleration ( const T &  time) const

Interpolates angular acceleration.

Parameters
timeTime for interpolation.
Returns
The interpolated angular acceleration at time, which is always zero for slerp.

◆ angular_velocity()

Vector3<T> angular_velocity ( const T &  time) const

Interpolates angular velocity.

Parameters
timeTime for interpolation.
Returns
The interpolated angular velocity at time, which is constant per segment.

◆ Append() [1/3]

void Append ( const T &  time,
const Quaternion< T > &  quaternion 
)

Given a new Quaternion, this method adds one segment to the end of this.

◆ Append() [2/3]

void Append ( const T &  time,
const math::RotationMatrix< T > &  rotation_matrix 
)

Given a new RotationMatrix, this method adds one segment to the end of this.

◆ Append() [3/3]

void Append ( const T &  time,
const AngleAxis< T > &  angle_axis 
)

Given a new AngleAxis, this method adds one segment to the end of this.

◆ Clone()

std::unique_ptr<Trajectory<T> > Clone ( ) const
overridevirtual
Returns
A deep copy of this Trajectory.

Implements Trajectory< T >.

◆ cols()

Eigen::Index cols ( ) const
overridevirtual
Returns
The number of columns in the matrix returned by value().

Implements Trajectory< T >.

◆ get_quaternion_samples()

const std::vector<Quaternion<T> >& get_quaternion_samples ( ) const

Getter for the internal quaternion samples.

Note
The returned quaternions might be different from the ones used for construction because the internal representations are set to always be the "closest" w.r.t to the previous one.
Returns
the internal sample points.

◆ is_approx()

bool is_approx ( const PiecewiseQuaternionSlerp< T > &  other,
double  tol 
) const

Returns true if all the corresponding segment times are within tol seconds, and the angle difference between the corresponding quaternion sample points are within tol (using ExtractDoubleOrThrow).

◆ operator=() [1/2]

PiecewiseQuaternionSlerp& operator= ( PiecewiseQuaternionSlerp< T > &&  )
default

◆ operator=() [2/2]

PiecewiseQuaternionSlerp& operator= ( const PiecewiseQuaternionSlerp< T > &  )
default

◆ orientation()

Quaternion<T> orientation ( const T &  time) const

Interpolates orientation.

Parameters
timeTime for interpolation.
Returns
The interpolated quaternion at time.

◆ rows()

Eigen::Index rows ( ) const
overridevirtual
Returns
The number of rows in the matrix returned by value().

Implements Trajectory< T >.

◆ value()

MatrixX<T> value ( const T &  t) const
overridevirtual

Evaluates the trajectory at the given time t.

Parameters
tThe time at which to evaluate the trajectory.
Returns
The matrix of evaluated values.

Implements Trajectory< T >.


The documentation for this class was generated from the following file: