signals-cpp
Loading...
Searching...
No Matches
Signal< T, BaseSignalSpec, TangentSignalSpec > Class Template Reference

Template class for time-series signals with interpolation, extrapolation, and derivative capabilities. More...

#include <Signal.h>

Classes

struct  SignalDP
 Data point structure storing time, value, and derivative. More...
 

Public Types

using BaseType = typename BaseSignalSpec::Type
 
using TangentType = typename TangentSignalSpec::Type
 

Public Member Functions

 Signal ()
 Default constructor initializing with LINEAR interpolation, ZEROS extrapolation, and DIRTY derivative.
 
 Signal (const Signal &other)
 Copy constructor.
 
Signal< T, TangentSignalSpec, TangentSignalSpec > dotSignal ()
 Create a new signal representing the time derivative of this signal.
 
double t () const
 Get the current time of the signal.
 
BaseType operator() () const
 Get the current signal value.
 
TangentType dot () const
 Get the current time derivative of the signal.
 
BaseType operator() (const double &t) const
 Get the signal value at a specific time using interpolation/extrapolation.
 
TangentType dot (const double &t) const
 Get the signal derivative at a specific time using interpolation/extrapolation.
 
std::vector< BaseTypeoperator() (const std::vector< double > &t) const
 Get signal values at multiple time points.
 
std::vector< TangentTypedot (const std::vector< double > &t) const
 Get signal derivatives at multiple time points.
 
void setInterpolationMethod (InterpolationMethod method)
 Set the interpolation method for this signal.
 
void setExtrapolationMethod (ExtrapolationMethod method)
 Set the extrapolation method for this signal.
 
void setDerivativeMethod (DerivativeMethod method)
 Set the derivative computation method for this signal.
 
void reset ()
 Reset the signal to initial state, clearing all history.
 
bool update (const double &_t, const BaseType &_x, bool insertHistory=false)
 Update the signal with a new value at a given time, computing derivative automatically.
 
bool update (const double &_t, const BaseType &_x, const TangentType &_xdot, bool insertHistory=false)
 Update the signal with a new value and derivative at a given time.
 
bool update (const std::vector< double > &_tHistory, const std::vector< BaseType > &_xHistory)
 Update the signal with a history of values, computing derivatives automatically.
 
bool update (const std::vector< double > &_tHistory, const std::vector< BaseType > &_xHistory, const std::vector< TangentType > &_xdotHistory)
 Update the signal with a history of values and derivatives.
 

Static Public Member Functions

static BaseType baseZero ()
 Get the zero (identity) value for the base signal type.
 
static TangentType tangentZero ()
 Get the zero (identity) value for the tangent signal type.
 
static T baseNorm (const BaseType &x)
 Compute the norm of a base signal value.
 
static T tangentNorm (const TangentType &x)
 Compute the norm of a tangent signal value.
 

Public Attributes

struct { 
 
SignalDPComparator 
 Comparator for sorting signal data points by time.
 
InterpolationMethod interpolationMethod
 
ExtrapolationMethod extrapolationMethod
 
DerivativeMethod derivativeMethod
 

Friends

template<typename S, typename BSS, typename TSS>
Signal< S, BSS, TSS > operator+ (const Signal< S, BSS, TSS > &l, const Signal< S, TSS, TSS > &r)
 
template<typename S, typename BSS, typename TSS>
Signal< S, TSS, TSS > operator- (const Signal< S, BSS, TSS > &l, const Signal< S, BSS, TSS > &r)
 
template<typename S, typename BSS, typename TSS>
Signal< S, BSS, TSS > operator* (const double &l, const Signal< S, BSS, TSS > &r)
 
template<typename S, typename BSS, typename TSS>
Signal< S, BSS, TSS > operator* (const Signal< S, BSS, TSS > &l, const double &r)
 

Detailed Description

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
class Signal< T, BaseSignalSpec, TangentSignalSpec >

Template class for time-series signals with interpolation, extrapolation, and derivative capabilities.

The Signal class represents a time-varying signal that stores both the value and its time derivative. It supports various interpolation methods for querying values at arbitrary time points, configurable extrapolation behavior outside the defined time range, and automatic derivative computation.

Template Parameters
BaseSignalSpecType specification for the signal values (can be scalar, vector, or manifold types).
TangentSignalSpecType specification for the signal derivatives (typically vector types).

Example usage:

ScalardSignal mySignal;
mySignal.update(1.0, 5.0, true); // time=1.0, value=5.0, store in history
mySignal.update(2.0, 7.0, true); // time=2.0, value=7.0, store in history
double interpValue = mySignal(1.5); // Query interpolated value at t=1.5
ScalarSignal< double > ScalardSignal
Definition Signal.h:939
@ LINEAR
Definition Signal.h:19
void setInterpolationMethod(InterpolationMethod method)
Set the interpolation method for this signal.
Definition Signal.h:228
bool update(const double &_t, const BaseType &_x, bool insertHistory=false)
Update the signal with a new value at a given time, computing derivative automatically.
Definition Signal.h:270

Member Typedef Documentation

◆ BaseType

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
using Signal< T, BaseSignalSpec, TangentSignalSpec >::BaseType = typename BaseSignalSpec::Type

◆ TangentType

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
using Signal< T, BaseSignalSpec, TangentSignalSpec >::TangentType = typename TangentSignalSpec::Type

Constructor & Destructor Documentation

◆ Signal() [1/2]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
Signal< T, BaseSignalSpec, TangentSignalSpec >::Signal ( )
inline

Default constructor initializing with LINEAR interpolation, ZEROS extrapolation, and DIRTY derivative.

◆ Signal() [2/2]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
Signal< T, BaseSignalSpec, TangentSignalSpec >::Signal ( const Signal< T, BaseSignalSpec, TangentSignalSpec > & other)
inline

Copy constructor.

Parameters
otherThe signal to copy from.

Member Function Documentation

◆ baseNorm()

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
static T Signal< T, BaseSignalSpec, TangentSignalSpec >::baseNorm ( const BaseType & x)
inlinestatic

Compute the norm of a base signal value.

Parameters
xThe base signal value.
Returns
The norm (magnitude) of the value.

◆ baseZero()

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
static BaseType Signal< T, BaseSignalSpec, TangentSignalSpec >::baseZero ( )
inlinestatic

Get the zero (identity) value for the base signal type.

Returns
Zero/identity element for the base type.

◆ dot() [1/3]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
TangentType Signal< T, BaseSignalSpec, TangentSignalSpec >::dot ( ) const
inline

Get the current time derivative of the signal.

Returns
The current derivative value.

◆ dot() [2/3]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
TangentType Signal< T, BaseSignalSpec, TangentSignalSpec >::dot ( const double & t) const
inline

Get the signal derivative at a specific time using interpolation/extrapolation.

Parameters
tThe time to query.
Returns
The interpolated/extrapolated derivative value at time t.

◆ dot() [3/3]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
std::vector< TangentType > Signal< T, BaseSignalSpec, TangentSignalSpec >::dot ( const std::vector< double > & t) const
inline

Get signal derivatives at multiple time points.

Parameters
tVector of time points to query.
Returns
Vector of interpolated/extrapolated derivative values.

◆ dotSignal()

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
Signal< T, TangentSignalSpec, TangentSignalSpec > Signal< T, BaseSignalSpec, TangentSignalSpec >::dotSignal ( )
inline

Create a new signal representing the time derivative of this signal.

Returns
A signal containing the derivative values from this signal's history.

◆ operator()() [1/3]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
BaseType Signal< T, BaseSignalSpec, TangentSignalSpec >::operator() ( ) const
inline

Get the current signal value.

Returns
The current value.

◆ operator()() [2/3]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
BaseType Signal< T, BaseSignalSpec, TangentSignalSpec >::operator() ( const double & t) const
inline

Get the signal value at a specific time using interpolation/extrapolation.

Parameters
tThe time to query.
Returns
The interpolated/extrapolated signal value at time t.

◆ operator()() [3/3]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
std::vector< BaseType > Signal< T, BaseSignalSpec, TangentSignalSpec >::operator() ( const std::vector< double > & t) const
inline

Get signal values at multiple time points.

Parameters
tVector of time points to query.
Returns
Vector of interpolated/extrapolated signal values.

◆ reset()

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
void Signal< T, BaseSignalSpec, TangentSignalSpec >::reset ( )
inline

Reset the signal to initial state, clearing all history.

◆ setDerivativeMethod()

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
void Signal< T, BaseSignalSpec, TangentSignalSpec >::setDerivativeMethod ( DerivativeMethod method)
inline

Set the derivative computation method for this signal.

Parameters
methodThe derivative method to use.

◆ setExtrapolationMethod()

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
void Signal< T, BaseSignalSpec, TangentSignalSpec >::setExtrapolationMethod ( ExtrapolationMethod method)
inline

Set the extrapolation method for this signal.

Parameters
methodThe extrapolation method to use.

◆ setInterpolationMethod()

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
void Signal< T, BaseSignalSpec, TangentSignalSpec >::setInterpolationMethod ( InterpolationMethod method)
inline

Set the interpolation method for this signal.

Parameters
methodThe interpolation method to use.

◆ t()

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
double Signal< T, BaseSignalSpec, TangentSignalSpec >::t ( ) const
inline

Get the current time of the signal.

Returns
The current time value.

◆ tangentNorm()

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
static T Signal< T, BaseSignalSpec, TangentSignalSpec >::tangentNorm ( const TangentType & x)
inlinestatic

Compute the norm of a tangent signal value.

Parameters
xThe tangent signal value.
Returns
The norm (magnitude) of the value.

◆ tangentZero()

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
static TangentType Signal< T, BaseSignalSpec, TangentSignalSpec >::tangentZero ( )
inlinestatic

Get the zero (identity) value for the tangent signal type.

Returns
Zero/identity element for the tangent type.

◆ update() [1/4]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
bool Signal< T, BaseSignalSpec, TangentSignalSpec >::update ( const double & _t,
const BaseType & _x,
bool insertHistory = false )
inline

Update the signal with a new value at a given time, computing derivative automatically.

Parameters
_tThe time of the new data point.
_xThe value at time _t.
insertHistoryWhether to store this data point in history for interpolation.
Returns
true if update was successful, false otherwise.

◆ update() [2/4]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
bool Signal< T, BaseSignalSpec, TangentSignalSpec >::update ( const double & _t,
const BaseType & _x,
const TangentType & _xdot,
bool insertHistory = false )
inline

Update the signal with a new value and derivative at a given time.

Parameters
_tThe time of the new data point.
_xThe value at time _t.
_xdotThe derivative at time _t.
insertHistoryWhether to store this data point in history for interpolation.
Returns
true if update was successful, false otherwise.

◆ update() [3/4]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
bool Signal< T, BaseSignalSpec, TangentSignalSpec >::update ( const std::vector< double > & _tHistory,
const std::vector< BaseType > & _xHistory )
inline

Update the signal with a history of values, computing derivatives automatically.

Parameters
_tHistoryVector of time points.
_xHistoryVector of values corresponding to each time point.
Returns
true if update was successful, false otherwise.

◆ update() [4/4]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
bool Signal< T, BaseSignalSpec, TangentSignalSpec >::update ( const std::vector< double > & _tHistory,
const std::vector< BaseType > & _xHistory,
const std::vector< TangentType > & _xdotHistory )
inline

Update the signal with a history of values and derivatives.

Parameters
_tHistoryVector of time points.
_xHistoryVector of values corresponding to each time point.
_xdotHistoryVector of derivatives corresponding to each time point.
Returns
true if update was successful, false if vector sizes don't match.

Friends And Related Symbol Documentation

◆ operator* [1/2]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
template<typename S, typename BSS, typename TSS>
Signal< S, BSS, TSS > operator* ( const double & l,
const Signal< S, BSS, TSS > & r )
friend

◆ operator* [2/2]

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
template<typename S, typename BSS, typename TSS>
Signal< S, BSS, TSS > operator* ( const Signal< S, BSS, TSS > & l,
const double & r )
friend

◆ operator+

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
template<typename S, typename BSS, typename TSS>
Signal< S, BSS, TSS > operator+ ( const Signal< S, BSS, TSS > & l,
const Signal< S, TSS, TSS > & r )
friend

◆ operator-

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
template<typename S, typename BSS, typename TSS>
Signal< S, TSS, TSS > operator- ( const Signal< S, BSS, TSS > & l,
const Signal< S, BSS, TSS > & r )
friend

Member Data Documentation

◆ derivativeMethod

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
DerivativeMethod Signal< T, BaseSignalSpec, TangentSignalSpec >::derivativeMethod

Current derivative computation method.

◆ extrapolationMethod

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
ExtrapolationMethod Signal< T, BaseSignalSpec, TangentSignalSpec >::extrapolationMethod

Current extrapolation method.

◆ interpolationMethod

template<typename T, typename BaseSignalSpec, typename TangentSignalSpec>
InterpolationMethod Signal< T, BaseSignalSpec, TangentSignalSpec >::interpolationMethod

Current interpolation method.

◆ [struct]

struct { ... } Signal< T, BaseSignalSpec, TangentSignalSpec >::SignalDPComparator

Comparator for sorting signal data points by time.


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