Class StateObserver

Inheritance Relationships

Derived Types

Class Documentation

class StateObserver

A generic state observer class for linear systems.

The StateObserver class provides methods for initializing and updating the state of a linear system observer defined by state-space matrices (A, B, C, D) and an initial state vector.

Subclassed by state_observer::KalmanFilter, state_observer::Luenberger

Public Functions

StateObserver(const Eigen::MatrixXd &A, const Eigen::MatrixXd &B, const Eigen::MatrixXd &C, const Eigen::MatrixXd &D, const Eigen::VectorXd &initial_state)

Constructor with full state-space matrices and initial state.

Parameters:
  • A – State transition matrix (n x n).

  • B – Input matrix (n x p).

  • C – Output matrix (q x n).

  • D – Feedthrough matrix (q x p).

  • initial_state – Initial state vector (n x 1).

Throws:

std::invalid_argument – if dimensions are inconsistent.

StateObserver(const Eigen::MatrixXd &A, const Eigen::MatrixXd &B, const Eigen::MatrixXd &C, const Eigen::VectorXd &initial_state)

Constructor without feedthrough matrix D.

Parameters:
  • A – State transition matrix (n x n).

  • B – Input matrix (n x p).

  • C – Output matrix (q x n).

  • initial_state – Initial state vector (n x 1).

Throws:

std::invalid_argument – if dimensions are inconsistent.

StateObserver(const Eigen::MatrixXd &A, const Eigen::MatrixXd &B, const Eigen::MatrixXd &C)

Constructor without initial state and feedthrough matrix D.

Parameters:
  • A – State transition matrix (n x n).

  • B – Input matrix (n x p).

  • C – Output matrix (q x n).

Throws:

std::invalid_argument – if dimensions are inconsistent.

inline StateObserver()

Default constructor.

inline ~StateObserver()
inline virtual void set_parameters(const StateObserverParam::SharedPtr state_observer_params)

Set the parameters of the state observer.

Parameters:

state_observer_params – Shared pointer to StateObserverParam.

void initialize(const Eigen::VectorXd &initial_state)

Initialize the state observer with an initial state.

Parameters:

initial_state – Initial state vector (n x 1).

Throws:

std::invalid_argument – if initial_state size is incorrect.

virtual Eigen::VectorXd open_loop_update()

Perform an open-loop update of the observer.

Updates the state x_ using the state transition matrix A_ without considering any input or measurement.

Returns:

Updated output vector y_.

virtual Eigen::MatrixXd update(const Eigen::VectorXd &measurement) = 0

Update the observer with a measurement.

Parameters:

measurement – Measurement vector.

Returns:

Updated state estimate.

virtual Eigen::MatrixXd update(const Eigen::VectorXd &measurement, const Eigen::VectorXd &input) = 0

Update the observer with a measurement and input.

Parameters:
  • measurement – Measurement vector.

  • input – Input vector.

Returns:

Updated state estimate.

inline Eigen::VectorXd get_state() const

Get the current state estimate.

Returns:

Current state vector x_.

inline Eigen::VectorXd get_output() const

Get the current output estimate.

Returns:

Current output vector y_.

inline bool is_initialized() const
inline virtual Eigen::VectorXd get_state_variance()

Get the variance of the state estimate.

Throws:

std::runtime_error – if not implemented.

Returns:

State variance vector.

void set_state_transition_matrix(const Eigen::MatrixXd &A)
inline Eigen::MatrixXd get_A() const
inline Eigen::MatrixXd get_B() const
inline Eigen::MatrixXd get_C() const
inline Eigen::MatrixXd get_D() const
inline Eigen::VectorXd get_initial_state() const

Protected Functions

void dimensions_check(const Eigen::MatrixXd &A, const Eigen::MatrixXd &B, const Eigen::MatrixXd &C, const Eigen::MatrixXd &D, const Eigen::VectorXd &initial_state)

Protected Attributes

Eigen::MatrixXd A_
Eigen::MatrixXd B_
Eigen::MatrixXd C_
Eigen::MatrixXd D_
Eigen::VectorXd x_
Eigen::VectorXd y_
bool initialized_ = false