Drake
Drake C++ Documentation
VectorLog< T > Class Template Reference

Detailed Description

template<typename T>
class drake::systems::VectorLog< T >

This utility class serves as an in-memory cache of time-dependent vector values.

Note that this is a standalone class, not a Drake System. It is primarily intended to support the Drake System primitive VectorLogSink, but can be used independently.

When the log becomes full, adding more data will cause the allocated space to double in size. If avoiding memory allocation during some performance-critical phase is desired, clients can call Reserve() to pre-allocate log storage.

This object imposes no constraints on the stored data. For example, times passed to AddData() need not be increasing in order of insertion, values are allowed to be infinite, NaN, etc.

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

#include <drake/systems/primitives/vector_log.h>

Public Member Functions

 VectorLog (int input_size)
 Constructs the vector log. More...
 
int64_t get_input_size () const
 Reports the size of the log's input vector. More...
 
int num_samples () const
 Returns the number of samples taken since construction or last Clear(). More...
 
Eigen::VectorBlock< const VectorX< T > > sample_times () const
 Accesses the logged time stamps. More...
 
Eigen::Block< const MatrixX< T >, Eigen::Dynamic, Eigen::Dynamic, true > data () const
 Accesses the logged data. More...
 
void Reserve (int64_t capacity)
 Reserve storage for at least capacity samples. More...
 
void Clear ()
 Clears the logged data. More...
 
void AddData (const T &time, const VectorX< T > &sample)
 Adds a sample to the data set with the associated time value. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 VectorLog (const VectorLog &)=default
 
VectorLogoperator= (const VectorLog &)=default
 
 VectorLog (VectorLog &&)=default
 
VectorLogoperator= (VectorLog &&)=default
 

Static Public Attributes

static constexpr int64_t kDefaultCapacity = 1000
 The default capacity of vector log allocation, expressed as a number of samples. More...
 

Constructor & Destructor Documentation

◆ VectorLog() [1/3]

VectorLog ( const VectorLog< T > &  )
default

◆ VectorLog() [2/3]

VectorLog ( VectorLog< T > &&  )
default

◆ VectorLog() [3/3]

VectorLog ( int  input_size)
explicit

Constructs the vector log.

Parameters
input_sizeDimension of the per-time step data set.

Member Function Documentation

◆ AddData()

void AddData ( const T &  time,
const VectorX< T > &  sample 
)

Adds a sample to the data set with the associated time value.

The new sample and time are added to the end of the log. No constraints are imposed on the values oftime or sample.

Parameters
timeThe time value for this sample.
sampleA vector of data of the declared size for this log.

◆ Clear()

void Clear ( )

Clears the logged data.

◆ data()

Eigen::Block<const MatrixX<T>, Eigen::Dynamic, Eigen::Dynamic, true > data ( ) const

Accesses the logged data.

The InnerPanel parameter of the return type indicates that the compiler can assume aligned access to the data.

◆ get_input_size()

int64_t get_input_size ( ) const

Reports the size of the log's input vector.

◆ num_samples()

int num_samples ( ) const

Returns the number of samples taken since construction or last Clear().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ Reserve()

void Reserve ( int64_t  capacity)

Reserve storage for at least capacity samples.

At construction, there will be at least kDefaultCapacity; use this method to reserve more.

◆ sample_times()

Eigen::VectorBlock<const VectorX<T> > sample_times ( ) const

Accesses the logged time stamps.

Member Data Documentation

◆ kDefaultCapacity

constexpr int64_t kDefaultCapacity = 1000
static

The default capacity of vector log allocation, expressed as a number of samples.

Chosen to be large enough that most systems won't need to allocate during simulation advance steps.


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