Drake
LcmAndVectorBaseTranslator Class Referenceabstract

Defines an abstract parent class of all translators that convert between LCM message bytes and drake::systems::VectorBase objects. More...

#include <drake/systems/lcm/lcm_and_vector_base_translator.h>

Public Member Functions

 LcmAndVectorBaseTranslator (int size)
 The constructor. More...
 
virtual ~LcmAndVectorBaseTranslator ()
 
int get_vector_size () const
 Returns the size of the vector in the drake::systems::VectorBase object. More...
 
virtual std::unique_ptr< BasicVector< double > > AllocateOutputVector () const
 Allocates the vector storage for an output port of our LCM message type, in case special storage is needed. More...
 
virtual void Deserialize (const void *lcm_message_bytes, int lcm_message_length, VectorBase< double > *vector_base) const =0
 Translates LCM message bytes into a drake::systems::VectorBase object. More...
 
virtual void Serialize (double time, const VectorBase< double > &vector_base, std::vector< uint8_t > *lcm_message_bytes) const =0
 Translates a drake::systems::VectorBase object into LCM message bytes. More...
 
Does not allow copy, move, or assignment
 LcmAndVectorBaseTranslator (const LcmAndVectorBaseTranslator &)=delete
 
LcmAndVectorBaseTranslatoroperator= (const LcmAndVectorBaseTranslator &)=delete
 
 LcmAndVectorBaseTranslator (LcmAndVectorBaseTranslator &&)=delete
 
LcmAndVectorBaseTranslatoroperator= (LcmAndVectorBaseTranslator &&)=delete
 

Detailed Description

Defines an abstract parent class of all translators that convert between LCM message bytes and drake::systems::VectorBase objects.

Constructor & Destructor Documentation

◆ LcmAndVectorBaseTranslator() [1/3]

◆ LcmAndVectorBaseTranslator() [2/3]

◆ LcmAndVectorBaseTranslator() [3/3]

LcmAndVectorBaseTranslator ( int  size)
explicit

The constructor.

Parameters
[in]sizeThe size of the vector in the VectorBase.

◆ ~LcmAndVectorBaseTranslator()

Member Function Documentation

◆ AllocateOutputVector()

std::unique_ptr< BasicVector< double > > AllocateOutputVector ( ) const
virtual

Allocates the vector storage for an output port of our LCM message type, in case special storage is needed.

A result of nullptr indicates that no special vector is needed; the calling code can and should use a default vector implementation such as BasicVector.

The default implementation in this class returns nullptr. Subclasses that require custom VectorBase subtypes should override it.

Reimplemented in PoseStampedTPoseVectorTranslator.

◆ Deserialize()

virtual void Deserialize ( const void *  lcm_message_bytes,
int  lcm_message_length,
VectorBase< double > *  vector_base 
) const
pure virtual

Translates LCM message bytes into a drake::systems::VectorBase object.

Parameters
[in]lcm_message_bytesA pointer to a buffer holding the LCM message's data.
[in]lcm_message_lengthThe number of bytes pointed to by the lcm_message_bytes.
[out]vector_baseA pointer to where the translation of the LCM message should be stored. This pointer must not be nullptr.
Exceptions
std::runtime_errorIf a received LCM message failed to be decoded, or if the decoded LCM message is incompatible with the vector_base. This often occurs when the size of the vector_base does not equal or is incompatible with the size of the decoded LCM message.

Implemented in ViewerDrawTranslator, LcmtDrakeSignalTranslator, and PoseStampedTPoseVectorTranslator.

◆ get_vector_size()

int get_vector_size ( ) const

Returns the size of the vector in the drake::systems::VectorBase object.

◆ operator=() [1/2]

◆ operator=() [2/2]

LcmAndVectorBaseTranslator& operator= ( const LcmAndVectorBaseTranslator )
delete

◆ Serialize()

virtual void Serialize ( double  time,
const VectorBase< double > &  vector_base,
std::vector< uint8_t > *  lcm_message_bytes 
) const
pure virtual

Translates a drake::systems::VectorBase object into LCM message bytes.

Parameters
[in]timeThe current time in seconds. This value is typically obtained from drake::systems::Context::get_time().
[in]vector_baseThe object to convert into an LCM message.
[out]lcm_message_bytesThe LCM message bytes. This pointer must not be nullptr.

Implemented in ViewerDrawTranslator, LcmtDrakeSignalTranslator, and PoseStampedTPoseVectorTranslator.


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