Drake
FrameKinematicsVector< KinematicsValue > Class Template Reference

Detailed Description

template<class KinematicsValue>
class drake::geometry::FrameKinematicsVector< KinematicsValue >

A FrameKinematicsVector is used to report kinematics data for registered frames (identified by unique FrameId values) to SceneGraph.

It serves as the basis of FramePoseVector, FrameVelocityVector, and FrameAccelerationVector.

template <typename T>
class MySystem : public LeafSystem<T> {
public:
MySystem() {
...
this->DeclareAbstractOutputPort(
&AllocInConstructorSystem::CalcFramePoseOutput);
...
}
private:
void CalcFramePoseOutput(const Context<T>& context,
geometry::FramePoseVector<T>* poses) const {
poses->clear();
for (int i = 0; i < static_cast<int>(frame_ids_.size()); ++i) {
poses->set_value(frame_ids_[i], poses_[i]);
}
}
std::vector<FrameId> frame_ids_;
std::vector<RigidTransform<T>> poses_;
};

If a System only ever emits a single frame (or small-constant-number of frames), then there's a shorter alternative way to write a Calc method, using an initializer_list:

void CalcFramePoseOutput(const Context<T>& context,
geometry::FramePoseVector<T>* poses) const {
const RigidTransform<T>& pose = ...;
*poses = {{frame_id_, pose}};
}

N.B. When the systems framework calls the Calc method, the value pointed to by poses is in an unspecified state. The implementation of Calc must always ensure that poses contains the correct value upon return, no matter what value it started with. The easy ways to do this are to call either poses->clear() or the assignment operator *poses = ....

Template Parameters
KinematicsValueThe underlying data type of for the order of kinematics data (e.g., pose, velocity, or acceleration).

One should never interact with the FrameKinematicsVector class directly. Instead, the FramePoseVector, FrameVelocityVector, and FrameAccelerationVector classes are aliases of the FrameKinematicsVector instantiated on specific data types (RigidTransform, SpatialVector, and SpatialAcceleration, respectively). Each of these data types are templated on Eigen scalars. All supported combinations of data type and scalar type are already available to link against in the containing library. No other values for KinematicsValue are supported.

Currently, the following data types with the following scalar types are supported:

Alias Instantiation Scalar types
FramePoseVector FrameKinematicsVector<RigidTransform<Scalar>> double
FramePoseVector FrameKinematicsVector<RigidTransform<Scalar>> AutoDiffXd
FramePoseVector FrameKinematicsVector<RigidTransform<Scalar>> Expression

#include <drake/geometry/frame_kinematics_vector.h>

Public Member Functions

 FrameKinematicsVector ()
 Initializes the vector using an invalid SourceId with no frames . More...
 
 FrameKinematicsVector (std::initializer_list< std::pair< const FrameId, KinematicsValue >> init)
 Initializes the vector using an invalid SourceId and the given frames and kinematics values. More...
 
FrameKinematicsVectoroperator= (std::initializer_list< std::pair< const FrameId, KinematicsValue >> init)
 Resets the vector to the given frames and kinematics values . More...
 
void clear ()
 Clears all values, resetting the size to zero. More...
 
void set_value (FrameId id, const KinematicsValue &value)
 Sets the kinematics value for the frame indicated by the given id. More...
 
int size () const
 Returns number of frame_ids(). More...
 
const KinematicsValue & value (FrameId id) const
 Returns the value associated with the given id. More...
 
bool has_id (FrameId id) const
 Reports true if the given id is a member of this data. More...
 
std::vector< FrameIdframe_ids () const
 Provides a range object for all of the frame ids in the vector. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 FrameKinematicsVector (const FrameKinematicsVector &)=default
 
FrameKinematicsVectoroperator= (const FrameKinematicsVector &)=default
 
 FrameKinematicsVector (FrameKinematicsVector &&)=default
 
FrameKinematicsVectoroperator= (FrameKinematicsVector &&)=default
 

Constructor & Destructor Documentation

◆ FrameKinematicsVector() [1/4]

FrameKinematicsVector ( const FrameKinematicsVector< KinematicsValue > &  )
default

◆ FrameKinematicsVector() [2/4]

FrameKinematicsVector ( FrameKinematicsVector< KinematicsValue > &&  )
default

◆ FrameKinematicsVector() [3/4]

Initializes the vector using an invalid SourceId with no frames .

◆ FrameKinematicsVector() [4/4]

FrameKinematicsVector ( std::initializer_list< std::pair< const FrameId, KinematicsValue >>  init)

Initializes the vector using an invalid SourceId and the given frames and kinematics values.

Member Function Documentation

◆ clear()

void clear ( )

Clears all values, resetting the size to zero.

◆ frame_ids()

std::vector<FrameId> frame_ids ( ) const

Provides a range object for all of the frame ids in the vector.

This is intended to be used as:

for (FrameId id : this_vector.frame_ids()) {
...
// Obtain the KinematicsValue of an id by `this_vector.value(id)`
...
}

◆ has_id()

bool has_id ( FrameId  id) const

Reports true if the given id is a member of this data.

◆ operator=() [1/3]

FrameKinematicsVector& operator= ( FrameKinematicsVector< KinematicsValue > &&  )
default

◆ operator=() [2/3]

FrameKinematicsVector& operator= ( const FrameKinematicsVector< KinematicsValue > &  )
default

◆ operator=() [3/3]

FrameKinematicsVector& operator= ( std::initializer_list< std::pair< const FrameId, KinematicsValue >>  init)

Resets the vector to the given frames and kinematics values .

◆ set_value()

void set_value ( FrameId  id,
const KinematicsValue &  value 
)

Sets the kinematics value for the frame indicated by the given id.

◆ size()

int size ( ) const

Returns number of frame_ids().

◆ value()

const KinematicsValue& value ( FrameId  id) const

Returns the value associated with the given id.

Exceptions
std::runtime_errorif id is not in the specified set of ids.

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