Skip to main content

StateEstimation::CompositeFeatureExtractor

StateEstimation::CompositeFeatureExtractor

Feature extractor that chains multiple extractors together. More…

#include <CompositeFeatureExtractor.hpp>

Inherits from StateEstimation::IFeatureExtractor< DataType >

Public Classes

Name
struct CrossCovarianceConfig
Configuration for cross-feature covariance in initial state.

Public Functions

Name
CompositeFeatureExtractor() =default
Construct an empty composite extractor.
CompositeFeatureExtractor(std::vector< std::unique_ptr< IFeatureExtractor< DataType > > > extractors)
Construct a composite extractor from a list of extractors.
void addExtractor(std::unique_ptr< IFeatureExtractor< DataType > > extractor)
Add a feature extractor to the chain.
virtual Eigen::VectorXd getFilterFeatures(DataType const & data) const override
Extract concatenated filter features from all extractors.
virtual FeatureCache getAllFeatures(DataType const & data) const override
Extract all features from all extractors.
virtual std::string getFilterFeatureName() const override
Get the name identifier for composite filter features.
virtual FilterState getInitialState(DataType const & data) const override
Create initial filter state from first observation.
virtual std::unique_ptr< IFeatureExtractor< DataType > > clone() const override
Clone this composite extractor.
size_t getExtractorCount() const
Get the number of extractors in this composite.
virtual FeatureMetadata getMetadata() const override
Get metadata for the composite feature.
std::vector< FeatureMetadata > getChildMetadata() const
Get metadata for all child extractors.
void setCrossCovarianceConfig(CrossCovarianceConfig config)
Set cross-feature covariance configuration.
FilterState getInitialStateWithCrossCovariance(DataType const & data) const
Create initial filter state with optional cross-feature covariance.

Additional inherited members

Public Functions inherited from StateEstimation::IFeatureExtractor< DataType >

Name
virtual ~IFeatureExtractor() =default

Detailed Description

template <typename DataType >
class StateEstimation::CompositeFeatureExtractor;

Feature extractor that chains multiple extractors together.

Template Parameters:

  • DataType The raw data type to extract features from (e.g., Line2D)

This extractor allows combining multiple feature extractors to produce a concatenated feature vector. The extractors are applied in the order they are added, and their outputs are concatenated together.

The composite respects each feature’s temporal behavior metadata:

  • KINEMATIC_2D features: 2D measurement → 4D state (position + velocity)
  • STATIC features: 1D measurement → 1D state (no velocity)
  • SCALAR_DYNAMIC features: 1D measurement → 2D state (value + derivative)

Example: Combining centroid (KINEMATIC_2D) + length (STATIC): Measurements: [x_centroid, y_centroid, length] (3D) State: [x, y, vx, vy, length] (5D)

The initial state is constructed by concatenating the states from each extractor and combining their covariances into a block-diagonal matrix.

Public Functions Documentation

function CompositeFeatureExtractor

CompositeFeatureExtractor() =default

Construct an empty composite extractor.

function CompositeFeatureExtractor

inline explicit CompositeFeatureExtractor(
    std::vector< std::unique_ptr< IFeatureExtractor< DataType > > > extractors
)

Construct a composite extractor from a list of extractors.

Parameters:

  • extractors Vector of unique_ptrs to feature extractors (ownership transferred)

function addExtractor

inline void addExtractor(
    std::unique_ptr< IFeatureExtractor< DataType > > extractor
)

Add a feature extractor to the chain.

Parameters:

  • extractor Unique_ptr to the extractor to add (ownership transferred)

Extractors are applied in the order they are added.

function getFilterFeatures

inline virtual Eigen::VectorXd getFilterFeatures(
    DataType const & data
) const override

Extract concatenated filter features from all extractors.

Parameters:

  • data The raw data object to extract features from

Return: Concatenated feature vector from all extractors

Reimplements: StateEstimation::IFeatureExtractor::getFilterFeatures

Applies each extractor in order and concatenates their outputs.

function getAllFeatures

inline virtual FeatureCache getAllFeatures(
    DataType const & data
) const override

Extract all features from all extractors.

Parameters:

  • data The raw data object to extract features from

Return: FeatureCache with all features from all extractors

Reimplements: StateEstimation::IFeatureExtractor::getAllFeatures

Creates a unified cache with features from all extractors. The composite feature is stored under “composite_features”. Individual extractor features are also stored under their original names.

function getFilterFeatureName

inline virtual std::string getFilterFeatureName() const override

Get the name identifier for composite filter features.

Return: “composite_features”

Reimplements: StateEstimation::IFeatureExtractor::getFilterFeatureName

function getInitialState

inline virtual FilterState getInitialState(
    DataType const & data
) const override

Create initial filter state from first observation.

Parameters:

  • data The raw data object to initialize from

Return: FilterState with concatenated state and block-diagonal covariance

Reimplements: StateEstimation::IFeatureExtractor::getInitialState

Concatenates the initial states from all extractors and creates a block-diagonal covariance matrix.

Example with 2 extractors (each 4D state: [x, y, vx, vy]): Result state: [x1, y1, vx1, vy1, x2, y2, vx2, vy2] (8D) Result covariance: Block diagonal with 4×4 blocks from each extractor

function clone

inline virtual std::unique_ptr< IFeatureExtractor< DataType > > clone() const override

Clone this composite extractor.

Return: A unique_ptr to a copy of this extractor

Reimplements: StateEstimation::IFeatureExtractor::clone

Creates a deep copy with cloned versions of all child extractors.

function getExtractorCount

inline size_t getExtractorCount() const

Get the number of extractors in this composite.

Return: Number of child extractors

function getMetadata

inline virtual FeatureMetadata getMetadata() const override

Get metadata for the composite feature.

Return: FeatureMetadata describing the composite

Reimplements: StateEstimation::IFeatureExtractor::getMetadata

Creates aggregate metadata by combining information from all child extractors. The measurement size is the sum of all child measurement sizes. The state size is the sum of all child state sizes. Type is marked as CUSTOM since it’s a composition of multiple types.

function getChildMetadata

inline std::vector< FeatureMetadata > getChildMetadata() const

Get metadata for all child extractors.

Return: Vector of metadata from each child extractor in order

Useful for building Kalman matrices with proper structure.

function setCrossCovarianceConfig

inline void setCrossCovarianceConfig(
    CrossCovarianceConfig config
)

Set cross-feature covariance configuration.

Parameters:

  • config Cross-covariance configuration

This allows the initial state covariance to include off-diagonal terms modeling known correlations between features.

Example: If position (feature 0) affects measured length (feature 2): config.feature_correlations[{0, 2}] = 0.3; // 30% correlation

function getInitialStateWithCrossCovariance

inline FilterState getInitialStateWithCrossCovariance(
    DataType const & data
) const

Create initial filter state with optional cross-feature covariance.

Parameters:

  • data The raw data object to initialize from

Return: FilterState with full covariance (including off-diagonal terms)

Extends the base implementation to add cross-feature covariance terms based on the configured correlations. This allows modeling cases where features are statistically dependent, such as when camera clipping causes measured length to correlate with position.


Updated on 2026-11-13 at 20:25:41 +0000