Controlpp
Loading...
Searching...
No Matches
controlpp Namespace Reference

The main namespace for the Control++ library. More...

Namespaces

namespace  polynom
 
namespace  tf
 
namespace  timevar
 Namespace that contains sample-time variant controllers

 

Classes

class  Bode
 Frequency response data. More...
 
class  ComplexTimeSeries
 
struct  ContinuousGeneralisedPlant
 A continuous generalised plant model. More...
 
class  ContinuousStateSpace
 
class  ContinuousTransferFunction
 Continuous transfer functions in the s lapace plain. More...
 
class  DiscreteStateSpace
 Matrix (A, B, C, D) representation of a linear time invariant system. More...
 
class  DiscreteTransferFunction
 Continuous transfer functions in the s lapace plain. More...
 
class  DssFilter
 Controller from a discrete state space. More...
 
class  DtfEstimator
 Estimates a discrete transfer function from online data points. More...
 
class  DtfFilter
 Controller from a discrete transfer function. More...
 
struct  ExpmPadeParams
 Pade for the scaled pade matrix exponential. More...
 
class  FixedPolynom
 Describes a mathematical polynomial of fixed size. More...
 
class  FixedRationalPolynom
 Fixed sized polynomial. More...
 
class  KalmanFilter
 Kalman filter. More...
 
class  Polynom
 Describes a mathematical polynomial. More...
 
class  ReccursiveLeastSquares
 Calculates the recursive least square for online parameter estimation. More...
 
class  ReccursiveLeastSquares< T, NParams, 1 >
 Calculates the recursive least square for online parameter estimation. More...
 
class  SineGenerator
 A lite weight incremental sine generator. More...
 
class  StateSpace
 Base class for the state space representation of a linear time invariant system. More...
 
class  TimeSeries
 Contiains time and values pairs. More...
 
class  TransferFunction
 

Enumerations

enum class  EBodeCsvReadError { CouldNotFindFrequencyVector , CouldNotFindAmplitudeVectors }
 Error cases for reading/parsing bode data from CSV formated data. More...
 
enum class  EFrequencyInterpretation { AutoHz , AutoRad , ForceHz , ForceRad }
 Enum that determines how frequency data will be interpreted when reading CSV data. More...
 
enum class  EMagnitudeInterpretation { Auto , ForceAbs , ForceDB }
 Enum that determines how frequency data will be interpreted when reading CSV data. More...
 
enum class  EPhaseInterpretation { AutoRad , AutoDeg , ForceRad , ForceDeg }
 Enum that determines how phase data will be interpreted when reading CSV data. More...
 
enum class  dft_estimate_error { data_ranges_different_lenth , data_range_too_small }
 
enum class  EDiscretisation { zero_order_hold , tustin }
 

Functions

std::ostream & operator<< (std::ostream &stream, EBodeCsvReadError val)
 
tl::expected< Bode< double >, std::variant< EBodeCsvReadError, csvd::ReadError > > read_bode_from_csv (std::istream &stream, const csvd::Settings &csv_settings=csvd::Settings(), EFrequencyInterpretation freq_interp=EFrequencyInterpretation::AutoHz, EMagnitudeInterpretation mag_interp=EMagnitudeInterpretation::Auto, EPhaseInterpretation phase_interp=EPhaseInterpretation::AutoDeg)
 Loads bode data from csv data.
 
template<class Itr , class T >
std::optional< std::pair< Itr, Itr > > find_enclosing (Itr first, Itr last, const T &v)
 Finds elements in a range that enclose v.
 
template<class T , int Size = Eigen::Dynamic>
std::optional< std::pair< const T *, const T * > > find_enclosing (const Eigen::Vector< T, Size > &range, const T &v)
 Finds elements in a range that enclose v.
 
template<class Iterator , class T >
void shift_up (Iterator first, Iterator last, const T &v0=T(0))
 Shifts the values in a range up by one position and inserts a new value (copy operation) at the beginning of the range.
 
template<class Iterator , class T >
void shift_up (Iterator first, Iterator last, T &&v0=T(0))
 Shifts the values in a range up by one position and inserts a new value (move operation) at the beginning of the range.
 
template<class T , int NStates>
TimeSeries< T > step (const DiscreteStateSpace< T, NStates, 1, 1 > &dss, double Ts, double simulation_time)
 calculates the step response of a system
 
template<class T , int NumOrder, int DenOrder>
std::tuple< T, T > slowest_fastest_frequencies (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf, T alternative=static_cast< T >(1))
 Calculates the slowest (lowest) and fastest (highest) frequencies of a continuous transfer function.
 
template<class T , int NumOrder, int DenOrder>
TimeSeries< T > step (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf, const T &sample_time, const T &simulation_time)
 
template<class T , int NumOrder, int DenOrder>
TimeSeries< T > step (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf)
 
template<class T >
Bode< T > prewarp_tustin (const Bode< T > &bode, const T &Ts)
 Prewarps the frequency axis of a bode plot for tustin discretisation.
 
template<class T >
Bode< T > unwarp_tustin (const Bode< T > &bode, const T &Ts)
 Unwarps the frequency axis of a bode plot for tustin discretisation.
 
template<class T >
const Eigen::Vector< T, Eigen::Dynamic > & frequencies (const Bode< T > &bode)
 Converts and returns the frequency vector in rad.
 
template<class T >
Eigen::Vector< T, Eigen::Dynamic > frequencies_hz (const Bode< T > &bode)
 Converts and returns the frequency vector in Hz.
 
template<class T >
Eigen::Vector< T, Eigen::Dynamic > real (const Bode< T > &bode)
 Converts and returns the frequency vector in rad/s.
 
template<class T >
Eigen::Vector< T, Eigen::Dynamic > imag (const Bode< T > &bode)
 Converts and returns the frequency vector in rad/s.
 
template<class T >
const Eigen::Vector< T, Eigen::Dynamic > & values (const Bode< T > &bode)
 Returns the complex values of the bode data.
 
template<class T >
Eigen::Vector< T, Eigen::Dynamic > magnitudes (const Bode< T > &bode)
 Creates a vector containing the absolute magnitudes.
 
template<class T >
Eigen::Vector< T, Eigen::Dynamic > magnitudes_dB (const Bode< T > &bode)
 Creates a vector of magnitudes in dB.
 
template<class T >
Eigen::Vector< T, Eigen::Dynamic > phases (const Bode< T > &bode)
 Creates a vector of phases in rad.
 
template<class T >
Eigen::Vector< T, Eigen::Dynamic > phases_deg (const Bode< T > &bode)
 Creates a vector of phases in degree.
 
template<class T >
TimeSeries< T > impulse (const Bode< T > &bode, const T &time_step, const T &simulation_time)
 Calculates the impulse-response of frequency data.
 
template<class T >
TimeSeries< T > impulse (const Bode< T > &bode)
 Calculates the time-series of a frequency response.
 
template<class T >
void integrate (TimeSeries< T > &out, const TimeSeries< T > &in, const T &v0=T(0))
 Integrates the time series and writes it to out.
 
template<class T >
TimeSeries< T > integrate (const TimeSeries< T > &in, const T &v0=T(0))
 Integrates the time series and writes it to out.
 
template<class T >
TimeSeries< T > step (const Bode< T > &bode)
 Calculates the step response time-value pairs from frequency-value data.
 
template<class T >
TimeSeries< T > step (const Bode< T > &bode, const T &time_step, const T &simulation_time)
 Calculates the step response time-value pairs from frequency-value data.
 
template<class T >
Bode< T > operator+ (const Bode< T > &l, const Bode< T > &r)
 Adds two bode plots together.
 
template<class T , std::convertible_to< T > T2>
Bode< T > operator+ (const Bode< T > &l, const T2 &r)
 Adds a bode plot and a scalar value together.
 
template<class T , std::convertible_to< T > T2>
Bode< T > operator+ (const T2 &l, const Bode< T > &r)
 Adds a scalar value and a bode plot together.
 
template<class T >
Bode< T > operator+ (const Bode< T > &b)
 Negates the bode plot values.
 
template<class T , int NumOrder, int DenOrder>
Bode< T > operator+ (const Bode< T > &l, const ContinuousTransferFunction< T, NumOrder, DenOrder > &r)
 Adds a bode plot and a continuous transfer function together.
 
template<class T , int NumOrder, int DenOrder>
Bode< T > operator+ (const ContinuousTransferFunction< T, NumOrder, DenOrder > &l, const Bode< T > &r)
 Adds a continuous transfer function and a bode plot together.
 
template<class T >
Bode< T > operator- (const Bode< T > &l, const Bode< T > &r)
 
template<class T , std::convertible_to< T > T2>
Bode< T > operator- (const Bode< T > &l, const T2 &r)
 
template<class T , std::convertible_to< T > T2>
Bode< T > operator- (const T2 &l, const Bode< T > &r)
 
template<class T >
Bode< T > operator- (const Bode< T > &b)
 
template<class T , int NumOrder, int DenOrder>
Bode< T > operator- (const Bode< T > &l, const ContinuousTransferFunction< T, NumOrder, DenOrder > &r)
 
template<class T , int NumOrder, int DenOrder>
Bode< T > operator- (const ContinuousTransferFunction< T, NumOrder, DenOrder > &l, const Bode< T > &r)
 
template<class T >
Bode< T > operator* (const Bode< T > &l, const Bode< T > &r)
 
template<class T , std::convertible_to< T > T2>
Bode< T > operator* (const Bode< T > &l, const T2 &r)
 
template<class T , std::convertible_to< T > T2>
Bode< T > operator* (const T2 &l, const Bode< T > &r)
 
template<class T , int NumOrder, int DenOrder>
Bode< T > operator* (const Bode< T > &l, const ContinuousTransferFunction< T, NumOrder, DenOrder > &r)
 
template<class T , int NumOrder, int DenOrder>
Bode< T > operator* (const ContinuousTransferFunction< T, NumOrder, DenOrder > &l, const Bode< T > &r)
 
template<class T >
Bode< T > operator/ (const Bode< T > &l, const Bode< T > &r)
 TODO: make it also work for bode that have different frequency vectors.
 
template<class T , std::convertible_to< T > T2>
Bode< T > operator/ (const Bode< T > &l, const T2 &r)
 
template<class T , std::convertible_to< T > T2>
Bode< T > operator/ (const T2 &l, const Bode< T > &r)
 
template<class T , int NumOrder, int DenOrder>
Bode< T > operator/ (const Bode< T > &l, const ContinuousTransferFunction< T, NumOrder, DenOrder > &r)
 
template<class T , int NumOrder, int DenOrder>
Bode< T > operator/ (const ContinuousTransferFunction< T, NumOrder, DenOrder > &l, const Bode< T > &r)
 
template<class T , int NumOrder, int DenOrder>
Bode< T > bode (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf, const Eigen::Vector< T, Eigen::Dynamic > &freqs)
 Calculates the bode response for a pre defined frequency (rad/s) vector.
 
template<class T , int NumOrder, int DenOrder>
Bode< T > bode (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf, Eigen::Vector< T, Eigen::Dynamic > &&freqs)
 
template<class T , int NumOrder, int DenOrder>
Bode< T > bode_hz (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf, const Eigen::Vector< T, Eigen::Dynamic > &freqs_Hz)
 Calculates the bode response for a pre defined frequency (Hz) vector.
 
template<class T , int NumOrder, int DenOrder>
Bode< T > bode_hz (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf, Eigen::Vector< T, Eigen::Dynamic > &&freqs_Hz)
 
template<class T , int NumOrder, int DenOrder, std::convertible_to< T > T1, std::convertible_to< T > T2>
Bode< T > bode_hz (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf, const T1 &slowest_freq_Hz, const T2 &fastest_freq_Hz, const int samples_per_decade=100)
 Calculates the bode response of a transfer function.
 
template<class T , int NumOrder, int DenOrder, std::convertible_to< T > T1, std::convertible_to< T > T2>
Bode< T > bode (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf, const T1 &slowest_freq_rad, const T2 &fastest_freq_rad, const int samples_per_decade=100)
 Calculates the bode response of a transfer function.
 
template<class T , int NumOrder, int DenOrder>
Bode< T > bode_hz (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf, const int samples_per_decade=100)
 Calculates the bode response of a transfer function.
 
template<class T , int NumOrder, int DenOrder>
Bode< T > bode (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf, const int samples_per_decade=100)
 Calculates the bode response of a transfer function.
 
template<class T >
void write_csv (std::ostream &stream, const Bode< T > &bode)
 Prints a bode plot to an output stream as a .csv file.
 
template<class T , int NumOrder, int DenOrder>
ContinuousStateSpace< T, DenOrder, 1, 1 > to_continuous_state_space (const TransferFunction< T, NumOrder, DenOrder > &rp)
 constructs a continuous state space function from a rational polynom
 
template<class T , int NumOrder, int DenOrder>
ContinuousStateSpace< T, DenOrder, 1, 1 > to_continuous_state_space (const ContinuousTransferFunction< T, NumOrder, DenOrder > &ctf)
 constructs a continuous state space function from a continuous transfer function
 
template<class T , int NumOrder, int DenOrder>
ContinuousStateSpace< T, DenOrder, 1, 1 > to_state_space (const ContinuousTransferFunction< T, NumOrder, DenOrder > &ctf)
 constructs a continuous state space function from a continuous transfer function
 
template<class T , int states>
ContinuousTransferFunction< T, states+1, states+1 > to_transfer_function (const ContinuousStateSpace< T, states, 1, 1 > &dss)
 Transforms a discrete state space system to a discrete transfer function.
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
auto operator+ (const ContinuousTransferFunction< T, NumOrder1, DenOrder1 > &lhs, const ContinuousTransferFunction< T, NumOrder2, DenOrder2 > &rhs)
 
template<class Tpoly , class Tscalar , int NumOrder, int DenOrder>
auto operator+ (const Tscalar &lhs, const ContinuousTransferFunction< Tpoly, NumOrder, DenOrder > &rhs)
 
template<class Tpoly , class Tscalar , int NumOrder, int DenOrder>
auto operator+ (const ContinuousTransferFunction< Tpoly, NumOrder, DenOrder > &lhs, const Tscalar &rhs)
 
template<class T , int NumOrder, int DenOrder>
ContinuousTransferFunction< T, NumOrder, DenOrder > operator- (const ContinuousTransferFunction< T, NumOrder, DenOrder > &a)
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
auto operator- (const ContinuousTransferFunction< T, NumOrder1, DenOrder1 > &lhs, const ContinuousTransferFunction< T, NumOrder2, DenOrder2 > &rhs)
 
template<class T , class Tscalar , int NumOrder, int DenOrder>
auto operator- (const Tscalar &lhs, const ContinuousTransferFunction< T, NumOrder, DenOrder > &rhs)
 
template<class T , class Tscalar , int NumOrder, int DenOrder>
auto operator- (const ContinuousTransferFunction< T, NumOrder, DenOrder > &lhs, const Tscalar &rhs)
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
auto operator* (const ContinuousTransferFunction< T, NumOrder1, DenOrder1 > &lhs, const ContinuousTransferFunction< T, NumOrder2, DenOrder2 > &rhs)
 
template<class T , class Tscalar , int NumOrder, int DenOrder>
auto operator* (const Tscalar &lhs, const ContinuousTransferFunction< T, NumOrder, DenOrder > &rhs)
 
template<class T , class Tscalar , int NumOrder, int DenOrder>
auto operator* (const ContinuousTransferFunction< T, NumOrder, DenOrder > &lhs, const Tscalar &rhs)
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
auto operator/ (const ContinuousTransferFunction< T, NumOrder1, DenOrder1 > &lhs, const ContinuousTransferFunction< T, NumOrder2, DenOrder2 > &rhs)
 
template<class T , class Tscalar , int NumOrder, int DenOrder>
auto operator/ (const Tscalar &lhs, const ContinuousTransferFunction< T, NumOrder, DenOrder > &rhs)
 
template<class T , class Tscalar , int NumOrder, int DenOrder>
auto operator/ (const ContinuousTransferFunction< T, NumOrder, DenOrder > &lhs, const Tscalar &rhs)
 
template<class T , int NumOrder, int DenOrder>
Eigen::Vector< std::complex< T >, NumOrder > zeros (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf)
 
template<class T , int NumOrder, int DenOrder>
Eigen::Vector< std::complex< T >, DenOrder > poles (const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf)
 
template<class T >
to_hz (const T &radps)
 Converts a number from radiants per second to herz.
 
template<class T , int N>
Eigen::Vector< T, N > to_hz (const Eigen::Vector< T, N > &radps)
 
template<class T >
to_radps (const T &hz)
 Converts a number from herz to radiants per second.
 
template<class T , int N>
Eigen::Vector< T, N > to_radps (const Eigen::Vector< T, N > &hz)
 
template<class T >
to_deg (const T &rad)
 
template<class T , int N>
Eigen::Vector< T, N > to_deg (const Eigen::Vector< T, N > &rad)
 
template<class T >
to_rad (const T &deg)
 
template<class T , int N>
Eigen::Vector< T, N > to_rad (const Eigen::Vector< T, N > &deg)
 
template<class T >
to_dB (const T &value)
 
template<class T >
from_dB (const T &value)
 
template<class T >
prewarp_tustin (const T &omega, const T &Ts)
 Prewarps frequencies for the tustin transformation.
 
template<class T , int N>
Eigen::Vector< T, N > prewarp_tustin (const Eigen::Vector< T, N > &omegas, const T &Ts)
 
template<class T >
unwarp_tustin (const T &omega, const T &Ts)
 provides the inverse to prewarp_tustin:
 
template<class T , int N>
Eigen::Vector< T, N > unwarp_tustin (const Eigen::Vector< T, N > &omegas, const T &Ts)
 
template<class T , int NumOrder, int DenOrder>
requires (NumOrder <= DenOrder)
DiscreteStateSpace< T, DenOrder, 1, 1 > to_discrete_state_space (const TransferFunction< T, NumOrder, DenOrder > &rp)
 constructs a discrete state space function from a rational polynom
 
template<class ValueType , int NumOrder, int DenOrder>
DiscreteStateSpace< ValueType, DenOrder, 1, 1 > to_discrete_state_space (const DiscreteTransferFunction< ValueType, NumOrder, DenOrder > &dtf)
 constructs a continuous state space function from a continuous transfer function
 
template<class ValueType , int NumOrder, int DenOrder>
DiscreteStateSpace< ValueType, DenOrder, 1, 1 > to_state_space (const DiscreteTransferFunction< ValueType, NumOrder, DenOrder > &dtf)
 constructs a continuous state space function from a continuous transfer function
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr auto operator+ (const DiscreteTransferFunction< T, NumOrder1, DenOrder1 > &lhs, const DiscreteTransferFunction< T, NumOrder2, DenOrder2 > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int NumOrder, int DenOrder>
constexpr auto operator+ (const Tscalar &lhs, const DiscreteTransferFunction< Tpoly, NumOrder, DenOrder > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int NumOrder, int DenOrder>
constexpr auto operator+ (const DiscreteTransferFunction< Tpoly, NumOrder, DenOrder > &lhs, const Tscalar &rhs)
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr auto operator- (const DiscreteTransferFunction< T, NumOrder1, DenOrder1 > &lhs, const DiscreteTransferFunction< T, NumOrder2, DenOrder2 > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr auto operator- (const Tscalar &lhs, const DiscreteTransferFunction< T, NumOrder, DenOrder > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr auto operator- (const DiscreteTransferFunction< T, NumOrder, DenOrder > &lhs, const Tscalar &rhs)
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr auto operator* (const DiscreteTransferFunction< T, NumOrder1, DenOrder1 > &lhs, const DiscreteTransferFunction< T, NumOrder2, DenOrder2 > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr auto operator* (const Tscalar &lhs, const DiscreteTransferFunction< T, NumOrder, DenOrder > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr auto operator* (const DiscreteTransferFunction< T, NumOrder, DenOrder > &lhs, const Tscalar &rhs)
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr auto operator/ (const DiscreteTransferFunction< T, NumOrder1, DenOrder1 > &lhs, const DiscreteTransferFunction< T, NumOrder2, DenOrder2 > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr auto operator/ (const Tscalar &lhs, const DiscreteTransferFunction< T, NumOrder, DenOrder > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr auto operator/ (const DiscreteTransferFunction< T, NumOrder, DenOrder > &lhs, const Tscalar &rhs)
 
template<class T , int XRows, int XCols, int XOpt, int XMaxRows, int XMaxCols>
requires ((XRows >= XCols) || (XRows == Eigen::Dynamic) || (XCols == Eigen::Dynamic))
Eigen::Vector< T, XCols > least_squares (const Eigen::Matrix< T, XRows, XCols, XOpt, XMaxRows, XMaxCols > &X, const Eigen::Vector< T, XRows > &y)
 Solves the overdefined system \(y = X p\) for p.
 
std::string_view to_string (dft_estimate_error err)
 
std::ostream & operator<< (std::ostream &stream, dft_estimate_error err)
 
template<class T , int NumOrder, int DenOrder>
requires ((NumOrder != Eigen::Dynamic) && (DenOrder != Eigen::Dynamic))
tl::expected< DiscreteTransferFunction< T, NumOrder, DenOrder >, dft_estimate_errordft_estimate (const Eigen::Vector< T, Eigen::Dynamic > &u, const Eigen::Vector< T, Eigen::Dynamic > &y, const T &regularization=T(0), const DiscreteTransferFunction< T, NumOrder, DenOrder > &hint=DiscreteTransferFunction< T, NumOrder, DenOrder >({T(0)}, {T(1)}))
 Estimates a discrete time transfer function of a specific order for the input (u) and output (y) data pairs.
 
template<class T , int Rows, int Cols, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > expm_taylor (const Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > &x, int n)
 Exponential function with a taylor approximation.
 
template<class T , int Rows, int Cols, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > expm_taylor_scaled (const Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > &M, int taylor_order=8, int scaling=10)
 Calculates the matrix exponent \( \exp{\mathbf{M}} \).
 
template<class T , int N, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, N, N > expm_pade (const Eigen::Matrix< T, N, N, Options, MaxRows, MaxCols > &A, int Order=5)
 Approximates \(\exp{A}\) using a pade fraction.
 
template<class T , int N, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, N, N > expm_pade_scaled (const Eigen::Matrix< T, N, N, Options, MaxRows, MaxCols > &M, int order, int scaling)
 Applies scaling and squaring to the pade approximation of the matrix exponential.
 
template<class T , int N, int Options, int MaxRows, int MaxCols>
ExpmPadeParams expm_pade_params (const Eigen::Matrix< T, N, N, Options, MaxRows, MaxCols > &M)
 Determines the order and scaling factor for the scaled pade approximation of the matrix exponential.
 
template<class T , int N, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, N, N > expm_pade_scaled (const Eigen::Matrix< T, N, N, Options, MaxRows, MaxCols > &M)
 Matrix exponential using a scaled Pade approximation with automatic order and scaling factor determination.
 
template<class T , int N, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, N, N > expm (const Eigen::Matrix< T, N, N, Options, MaxRows, MaxCols > &M)
 Calculates the matrix exponent \( \exp{\mathbf{M}} \).
 
template<class T , int NStates, int NInputs, int NPerfOutputs, int NMeasOutputs, int NDisturbances>
ContinuousStateSpace< T, NStates, NMeasOutputs, NInputs > continous_h2 (const Eigen::Matrix< T, NStates, NStates > &A, const Eigen::Matrix< T, NStates, NDisturbances > &Bw, const Eigen::Matrix< T, NStates, NInputs > &Bu, const Eigen::Matrix< T, NPerfOutputs, NStates > &Cz, const Eigen::Matrix< T, NPerfOutputs, NInputs > &Duz, const Eigen::Matrix< T, NMeasOutputs, NStates > &Cy, const Eigen::Matrix< T, NMeasOutputs, NDisturbances > &Dwy, const Eigen::Matrix< T, NInputs, NInputs > &R, const Eigen::Matrix< T, NMeasOutputs, NMeasOutputs > &S)
 
template<class T , int NStates, int NInputs, int NPerfOutputs, int NMeasOutputs, int NDisturbances>
requires (NInputs>1 && NMeasOutputs>1)
ContinuousStateSpace< T, NStates, NMeasOutputs, NInputs > continous_h2 (const Eigen::Matrix< T, NStates, NStates > &A, const Eigen::Matrix< T, NStates, NDisturbances > &Bw, const Eigen::Matrix< T, NStates, NInputs > &Bu, const Eigen::Matrix< T, NPerfOutputs, NStates > &Cz, const Eigen::Matrix< T, NPerfOutputs, NInputs > &Duz, const Eigen::Matrix< T, NMeasOutputs, NStates > &Cy, const Eigen::Matrix< T, NMeasOutputs, NDisturbances > &Dwy, const Eigen::Vector< T, NInputs > r=Eigen::Vector< T, NInputs >::Zero(), const Eigen::Vector< T, NMeasOutputs > s=Eigen::Vector< T, NMeasOutputs >::Zero())
 An optimal controller for linear time-invariant (LTI) system. It minimizes the H2 norm of the the disturbance input gain to the output.
 
template<class T , int NStates, int NInputs, int NPerfOutputs, int NMeasOutputs, int NDisturbances>
ContinuousStateSpace< T, NStates, NMeasOutputs, NInputs > continous_h2 (const Eigen::Matrix< T, NStates, NStates > &A, const Eigen::Matrix< T, NStates, NDisturbances > &Bw, const Eigen::Matrix< T, NStates, NInputs > &Bu, const Eigen::Matrix< T, NPerfOutputs, NStates > &Cz, const Eigen::Matrix< T, NPerfOutputs, NInputs > &Duz, const Eigen::Matrix< T, NMeasOutputs, NStates > &Cy, const Eigen::Matrix< T, NMeasOutputs, NDisturbances > &Dwy, const T &r_scalar=0, const T &s_scalar=0)
 
template<class T , int NStates, int NInputs = 1, int NPerfOutputs = 1, int NMeasOutputs = 1, int NDisturbances = 1>
std::ostream & operator<< (std::ostream &stream, const ContinuousGeneralisedPlant< T, NStates, NInputs, NPerfOutputs, NMeasOutputs, NDisturbances > &G)
 
template<class T , int NStates, int NInputs, int NPerfOutputs, int NMeasOutputs, int NDisturbances>
ContinuousStateSpace< T, NStates, NMeasOutputs, NInputs > continuous_h2 (const ContinuousGeneralisedPlant< T, NStates, NInputs, NPerfOutputs, NMeasOutputs, NDisturbances > &Gss, const Eigen::Vector< T, NInputs > &control_penalty=Eigen::Vector< T, NInputs >::Zero(), const Eigen::Vector< T, NMeasOutputs > &measurement_noise=Eigen::Vector< T, NMeasOutputs >::Zero())
 Constructs a continuous H2 controller from a continuous state space plant model.
 
template<class T , int NStates, int NInputs, int NPerfOutputs, int NMeasOutputs, int NDisturbances>
ContinuousStateSpace< T, NStates, NMeasOutputs, NInputs > continuous_h2 (const ContinuousGeneralisedPlant< T, NStates, NInputs, NPerfOutputs, NMeasOutputs, NDisturbances > &Gss, const T &control_penalty=static_cast< T >(0), const T &measurement_noise=static_cast< T >(0))
 
template<class T , int PNumOrder, int PDenOrder, int MNumOrder, int MDenOrder, int WdNumOrder, int WdDenOrder, int WzNumOrder, int WzDenOrder>
ContinuousStateSpace< T, PDenOrder+MDenOrder+WdDenOrder+WzDenOrder, 1, 1 > continous_h2 (const ContinuousTransferFunction< T, PNumOrder, PDenOrder > &P, const ContinuousTransferFunction< T, MNumOrder, MDenOrder > &M, const ContinuousTransferFunction< T, WdNumOrder, WdDenOrder > &Wd, const ContinuousTransferFunction< T, WzNumOrder, WzDenOrder > &Wz, const T &control_penalty, const T &measurement_noise)
 Synthesizes an H2 controller from transfer functions.
 
template<class T , int NStates, int NInputs>
Eigen::Matrix< T, NInputs, NStates > lqr_continuous (const Eigen::Matrix< T, NStates, NStates > &A, const Eigen::Matrix< T, NStates, NInputs > &B, const Eigen::Matrix< T, NStates, NStates > &Q=Eigen::Matrix< T, NStates, NStates >::Identity(), const Eigen::Matrix< T, NInputs, NInputs > &R=Eigen::Matrix< T, NInputs, NInputs >::Identity())
 Synthesizes the continuous LQR gain from plant matrices (A, B) and weights (Q, R)
 
template<class T , int NStates, int NInputs>
Eigen::Matrix< T, NInputs, NStates > lqr_discrete (const Eigen::Matrix< T, NStates, NStates > &A, const Eigen::Matrix< T, NStates, NInputs > &B, const Eigen::Matrix< T, NStates, NStates > &Q=Eigen::Matrix< T, NStates, NStates >::Identity(), const Eigen::Matrix< T, NInputs, NInputs > &R=Eigen::Matrix< T, NInputs, NInputs >::Identity())
 Synthesizes the continuous LQR gain from plant matrices (A, B) and weights (Q, R)
 
template<class T , int NStates, int NInputs, int NOutputs>
Eigen::Matrix< T, NInputs, NStates > lqr (const DiscreteStateSpace< T, NStates, NInputs, NOutputs > Gss, const Eigen::Matrix< T, NStates, NStates > &Q, const Eigen::Matrix< T, NInputs, NInputs > &R)
 Computes a discrete LQR controller from a discrete state space plant model.
 
template<class T , int NStates, int NInputs, int NOutputs, std::convertible_to< T > U1 = T, std::convertible_to< T > U2 = T>
Eigen::Matrix< T, NInputs, NStates > lqr (const DiscreteStateSpace< T, NStates, NInputs, NOutputs > Gss, const U1 &r=static_cast< U1 >(1), const U2 &eps=static_cast< U2 >(0.001))
 Construcs a discrete LQR controller with automatic weights Q and R.
 
template<class T , int NStates, int NInputs, int NOutputs, std::convertible_to< T > U1 = T, std::convertible_to< T > U2 = T>
Eigen::Matrix< T, NInputs, NStates > lqr_bryson (const DiscreteStateSpace< T, NStates, NInputs, NOutputs > Gss, const Eigen::Vector< T, NOutputs > &x_max, const Eigen::Vector< T, NInputs > &u_max)
 Construcs a discrete LQR controller with weights trying to limit states and controller outputs.
 
template<class T , int NStates, int NInputs, int NOutputs>
Eigen::Matrix< T, NInputs, NOutputs > lqr_feed_forward (const DiscreteStateSpace< T, NStates, NInputs, NOutputs > Gss, Eigen::Matrix< T, NInputs, NStates > LQR)
 
template<class T >
constexpr T product_over (T from, T to)
 Calculates the product of all numbers in the closed open range [from, to)
 
template<class T >
constexpr T pow (const T &base, const int &exp)
 Power function for integral exponents.
 
template<class T , int N>
Eigen::Vector< T, N > unwrap (const Eigen::Vector< T, N > &y, const T &modulo)
 Unwinds modulo jumps.
 
template<class T , int N>
Eigen::Vector< T, N > unwrap_rad (const Eigen::Vector< T, N > &phases)
 Unwinds phase jumps of \(2 \pi\) in radiants.
 
template<class T , int N>
Eigen::Vector< T, N > unwrap_deg (const Eigen::Vector< T, N > &phases)
 Unwinds phase jumps of \(2 \pi\) in degrees.
 
template<class T = double>
constexpr T pade_param_reccursice (T P_k, std::int32_t m, std::int32_t n, std::int32_t k)
 Calculates the next pade parameter recursively.
 
template<class T = double>
constexpr void pade_params (T *params, std::size_t size, std::uint32_t m, std::uint32_t n)
 Calculates all pade parameters up to the given size.
 
template<class T = double>
constexpr T pade_num_param (std::int32_t m, std::int32_t n, std::int32_t k)
 Calculates the numerator parameters of the pade approximation.
 
template<class T = double>
constexpr T pade_den_param (unsigned long m, unsigned long n, unsigned long k)
 Calculates the numerator parameters of the pade approximation.
 
template<class T , int Rows, int Cols, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > identity_like (const Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > &unused)
 
template<class T , int LSize, int RSize>
Eigen::Matrix< T, LSize+RSize, LSize+RSize > join_to_diagonal (const Eigen::Vector< T, LSize > &l, const Eigen::Vector< T, RSize > &r)
 
template<class T , int LSize, int RSize>
requires (LSize != Eigen::Dynamic && RSize != Eigen::Dynamic)
Eigen::Vector< T, LSize+RSize > join_to_vector (const Eigen::Vector< T, LSize > &l, const Eigen::Vector< T, RSize > &r)
 
template<class T , int LSize, int RSize>
requires (!(LSize != Eigen::Dynamic && RSize != Eigen::Dynamic))
Eigen::Vector< T, Eigen::Dynamic > join_to_vector (const Eigen::Vector< T, LSize > &l, const Eigen::Vector< T, RSize > &r)
 
template<class T , int Rows, int Cols, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, Rows-1, Cols-1 > minor (const Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > &A, size_t ex_row, size_t ex_col)
 returns the minor matrix excluding the provided column and row
 
template<class T , int Rows, int Cols, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, Rows, Cols > adj (const Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > &A)
 
template<class T , int N>
Eigen::Matrix< T, N-1, N-1 > companion (const Eigen::Vector< T, N > &v)
 Creates a companion matrix from a vector.
 
template<class T , int N>
requires (N % 2 == 0)
Eigen::Matrix< T, N/2, N/2 > hamilton_solver (const Eigen::Matrix< T, N, N > H)
 Solves the hamilton matrix.
 
template<class T , int N>
Eigen::Matrix< T, N/2, N/2 > symplectic_solver (const Eigen::Matrix< T, N, N > S)
 Solves the hamilton matrix.
 
template<class T , int NStates, int AOpt, int AMaxR, int AMaxC, int QOpt, int QMaxR, int QMaxC>
Eigen::Matrix< T, NStates, NStates > lyapunov_solver (const Eigen::Matrix< T, NStates, NStates, AOpt, AMaxR, AMaxC > &A, const Eigen::Matrix< T, NStates, NStates, QOpt, QMaxR, QMaxC > &Q)
 Solves the continuous time Lyapunov equation.
 
template<class ValueType , int NStates, int NInputs, int NOutputs>
std::tuple< Eigen::Matrix< ValueType, NStates, NStates >, Eigen::Matrix< ValueType, NStates, NStates > > energy_scaling_matrix (const Eigen::Matrix< ValueType, NStates, NStates > A, const Eigen::Matrix< ValueType, NStates, NInputs > B, const Eigen::Matrix< ValueType, NOutputs, NStates > C)
 Calculates the energy (Gramian) scaling via Lyapunov equations.
 
template<class T , int NStates, int NInputs, int AOpt, int AMaxR, int AMaxC, int BOpt, int BMaxR, int BMaxC, int ROpt, int RMaxR, int RMaxC, int QOpt, int QMaxR, int QMaxC>
Eigen::Matrix< T, NStates, NStates > care_solver (const Eigen::Matrix< T, NStates, NStates, AOpt, AMaxR, AMaxC > &A, const Eigen::Matrix< T, NStates, NInputs, BOpt, BMaxR, BMaxC > &B, const Eigen::Matrix< T, NStates, NStates, QOpt, QMaxR, QMaxC > &Q, const Eigen::Matrix< T, NInputs, NInputs, ROpt, RMaxR, RMaxC > &R)
 Solves the continuous time riccati equation (CARE)
 
template<class T , int NStates, int NInputs, int AOpt, int AMaxR, int AMaxC, int BOpt, int BMaxR, int BMaxC, int ROpt, int RMaxR, int RMaxC, int QOpt, int QMaxR, int QMaxC>
Eigen::Matrix< T, NStates, NStates > dare_solver (const Eigen::Matrix< T, NStates, NStates, AOpt, AMaxR, AMaxC > &A, const Eigen::Matrix< T, NStates, NInputs, BOpt, BMaxR, BMaxC > &B, const Eigen::Matrix< T, NStates, NStates, QOpt, QMaxR, QMaxC > &Q, const Eigen::Matrix< T, NInputs, NInputs, ROpt, RMaxR, RMaxC > &R)
 Solves the discrete time riccati equation (DARE)
 
template<class T , int NStates, int NInputs, int AOpt, int AMaxR, int AMaxC, int BOpt, int BMaxR, int BMaxC, int ROpt, int RMaxR, int RMaxC, int QOpt, int QMaxR, int QMaxC, int NOpt, int NMaxR, int NMaxC>
Eigen::Matrix< T, NStates, NStates > care_solver (const Eigen::Matrix< T, NStates, NStates, AOpt, AMaxR, AMaxC > &A, const Eigen::Matrix< T, NStates, NInputs, BOpt, BMaxR, BMaxC > &B, const Eigen::Matrix< T, NStates, NStates, QOpt, QMaxR, QMaxC > &Q, const Eigen::Matrix< T, NInputs, NInputs, ROpt, RMaxR, RMaxC > &R, const Eigen::Matrix< T, NStates, NInputs, NOpt, NMaxR, NMaxC > &N)
 Solves the continuous time riccati equation (CARE) with cross coupling.
 
template<class T , int NumOrder, int DenOrder = NumOrder>
requires (NumOrder <= DenOrder)
ContinuousTransferFunction< T, NumOrder, DenOrder > pade_delay (T delay)
 Creates a continuous transfer function approximating a delay using the pade approximation.
 
template<class T >
Eigen::Vector< std::complex< T >, 0 > zeros (const Polynom< T, 0 > &polynom)
 Returns an empty vector resembling the absence of solutions.
 
template<class T >
Eigen::Vector< std::complex< T >, 1 > zeros (const Polynom< T, 1 > &polynom)
 calculates the zeros/roots of a polynomial
 
template<class T >
Eigen::Vector< std::complex< T >, 2 > zeros (const Polynom< T, 2 > &polynom)
 calculates the zeros/roots of a polynomial
 
template<class T , int N>
requires (N > 1)
Eigen::Vector< std::complex< T >, N > zeros (const Polynom< T, N > &polynom)
 Calculates the zeros of a polynomial.
 
template<class T , int N>
bool operator== (const Polynom< T, N > &lhs, const Polynom< T, N > &rhs)
 Compares two polynomials for equality.
 
template<class T , int N>
bool operator!= (const Polynom< T, N > &lhs, const Polynom< T, N > &rhs)
 
template<class T , int Nl, int Nr>
Polynom< T,(Nl > Nr) ? Nl :Nr > operator+ (const Polynom< T, Nl > &lhs, const Polynom< T, Nr > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
Polynom< Tpoly, N > operator+ (const Tscalar &lhs, const Polynom< Tpoly, N > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
Polynom< Tpoly, N > operator+ (const Polynom< Tpoly, N > &lhs, const Tscalar &rhs)
 
template<class T , int N>
Polynom< T, N > operator- (const Polynom< T, N > &poly)
 
template<class T , int Nl, int Nr>
Polynom< T,(Nl > Nr) ? Nl :Nr > operator- (const Polynom< T, Nl > &lhs, const Polynom< T, Nr > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
Polynom< Tpoly, N > operator- (const Tscalar &lhs, const Polynom< Tpoly, N > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
Polynom< Tpoly, N > operator- (const Polynom< Tpoly, N > &lhs, const Tscalar &rhs)
 
template<class T , int lOrder, int rOrder>
Polynom< T, lOrder+rOrder > operator* (const Polynom< T, lOrder > &lhs, const Polynom< T, rOrder > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int Order>
Polynom< Tpoly, Order > operator* (const Polynom< Tpoly, Order > &lhs, const Tscalar &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int Order>
Polynom< Tpoly, Order > operator* (const Tscalar &lhs, const Polynom< Tpoly, Order > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int Order>
Polynom< Tpoly, Order > operator/ (const Polynom< Tpoly, Order > &lhs, const Tscalar &rhs)
 
template<class T , int N>
bool operator== (const FixedPolynom< T, N > &lhs, const FixedPolynom< T, N > &rhs)
 Compares two polynomials for equality.
 
template<class T , int N>
bool operator!= (const FixedPolynom< T, N > &lhs, const FixedPolynom< T, N > &rhs)
 
template<class T , int N>
FixedPolynom< T, N > operator+ (const FixedPolynom< T, N > &lhs, const FixedPolynom< T, N > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
requires (N >= 1)
FixedPolynom< Tpoly, N > operator+ (const Tscalar &lhs, const FixedPolynom< Tpoly, N > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
requires (N >= 1)
FixedPolynom< Tpoly, N > operator+ (const FixedPolynom< Tpoly, N > &lhs, const Tscalar &rhs)
 
template<class T , int N>
FixedPolynom< T, N > operator- (const FixedPolynom< T, N > &lhs, const FixedPolynom< T, N > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
requires (N >= 1)
FixedPolynom< Tpoly, N > operator- (const Tscalar &lhs, const FixedPolynom< Tpoly, N > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
requires (N >= 1)
FixedPolynom< Tpoly, N > operator- (const FixedPolynom< Tpoly, N > &lhs, const Tscalar &rhs)
 
template<class T , int N>
FixedPolynom< T, N > operator- (const FixedPolynom< T, N > &values)
 
template<class T , int N>
FixedPolynom< T, N > operator* (const FixedPolynom< T, N > &lhs, const FixedPolynom< T, N > &rhs)
 Non growing multiplication.
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
FixedPolynom< Tpoly, N > operator* (const FixedPolynom< Tpoly, N > &lhs, const Tscalar &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
FixedPolynom< Tpoly, N > operator* (const Tscalar &lhs, const FixedPolynom< Tpoly, N > &rhs)
 
template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
FixedPolynom< Tpoly, N > operator/ (const FixedPolynom< Tpoly, N > &lhs, const Tscalar &rhs)
 
template<class T , int NumOrder, int DenOrder>
StateSpace< T, DenOrder, 1, 1 > to_state_space_controller_norm (const TransferFunction< T, NumOrder, DenOrder > &rp)
 calculates the control-normed state space representation from a rational polynomial
 
template<class T , int NumOrder, int DenOrder>
StateSpace< T, DenOrder, 1, 1 > to_state_space_observer_norm (const TransferFunction< T, NumOrder, DenOrder > &rp)
 calculates the observer-normed state space representation from a rational polynomial
 
template<class T , int NumOrder, int DenOrder>
StateSpace< T, DenOrder, 1, 1 > to_state_space (const TransferFunction< T, NumOrder, DenOrder > &rp)
 calculates the observer-normed state space representation from a rational polynomial
 
template<class T , int NRows, int NCols, int Opts, int NMaxRows, int NMaxCols>
StateSpace< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::Dynamic > to_state_space (const Eigen::Matrix< TransferFunction< T, Eigen::Dynamic, Eigen::Dynamic >, NRows, NCols, Opts, NMaxRows, NMaxCols > &Mtf)
 Generates the block diagonal state space representation of the system of transfer functions.
 
template<class T , int states>
TransferFunction< T, states+1, states+1 > to_transfer_function (const StateSpace< T, states, 1, 1 > &css)
 transforms a continuous state space system representation to a transfer function representation
 
template<class T >
void write_csv (std::ostream &stream, const TimeSeries< T > &timeseries)
 Prints the timeseries as a .csv file.
 
template<class T >
std::ostream & operator<< (std::ostream &stream, const ComplexTimeSeries< T > &timeseries)
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr auto operator== (const TransferFunction< T, NumOrder1, DenOrder1 > &lhs, const TransferFunction< T, NumOrder1, DenOrder1 > &rhs)
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr bool operator!= (const TransferFunction< T, NumOrder1, DenOrder1 > &lhs, const TransferFunction< T, NumOrder1, DenOrder1 > &rhs)
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr TransferFunction< T, std::max(NumOrder1+DenOrder2, NumOrder2+DenOrder1), DenOrder1+DenOrder2 > operator+ (const TransferFunction< T, NumOrder1, DenOrder1 > &lhs, const TransferFunction< T, NumOrder2, DenOrder2 > &rhs)
 rational addition of polynomials
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, std::max(NumOrder, DenOrder), DenOrder > operator+ (const Tscalar &lhs, const TransferFunction< T, NumOrder, DenOrder > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, std::max(NumOrder, DenOrder), DenOrder > operator+ (const TransferFunction< T, NumOrder, DenOrder > &lhs, const Tscalar &rhs)
 
template<class T , int NumOrder1, int DenOrder1>
constexpr TransferFunction< T, NumOrder1, DenOrder1 > operator- (const TransferFunction< T, NumOrder1, DenOrder1 > &poly)
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr TransferFunction< T, std::max(NumOrder1+DenOrder2, NumOrder2+DenOrder1), DenOrder1+DenOrder2 > operator- (const TransferFunction< T, NumOrder1, DenOrder1 > &lhs, const TransferFunction< T, NumOrder2, DenOrder2 > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, std::max(NumOrder, DenOrder), DenOrder > operator- (const Tscalar &lhs, const TransferFunction< T, NumOrder, DenOrder > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, std::max(NumOrder, DenOrder), DenOrder > operator- (const TransferFunction< T, NumOrder, DenOrder > &lhs, const Tscalar &rhs)
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr TransferFunction< T, NumOrder1+NumOrder2, DenOrder1+DenOrder2 > operator* (const TransferFunction< T, NumOrder1, DenOrder1 > &lhs, const TransferFunction< T, NumOrder2, DenOrder2 > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, NumOrder, DenOrder > operator* (const Tscalar &lhs, const TransferFunction< T, NumOrder, DenOrder > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, NumOrder, DenOrder > operator* (const TransferFunction< T, NumOrder, DenOrder > &lhs, const Tscalar &rhs)
 
template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr TransferFunction< T, NumOrder1+DenOrder2, DenOrder1+NumOrder2 > operator/ (const TransferFunction< T, NumOrder1, DenOrder1 > &lhs, const TransferFunction< T, NumOrder2, DenOrder2 > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, DenOrder, NumOrder > operator/ (const Tscalar &lhs, const TransferFunction< T, NumOrder, DenOrder > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, NumOrder, DenOrder > operator/ (const TransferFunction< T, NumOrder, DenOrder > &lhs, const Tscalar &rhs)
 
template<class T , int NumOrder, int DenOrder>
Eigen::Vector< std::complex< T >, NumOrder+1 > zeros (const TransferFunction< T, NumOrder, DenOrder > &tf)
 
template<class T , int NumOrder, int DenOrder>
Eigen::Vector< std::complex< T >, DenOrder+1 > poles (const TransferFunction< T, NumOrder, DenOrder > &tf)
 
template<class T , int N>
constexpr bool operator== (const FixedRationalPolynom< T, N > &lhs, const FixedRationalPolynom< T, N > &rhs)
 
template<class T , int N>
constexpr bool operator!= (const FixedRationalPolynom< T, N > &lhs, const FixedRationalPolynom< T, N > &rhs)
 
template<class T , int N>
constexpr auto operator+ (const FixedRationalPolynom< T, N > &lhs, const FixedRationalPolynom< T, N > &rhs)
 rational addition of polynomials
 
template<class T , std::convertible_to< T > Tscalar, int N>
constexpr auto operator+ (const Tscalar &lhs, const FixedRationalPolynom< T, N > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int N>
constexpr auto operator+ (const FixedRationalPolynom< T, N > &lhs, const Tscalar &rhs)
 
template<class T , int N>
constexpr FixedRationalPolynom< T, N > operator- (const FixedRationalPolynom< T, N > &poly)
 
template<class T , int N>
constexpr auto operator- (const FixedRationalPolynom< T, N > &lhs, const FixedRationalPolynom< T, N > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int N>
constexpr auto operator- (const Tscalar &lhs, const FixedRationalPolynom< T, N > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int N>
constexpr auto operator- (const FixedRationalPolynom< T, N > &lhs, const Tscalar &rhs)
 
template<class T , int N>
constexpr FixedRationalPolynom< T, N > operator* (const FixedRationalPolynom< T, N > &lhs, const FixedRationalPolynom< T, N > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int N>
constexpr FixedRationalPolynom< T, N > operator* (const Tscalar &lhs, const FixedRationalPolynom< T, N > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int N>
constexpr FixedRationalPolynom< T, N > operator* (const FixedRationalPolynom< T, N > &lhs, const Tscalar &rhs)
 
template<class T , int N>
constexpr auto operator/ (const FixedRationalPolynom< T, N > &lhs, const FixedRationalPolynom< T, N > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int N>
constexpr auto operator/ (const Tscalar &lhs, const FixedRationalPolynom< T, N > &rhs)
 
template<class T , std::convertible_to< T > Tscalar, int N>
constexpr auto operator/ (const FixedRationalPolynom< T, N > &lhs, const Tscalar &rhs)
 
template<class ValueType , int states>
DiscreteStateSpace< ValueType, states, 1, 1 > discretise_zoh (const ContinuousStateSpace< ValueType, states, 1, 1 > &sys, ValueType sample_time)
 transform s-domain into z-domain using zero-order-hold
 
template<class T , int NStates, int NInputs, int NOutputs>
DiscreteStateSpace< T, NStates, NInputs, NOutputs > discretise_tustin (const ContinuousStateSpace< T, NStates, NInputs, NOutputs > &sys, const T &sample_time)
 discretises a continuous state space to a discrete one with the Tustin transformation
 
template<class T , int NStates>
DiscreteStateSpace< T, NStates, 1, 1 > discretise (const ContinuousStateSpace< T, NStates, 1, 1 > &sys, const T &sample_time, EDiscretisation method)
 

Detailed Description

The main namespace for the Control++ library.

This namespace contains all the classes, functions, and utilities provided by the Control++ library for control systems analysis and design.

Enumeration Type Documentation

◆ dft_estimate_error

enum class controlpp::dft_estimate_error
strong
Enumerator
data_ranges_different_lenth 
data_range_too_small 

◆ EBodeCsvReadError

enum class controlpp::EBodeCsvReadError
strong

Error cases for reading/parsing bode data from CSV formated data.

Enumerator
CouldNotFindFrequencyVector 

Could not find the frequency axis in the csv data. Searched for a header that starts with "f" (case-insensitive).

CouldNotFindAmplitudeVectors 

Could not find the amplitude data. Needed either: 1) Two columns that start with "re" and "im" (case-insensitive). 2) Two columns that start with "mag" and "ph" (case-insensitive).

◆ EDiscretisation

enum class controlpp::EDiscretisation
strong
Enumerator
zero_order_hold 
tustin 

◆ EFrequencyInterpretation

Enum that determines how frequency data will be interpreted when reading CSV data.

Enumerator
AutoHz 

Automatically infers the unit from the header or interprets the data in Hz if no unit is found in the header name.

AutoRad 

Automatically infers the unit from the header or interprets the data in rad if no unit is found in the header name.

ForceHz 

When reading frequency data the data is always interpreted in Hz regardless of the header name.

ForceRad 

When reading frequency data the data is always interpreted in rad regardless of the header name.

◆ EMagnitudeInterpretation

Enum that determines how frequency data will be interpreted when reading CSV data.

Enumerator
Auto 

Automatically infers the unit from the header and interprets as deci-Bell if "dB" has been found or interprets the data as absolute values if no unit is found in the header name.

ForceAbs 

Forces the magnitude data to be interpreted in absolute values regardless of the header name.

ForceDB 

Forces the magnitude data to be interpreted in dB regardless of the header name.

◆ EPhaseInterpretation

Enum that determines how phase data will be interpreted when reading CSV data.

Enumerator
AutoRad 

Automatically infers the unit from the header or interprets the data as rad if no unit is found in the header name.

AutoDeg 

Automatically infers the unit from the header or interprets the data as deg if no unit is found in the header name.

ForceRad 

Forces the magnitude data to be interpreted in rad regardless of the header name.

ForceDeg 

Forces the magnitude data to be interpreted in deg regardless of the header name.

Function Documentation

◆ adj()

template<class T , int Rows, int Cols, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, Rows, Cols > controlpp::adj ( const Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > &  A)

◆ bode() [1/4]

template<class T , int NumOrder, int DenOrder>
Bode< T > controlpp::bode ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf,
const Eigen::Vector< T, Eigen::Dynamic > &  freqs 
)

Calculates the bode response for a pre defined frequency (rad/s) vector.

Template Parameters
TThe value type of the transfer function
NumOrderThe numerator order
DenOrderThe denominator order
NSizeThe number of elements in the frequency vector (may also be Eigen::Dynamic)
Parameters
tfThe continuous transfer function to analyse
freqsThe frequency vector at which to evaluate the transfer function in rad/s
Returns
The bode result as a Bode struct
See also
ContinuousTransferFunction
Bode

◆ bode() [2/4]

template<class T , int NumOrder, int DenOrder>
Bode< T > controlpp::bode ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf,
const int  samples_per_decade = 100 
)

Calculates the bode response of a transfer function.

Infers the frequency range of the bode plot from the transfer function.

Parameters
tfThe transfer function
samples_per_decadeThe number of samples per decade of frequencies to be calculated
Returns
A Bode containing the frequencies (Hz), magnitues (dB) and phases (deg)
See also
Bode
bode(const ContinuousTransferFunction<T, NumOrder, DenOrder>& tf, const T& slowest_freq_Hz, const T& fastest_freq_Hz, const int samples_per_decade)
ContinuousTransferFunction::eval_frequencies

◆ bode() [3/4]

template<class T , int NumOrder, int DenOrder, std::convertible_to< T > T1, std::convertible_to< T > T2>
Bode< T > controlpp::bode ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf,
const T1 &  slowest_freq_rad,
const T2 &  fastest_freq_rad,
const int  samples_per_decade = 100 
)

Calculates the bode response of a transfer function.

Parameters
slowest_freq_radThe slowest/lowest frequency in rad/s from which to calculate frequency responses
fastest_freq_radThe fastest/highest frequency in rad/s to which to calculate the frequency response
samples_per_decadeThe number of samples per decade of frequencies to be calculated
Returns
A Bode containing the frequencies (Hz), magnitues (dB) and phases (deg)
See also
Bode
ContinuousTransferFunction::eval_frequencies
bode(const ContinuousTransferFunction<T, NumOrder, DenOrder>& tf, const int samples_per_decade)

◆ bode() [4/4]

template<class T , int NumOrder, int DenOrder>
Bode< T > controlpp::bode ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf,
Eigen::Vector< T, Eigen::Dynamic > &&  freqs 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ bode_hz() [1/4]

template<class T , int NumOrder, int DenOrder>
Bode< T > controlpp::bode_hz ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf,
const Eigen::Vector< T, Eigen::Dynamic > &  freqs_Hz 
)

Calculates the bode response for a pre defined frequency (Hz) vector.

Template Parameters
TThe value type of the transfer function
NumOrderThe numerator order
DenOrderThe denominator order
NSizeThe number of elements in the frequency vector (may also be Eigen::Dynamic)
Parameters
tfThe continuous transfer function to analyse
freqs_HzThe frequency vector at which to evaluate the transfer function in hz
Returns
The bode result as a Bode struct
See also
ContinuousTransferFunction
Bode

◆ bode_hz() [2/4]

template<class T , int NumOrder, int DenOrder>
Bode< T > controlpp::bode_hz ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf,
const int  samples_per_decade = 100 
)

Calculates the bode response of a transfer function.

Infers the frequency range of the bode plot from the transfer function.

Parameters
tfThe transfer function
samples_per_decadeThe number of samples per decade of frequencies to be calculated
Returns
A Bode containing the frequencies (Hz), magnitues (dB) and phases (deg)
See also
Bode
bode(const ContinuousTransferFunction<T, NumOrder, DenOrder>& tf, const T& slowest_freq_Hz, const T& fastest_freq_Hz, const int samples_per_decade)
ContinuousTransferFunction::eval_frequencies

◆ bode_hz() [3/4]

template<class T , int NumOrder, int DenOrder, std::convertible_to< T > T1, std::convertible_to< T > T2>
Bode< T > controlpp::bode_hz ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf,
const T1 &  slowest_freq_Hz,
const T2 &  fastest_freq_Hz,
const int  samples_per_decade = 100 
)

Calculates the bode response of a transfer function.

Parameters
slowest_freq_HzThe slowest/lowest frequency in Hz from which to calculate frequency responses
fastest_freq_HzThe fastest/highest frequency in Hz to which to calculate the frequency response
samples_per_decadeThe number of samples per decade of frequencies to be calculated
Returns
A Bode containing the frequencies (Hz), magnitues (dB) and phases (deg)
See also
Bode
ContinuousTransferFunction::eval_frequencies
bode(const ContinuousTransferFunction<T, NumOrder, DenOrder>& tf, const int samples_per_decade)

◆ bode_hz() [4/4]

template<class T , int NumOrder, int DenOrder>
Bode< T > controlpp::bode_hz ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf,
Eigen::Vector< T, Eigen::Dynamic > &&  freqs_Hz 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ care_solver() [1/2]

template<class T , int NStates, int NInputs, int AOpt, int AMaxR, int AMaxC, int BOpt, int BMaxR, int BMaxC, int ROpt, int RMaxR, int RMaxC, int QOpt, int QMaxR, int QMaxC>
Eigen::Matrix< T, NStates, NStates > controlpp::care_solver ( const Eigen::Matrix< T, NStates, NStates, AOpt, AMaxR, AMaxC > &  A,
const Eigen::Matrix< T, NStates, NInputs, BOpt, BMaxR, BMaxC > &  B,
const Eigen::Matrix< T, NStates, NStates, QOpt, QMaxR, QMaxC > &  Q,
const Eigen::Matrix< T, NInputs, NInputs, ROpt, RMaxR, RMaxC > &  R 
)

Solves the continuous time riccati equation (CARE)

This function computes the stabilizing symmetric solution of the CARE:

\[ A^\top X + X A - (X B) R^{-1} (B^\top X) + Q = 0 \]

where \(A, B, C, D\) are system matrices:

\[ \dot{x} = A x + B u y = C x + D u \]

with the system states \(x\), inputs \(u\) and outputs \(y\),

as well as \(Q\), \(R\) the state and input weighting matrices.


Soves the Riccatiy equation by:

  1. Building the Hamilton matrix (controlpp::create_hamilton())
  2. Compute its stable eigenvectors
  3. Re-Partitions the eigenvectors
  4. Recovers X from the partitions
Parameters
AState matrix ( \(n \times n\)).
BInput matrix ( \(n \times m\)).
RInput weighting matrix ( \(m \times m\), symmetric positive definite).
QState weighting matrix ( \(n \times n\), symmetric positive semidefinite).
Template Parameters
TScalar type (e.g., double, float).
NStatesNumber of states.
NInputsNumber of control inputs.
See also
Zhou, Doyle, and Glover (1996), Robust and Optimal Control.
hamilton_solver

◆ care_solver() [2/2]

template<class T , int NStates, int NInputs, int AOpt, int AMaxR, int AMaxC, int BOpt, int BMaxR, int BMaxC, int ROpt, int RMaxR, int RMaxC, int QOpt, int QMaxR, int QMaxC, int NOpt, int NMaxR, int NMaxC>
Eigen::Matrix< T, NStates, NStates > controlpp::care_solver ( const Eigen::Matrix< T, NStates, NStates, AOpt, AMaxR, AMaxC > &  A,
const Eigen::Matrix< T, NStates, NInputs, BOpt, BMaxR, BMaxC > &  B,
const Eigen::Matrix< T, NStates, NStates, QOpt, QMaxR, QMaxC > &  Q,
const Eigen::Matrix< T, NInputs, NInputs, ROpt, RMaxR, RMaxC > &  R,
const Eigen::Matrix< T, NStates, NInputs, NOpt, NMaxR, NMaxC > &  N 
)

Solves the continuous time riccati equation (CARE) with cross coupling.

This function computes the stabilizing symmetric solution of the CARE:

\[ A^\top X + X A - (X B + N) R^{-1} (B^\top X + N) + Q = 0 \]

where \(A, B, C, D\) are system matrices:

\[ \dot{x} = A x + B u y = C x + D u \]

with the system states \(x\), inputs \(u\) and outputs \(y\),

as well as \(Q\), \(R\) the state and input weighting matrices.


Soves the Riccatiy equation by:

  1. Building the Hamilton matrix (controlpp::create_hamilton())
  2. Compute its stable eigenvectors
  3. Re-Partitions the eigenvectors
  4. Recovers X from the partitions
Parameters
AState matrix ( \(n \times n\)).
BInput matrix ( \(n \times m\)).
RInput weighting matrix ( \(m \times m\), symmetric positive definite).
QState weighting matrix ( \(n \times n\), symmetric positive semidefinite).
NN Cross-term weighting matrix ( \(n × m\)).
Template Parameters
TScalar type (e.g., double, float).
NStatesNumber of states.
NInputsNumber of control inputs.
See also
Zhou, Doyle, and Glover (1996), Robust and Optimal Control.
hamilton_solver

◆ companion()

template<class T , int N>
Eigen::Matrix< T, N-1, N-1 > controlpp::companion ( const Eigen::Vector< T, N > &  v)

Creates a companion matrix from a vector.

given the vector:

\[ \vec{v} = \left[a_0, a_1, a_2, \cdots , a_n \right] \]

creates the companion matrix:

\[ \mathbf{C} = \begin{bmatrix} 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \ddots & \ddots & \vdots \\ 0 & 0 & \cdots & 0 & 1 \\ b_0 & b_1 & \cdots & b_{n-2} & b_{n-1} \end{bmatrix} \]

where \(b_i\) is:

\[ b_i = \frac{a_i}{a_n} \]

Returns
a companion matrix

◆ continous_h2() [1/4]

template<class T , int PNumOrder, int PDenOrder, int MNumOrder, int MDenOrder, int WdNumOrder, int WdDenOrder, int WzNumOrder, int WzDenOrder>
ContinuousStateSpace< T, PDenOrder+MDenOrder+WdDenOrder+WzDenOrder, 1, 1 > controlpp::continous_h2 ( const ContinuousTransferFunction< T, PNumOrder, PDenOrder > &  P,
const ContinuousTransferFunction< T, MNumOrder, MDenOrder > &  M,
const ContinuousTransferFunction< T, WdNumOrder, WdDenOrder > &  Wd,
const ContinuousTransferFunction< T, WzNumOrder, WzDenOrder > &  Wz,
const T &  control_penalty,
const T &  measurement_noise 
)

Synthesizes an H2 controller from transfer functions.

d .. disturbance
|
+----+
| Wd |
+----+
e +----+ u +---+ | +----+
r ----> + ---->| H2 |----->| P |-----> + ---->| Wz |----> z .. performance output
^ +----+ +---+ | +----+
| |
| y .. measurement +---+ |
+---------- + -----| M | ----------+
^ +---+
|
+----+
| Wn |
+----+
|
n .. measurement noise
Parameters
PTransfer function of the plan
MTransfer function of the measurement
WdTransfer function (weight) shaping the disturbance
WnTransfer function (weight) shaping the measurement noise
WzTransfer function (weight) shaping the performance output
See also
ContinuousGeneralisedPlant
ContinuousStateSpace
ContinuousTransferFunction

◆ continous_h2() [2/4]

template<class T , int NStates, int NInputs, int NPerfOutputs, int NMeasOutputs, int NDisturbances>
ContinuousStateSpace< T, NStates, NMeasOutputs, NInputs > controlpp::continous_h2 ( const Eigen::Matrix< T, NStates, NStates > &  A,
const Eigen::Matrix< T, NStates, NDisturbances > &  Bw,
const Eigen::Matrix< T, NStates, NInputs > &  Bu,
const Eigen::Matrix< T, NPerfOutputs, NStates > &  Cz,
const Eigen::Matrix< T, NPerfOutputs, NInputs > &  Duz,
const Eigen::Matrix< T, NMeasOutputs, NStates > &  Cy,
const Eigen::Matrix< T, NMeasOutputs, NDisturbances > &  Dwy,
const Eigen::Matrix< T, NInputs, NInputs > &  R,
const Eigen::Matrix< T, NMeasOutputs, NMeasOutputs > &  S 
)

◆ continous_h2() [3/4]

template<class T , int NStates, int NInputs, int NPerfOutputs, int NMeasOutputs, int NDisturbances>
requires (NInputs>1 && NMeasOutputs>1)
ContinuousStateSpace< T, NStates, NMeasOutputs, NInputs > controlpp::continous_h2 ( const Eigen::Matrix< T, NStates, NStates > &  A,
const Eigen::Matrix< T, NStates, NDisturbances > &  Bw,
const Eigen::Matrix< T, NStates, NInputs > &  Bu,
const Eigen::Matrix< T, NPerfOutputs, NStates > &  Cz,
const Eigen::Matrix< T, NPerfOutputs, NInputs > &  Duz,
const Eigen::Matrix< T, NMeasOutputs, NStates > &  Cy,
const Eigen::Matrix< T, NMeasOutputs, NDisturbances > &  Dwy,
const Eigen::Vector< T, NInputs >  r = Eigen::Vector<T, NInputs>::Zero(),
const Eigen::Vector< T, NMeasOutputs >  s = Eigen::Vector<T, NMeasOutputs>::Zero() 
)

An optimal controller for linear time-invariant (LTI) system. It minimizes the H2 norm of the the disturbance input gain to the output.

An H2 controller is part of the class of optimal controllers. Where the typical system model is a linear time-invaritan (LTI) system, that looks like:

\[ \dot{x} = A x + B_w w + B_u u \\ z = C_z x + D_{1u} u \\ y = C_y x + D_{2w} w \]

Where:

  • inputs:
    • \(w\) is the disturbance
    • \(u\) are the inputs of the system
  • Outputs/States
    • \(x\) describes the states of the system
    • \(z\) is the performance output (this is the output of which we want to minimize the variance)
    • \(y\) is the output that we can actually measure (what the controller sees)
  • Parameters
    • \(A\) describes the dynamic of the system/plant
    • \(B_w\) describes how the disturbance \(w\) affects the systems states
    • \(B_u\) describes how the inputs \(u\) affect the system states
    • \(C_z\) describes how the system states result in the output of the system that should be controlled
    • \(C_y\) describes how the states generate the system output \(y\) that we can measure
    • \(D_{1u}\) describes how the inputs directly affect the performance output
    • \(D_{2w}\) describes how the disturbance affects the measurement output \(y\)

Note how \(D_{11}\), and \(D_{22}\) are assumed to be zero.


The H2 controller solves a system such that the closed-loop transfer function from the disturbance \(w\) to the performace output \(z\) has a minimized variance.

The dynamic controller of such a system has the form of:

\[ \dot{x_K} = A_K + x_K + B_K y \\ u = C_K x_K + D_K y \]


The optimal solution can be found solveing the Riccati equations for the state-feedback riccati equation:

\[ A^\top X + X A - X B_u R^{-1} B_u^\top X + Q = 0 \]

with

  • \(Q = C_z^\top C_z\) the performance weight, aka. state cost matrix. It penalizes state deviations.
  • \(R = D_{1u}^\top D_{1u}\) is the input weight, aka. control cost matrix. It penalizes control effort.

and the estimator riccati equation:

\[ A^\top Y + Y A - Y C_y S^{-1} C_y^\top Y + W = 0 \]

where:

  • \(W = B_w B_w^\top\) disturbance weight
  • \(S = D_{2w} D_{2w}^\top\) measurement noise weight.

X and Y from the riccati equations are then used to calculate the

optimal state-feedback gain:

\[ F = -R^{-1} \left( B_u^\top X + D_{1u}^\top C_z \right) \]

and the optimal observer gian:

\[ L = - \left( Y C_y^\top + B_w D_{2w}^\top \right) S^{-1} \]


The H2 controller then is:

\[ A_K = A + B_u F + L C_y \\ B_K = -L C_K = F D_K = 0 \]


The default H2 controller minimizes the total energy over all frequencies. To emphasise the control of a certain frequency region one can define a weighting transfer function \(W_z(s)\) that affects the performance output \(z\):

\[ z_w = W_z(s) z \]

I \(W_z\) is large at a certain frequency the optimizer will try to reduce the gain in that band more aggressively than in the band that W is smaller.

Parameters
ASystem/plant dynamic
Bwdisturbance input
Bucontrol input
Czstate to performance output
Cystate to measurement output
Duzthroughput from control input to performance output
Dwythroughput from disturbance to measurement output
rInput weighting. penalizes control effort u.
  • Large r: controller is gentle (low gain)
  • Small r: controller is aggressive (high gain)
sMeasurement noise / estimator weighting. penalizes measurement trust:
  • Large s: controller assumes the "measurements are noisy". It does not trust the measurements and relies on the model.
  • Small s: controller assumes the "measurements are clean". It trusts the measurements more and the estimator reacts stronger to sensor signals.

◆ continous_h2() [4/4]

template<class T , int NStates, int NInputs, int NPerfOutputs, int NMeasOutputs, int NDisturbances>
ContinuousStateSpace< T, NStates, NMeasOutputs, NInputs > controlpp::continous_h2 ( const Eigen::Matrix< T, NStates, NStates > &  A,
const Eigen::Matrix< T, NStates, NDisturbances > &  Bw,
const Eigen::Matrix< T, NStates, NInputs > &  Bu,
const Eigen::Matrix< T, NPerfOutputs, NStates > &  Cz,
const Eigen::Matrix< T, NPerfOutputs, NInputs > &  Duz,
const Eigen::Matrix< T, NMeasOutputs, NStates > &  Cy,
const Eigen::Matrix< T, NMeasOutputs, NDisturbances > &  Dwy,
const T &  r_scalar = 0,
const T &  s_scalar = 0 
)

◆ continuous_h2() [1/2]

template<class T , int NStates, int NInputs, int NPerfOutputs, int NMeasOutputs, int NDisturbances>
ContinuousStateSpace< T, NStates, NMeasOutputs, NInputs > controlpp::continuous_h2 ( const ContinuousGeneralisedPlant< T, NStates, NInputs, NPerfOutputs, NMeasOutputs, NDisturbances > &  Gss,
const Eigen::Vector< T, NInputs > &  control_penalty = Eigen::Vector<T, NInputs>::Zero(),
const Eigen::Vector< T, NMeasOutputs > &  measurement_noise = Eigen::Vector<T, NMeasOutputs>::Zero() 
)

Constructs a continuous H2 controller from a continuous state space plant model.

Parameters
GssGeneralised plant in state space form
Template Parameters
TThe value type of the plant and controller. Usually double or float.
NPlantOutputsThe number of states of the plant. Also the number of states of the controller if no extra weighting functions are applied.
NPlantInputsThe number of inputs of the plant.
See also
controlpp::continous_h2()
controlpp::ContinuousGeneralisedPlant

◆ continuous_h2() [2/2]

template<class T , int NStates, int NInputs, int NPerfOutputs, int NMeasOutputs, int NDisturbances>
ContinuousStateSpace< T, NStates, NMeasOutputs, NInputs > controlpp::continuous_h2 ( const ContinuousGeneralisedPlant< T, NStates, NInputs, NPerfOutputs, NMeasOutputs, NDisturbances > &  Gss,
const T &  control_penalty = static_cast<T>(0),
const T &  measurement_noise = static_cast<T>(0) 
)

◆ dare_solver()

template<class T , int NStates, int NInputs, int AOpt, int AMaxR, int AMaxC, int BOpt, int BMaxR, int BMaxC, int ROpt, int RMaxR, int RMaxC, int QOpt, int QMaxR, int QMaxC>
Eigen::Matrix< T, NStates, NStates > controlpp::dare_solver ( const Eigen::Matrix< T, NStates, NStates, AOpt, AMaxR, AMaxC > &  A,
const Eigen::Matrix< T, NStates, NInputs, BOpt, BMaxR, BMaxC > &  B,
const Eigen::Matrix< T, NStates, NStates, QOpt, QMaxR, QMaxC > &  Q,
const Eigen::Matrix< T, NInputs, NInputs, ROpt, RMaxR, RMaxC > &  R 
)

Solves the discrete time riccati equation (DARE)

This function computes the stabilizing symmetric solution of the DARE:

\[ A^\top X A - A^\top X B (R + B^\top X B)^{-1} B^\top X A + Q = 0 \]

where \(A, B, C, D\) are system matrices:

\[ \dot{x} = A x + B u y = C x + D u \]

with the system states \(x\), inputs \(u\) and outputs \(y\),

as well as \(Q\), \(R\) the state and input weighting matrices.


Soves the Riccatiy equation by:

  1. Building the Hamilton matrix (controlpp::create_hamilton())
  2. Compute its stable eigenvectors
  3. Re-Partitions the eigenvectors
  4. Recovers X from the partitions
Parameters
AState matrix ( \(n \times n\)).
BInput matrix ( \(n \times m\)).
RInput weighting matrix ( \(m \times m\), symmetric positive definite).
QState weighting matrix ( \(n \times n\), symmetric positive semidefinite).
Template Parameters
TScalar type (e.g., double, float).
NStatesNumber of states.
NInputsNumber of control inputs.
See also
hamilton_solver

◆ dft_estimate()

template<class T , int NumOrder, int DenOrder>
requires ((NumOrder != Eigen::Dynamic) && (DenOrder != Eigen::Dynamic))
tl::expected< DiscreteTransferFunction< T, NumOrder, DenOrder >, dft_estimate_error > controlpp::dft_estimate ( const Eigen::Vector< T, Eigen::Dynamic > &  u,
const Eigen::Vector< T, Eigen::Dynamic > &  y,
const T &  regularization = T(0),
const DiscreteTransferFunction< T, NumOrder, DenOrder > &  hint = DiscreteTransferFunction<T, NumOrder, DenOrder>({T(0)}, {T(1)}) 
)

Estimates a discrete time transfer function of a specific order for the input (u) and output (y) data pairs.

Finds the optimal parameters that minimize the cost function:

\[ \left( y - U p \right)^2 \]

where

  • y: is the output of the system
  • p: are the parameters of the transfer function (this is what we optimise)
  • U: A matrix where each row contains the current and past inputs and outputs.
Template Parameters
TThe data type
NumOrderThe numerator order for the resulting transfer function
DenOrderThe denominator order for the resulting transfer function
NThe size of the data
Parameters
yThe output data of the system
uThe input data of the system
regularizationadds an extra ( \(\lambda\)) therm \( \lambda p^2 \) to the cost function that penalises large parameters (p).
hintadds an extra penalty to the cost function if parameters deviate from the hint \( \lambda (p - p_\text{hint})^2 \). Note that regularisation needs to be non-zero for the hint to take effect.
Returns
A transfer function that best fits: y = Tf * u

◆ discretise()

template<class T , int NStates>
DiscreteStateSpace< T, NStates, 1, 1 > controlpp::discretise ( const ContinuousStateSpace< T, NStates, 1, 1 > &  sys,
const T &  sample_time,
EDiscretisation  method 
)

◆ discretise_tustin()

template<class T , int NStates, int NInputs, int NOutputs>
DiscreteStateSpace< T, NStates, NInputs, NOutputs > controlpp::discretise_tustin ( const ContinuousStateSpace< T, NStates, NInputs, NOutputs > &  sys,
const T &  sample_time 
)

discretises a continuous state space to a discrete one with the Tustin transformation

Applies the following transformation:

\[ A_d = \left( I - \frac{Ts}{2} A \right)^{-1} \left( I + \frac{Ts}{2} A \right)\\ B_d = \left( I - \frac{Ts}{2} A \right)^{-1} Ts B C_d = C \left( I - \frac{Ts}{2} A \right)^{-1} D_d = D + C * \left( I - \frac{Ts}{2} A \right)^{-1} * Ts * B / 2 \]

where:

  • A, B, C, D are the continuous time system matrices
  • A_d, B_d, C_d, D_d are the discrete time system matrices
  • Ts is the sample time
Template Parameters
TThe value type of the matrices/systems. Usually float or double.
NStatesThe number of states of the systems
NInputsThe number of inputs of the systems
NOutputsThe number of outputs of the systems
Parameters
sysThe continuous time state space system about to be discretised
sample_timeThe sample time used for the discretisation
Returns
A discrete state space system

◆ discretise_zoh()

template<class ValueType , int states>
DiscreteStateSpace< ValueType, states, 1, 1 > controlpp::discretise_zoh ( const ContinuousStateSpace< ValueType, states, 1, 1 > &  sys,
ValueType  sample_time 
)

transform s-domain into z-domain using zero-order-hold

TODO: Testing

Use this function to discretize a plant.

To correctly design controllers, transform the plant first with zoh into the z-domain and then from the z-domain into the q-domain using the tustin transformation. Perform the actual controller design in q-domain and then transform the controller back into the z-domain.

Note: This method uses exact discretisation - but not quite - it uses an approximated matrix exponent control::exp_taylor_scale(M) to calculate:

\[ \exp{\mathbf{M}} \]

Controller design chain:

  • G ... Plant
  • R ... Controller
  1. mathematical model --> G(s)
  2. discretise_zoh (zero-order-hold) --> G(z)
  3. discrete_to_bilinear (tustin) --> controller design --> R(q)
  4. bilinear_to_discrete (tustin) --> R(z)
Template Parameters
ValueTypeThe value type of the matrix entries (e.g.: float)
TimePointThe representation of the time type (e.g.: float)
statesThe number of internal states of the system
Parameters
sysA continuous state space sytem
sample_timeThe sample time in seconds
Returns
The discretised version of sys

◆ energy_scaling_matrix()

template<class ValueType , int NStates, int NInputs, int NOutputs>
std::tuple< Eigen::Matrix< ValueType, NStates, NStates >, Eigen::Matrix< ValueType, NStates, NStates > > controlpp::energy_scaling_matrix ( const Eigen::Matrix< ValueType, NStates, NStates >  A,
const Eigen::Matrix< ValueType, NStates, NInputs >  B,
const Eigen::Matrix< ValueType, NOutputs, NStates >  C 
)

Calculates the energy (Gramian) scaling via Lyapunov equations.

Calculates the scaling (similarity) matrix T so that the similar system:

\[ A' = T A T^{-1}, \quad B' = T B, \quad C' = C T^{-1}, \quad D' = D \]

has equal state energy.

This is especially useful, if a system has very small and very large entries of very small and large frequency components/dynamics.

Template Parameters
ValueTypeThe value type of the matrices. (E.g.: double, float)
NStatesThe number of states
NInputsThe number of inputs
NOutputsThe number of outputs
Parameters
AThe system state matrix (NStates x NStates)
BThe system input matrix (NStates x NInputs)
CThe system output matrix (NOutputs x NStates)
DThe system passthrough matrix (NOutputs x NInputs)
Returns
The tuple of matrices T and its inverse \(T^{-1}\) [T, T_inverse]

◆ expm()

template<class T , int N, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, N, N > controlpp::expm ( const Eigen::Matrix< T, N, N, Options, MaxRows, MaxCols > &  M)

Calculates the matrix exponent \( \exp{\mathbf{M}} \).

Uses a scaled pade approximation for the exponential.

The order and scaling factor are automatically determined based on the norm of the matrix.

Template Parameters
TThe value type of the matrix elements
RowsThe number of rows of the matrix
ColsThe number of columns of the matrix
Parameters
MThe matrix
Returns
The resulting exponentiated matrix
See also
controlpp::expm_pade
controlpp::expm_pade_scaled

◆ expm_pade()

template<class T , int N, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, N, N > controlpp::expm_pade ( const Eigen::Matrix< T, N, N, Options, MaxRows, MaxCols > &  A,
int  Order = 5 
)

Approximates \(\exp{A}\) using a pade fraction.

Exceptions
`std::invalid_argument`if the order is greater than 31
Template Parameters
TThe value type of the matrix entries (usually float or double)
RowsThe number of rows
ColsThe number of columns
OptionsMatrix options (See: Store Orders)
Parameters
AThe input matrix
OrderThe order of the numerator and denominator of the pade fraction
Returns
An approximation of the exponential \(\exp{A}\)

◆ expm_pade_params()

template<class T , int N, int Options, int MaxRows, int MaxCols>
ExpmPadeParams controlpp::expm_pade_params ( const Eigen::Matrix< T, N, N, Options, MaxRows, MaxCols > &  M)

Determines the order and scaling factor for the scaled pade approximation of the matrix exponential.

Higham, Nicholas J., and Desmond J. Higham. "A new scaling and squaring algorithm for the matrix exponential."

Template Parameters
TThe value type of the matrix entries (usually float or double)
MaxRowsThe maximum number of rows for the matrix (default is N)
MaxColsThe maximum number of columns for the matrix (default is N)
OptionsThe storage order of the matrix (see Eigen documentation)
NThe size of the square matrix
Parameters
MThe matrix for which to determine the parameters
Returns
The parameters for the scaled pade approximation, including the order and scaling factor

◆ expm_pade_scaled() [1/2]

template<class T , int N, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, N, N > controlpp::expm_pade_scaled ( const Eigen::Matrix< T, N, N, Options, MaxRows, MaxCols > &  M)

Matrix exponential using a scaled Pade approximation with automatic order and scaling factor determination.

Template Parameters
TThe value type of the matrix entries (usually float or double)
NThe size of the square matrix
OptionsThe storage order of the matrix (see Eigen documentation)
MaxRowsThe maximum number of rows for the matrix (default is N)
MaxColsThe maximum number of columns for the matrix (default is N)
Parameters
MThe matrix to exponentiate
Returns
The exponentiated matrix \(\exp{M}\) using the scaled Pade approximation with automatically determined order and scaling factor

◆ expm_pade_scaled() [2/2]

template<class T , int N, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, N, N > controlpp::expm_pade_scaled ( const Eigen::Matrix< T, N, N, Options, MaxRows, MaxCols > &  M,
int  order,
int  scaling 
)

Applies scaling and squaring to the pade approximation of the matrix exponential.

Template Parameters
TThe value type of the matrix entries (usually float or double)
NThe size of the square matrix
OptionsThe storage order of the matrix (see Eigen documentation)
MaxRowsThe maximum number of rows for the matrix (default is N)
MaxColsThe maximum number of columns for the matrix (default is N)
Parameters
MMatrix to exponentiate
orderOrder of the Pade approximation (default is 7)
scalingScaling factor for the matrix (default is 7)
Returns
The exponentiated matrix \(\exp{M}\) using the scaled Pade approximation

◆ expm_taylor()

template<class T , int Rows, int Cols, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > controlpp::expm_taylor ( const Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > &  x,
int  n 
)

Exponential function with a taylor approximation.

\[ \exp{x} = I + x + x^2 / 2 + ... + x^n / n! \]

The minimum number of n is 2. If n is set lower than 2, then 2 increments will be calculated regardless

Template Parameters
TThe value type
Parameters
xThe value taken to the exponent
nThe order of the taylor approximation (default: 3)
Returns
the exponentiated value
See also
controlpp::expm_taylor_scale
controlpp::expm

◆ expm_taylor_scaled()

template<class T , int Rows, int Cols, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > controlpp::expm_taylor_scaled ( const Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > &  M,
int  taylor_order = 8,
int  scaling = 10 
)

Calculates the matrix exponent \( \exp{\mathbf{M}} \).

Uses a scaled taylor approximation for the exponential.

Uses the following relationship:

\[ exp{x} = exp{x/s*s} = \left( exp{x/s} \right) ^ {s} \]

to improve accuracy, by scaling the value first, allowing for smaller taylor orders with increased accuracy.

Template Parameters
TThe value type of the matrix elements
RowsThe number of rows of the matrix
ColsThe number of columns of the matrix
Parameters
MThe matrix
taylor_orderThe order of the taylor polynomial used to approximate the exponential function
scalingThe scaling factor used to improve the accuracy of the exponential function
Returns
The resulting exponentiated matrix
See also
controlpp::expm_taylor

◆ find_enclosing() [1/2]

template<class T , int Size = Eigen::Dynamic>
std::optional< std::pair< const T *, const T * > > controlpp::find_enclosing ( const Eigen::Vector< T, Size > &  range,
const T &  v 
)

Finds elements in a range that enclose v.

Parameters
rangeThe range to search in/iterate through
vThe value to search for
Returns
a pair of [low, high] iterators that enclose the input value v or std::nullopt if no enclosing sub-range could be found.
See also
template<class Itr, class T> std::optional<std::tuple<Itr, Itr>> find_enclosing(Itr first, Itr last, const T& v)

◆ find_enclosing() [2/2]

template<class Itr , class T >
std::optional< std::pair< Itr, Itr > > controlpp::find_enclosing ( Itr  first,
Itr  last,
const T &  v 
)

Finds elements in a range that enclose v.

Searches for two elements in the range given by [first, last) such that *itr <= v && v <= *(itr+1) is true.

Parameters
firstthe first iterator of the range (points to the first element of the range)
lastthe last iterator of the range (points past the last element of the range)
vthe input value to search for
Returns
a pair of [low, high] iterators that enclose the input value v or std::nullopt if no enclosing sub-range could be found.

◆ from_dB()

template<class T >
T controlpp::from_dB ( const T &  value)

◆ hamilton_solver()

template<class T , int N>
requires (N % 2 == 0)
Eigen::Matrix< T, N/2, N/2 > controlpp::hamilton_solver ( const Eigen::Matrix< T, N, N >  H)

Solves the hamilton matrix.

For example when solveing the CARE (continuous time ricatti equation).

The solution of the hamiltoin matrix is understood as the result of the operations:

  1. Compute its stable eigenvectors
  2. Re-Partitions the eigenvectors
  3. Recovers X (ricatti result) from the partitions
Template Parameters
TThe value type of the parameters/matrix elements (ususally float or double)
NThe size of the hamilton matrix
Parameters
HThe hamilton matrix
Returns
The solution of the hamilton matrix
See also
lyapunov_solver
care_solver

◆ identity_like()

template<class T , int Rows, int Cols, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > controlpp::identity_like ( const Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > &  unused)

◆ join_to_diagonal()

template<class T , int LSize, int RSize>
Eigen::Matrix< T, LSize+RSize, LSize+RSize > controlpp::join_to_diagonal ( const Eigen::Vector< T, LSize > &  l,
const Eigen::Vector< T, RSize > &  r 
)

◆ join_to_vector() [1/2]

template<class T , int LSize, int RSize>
requires (LSize != Eigen::Dynamic && RSize != Eigen::Dynamic)
Eigen::Vector< T, LSize+RSize > controlpp::join_to_vector ( const Eigen::Vector< T, LSize > &  l,
const Eigen::Vector< T, RSize > &  r 
)

◆ join_to_vector() [2/2]

template<class T , int LSize, int RSize>
requires (!(LSize != Eigen::Dynamic && RSize != Eigen::Dynamic))
Eigen::Vector< T, Eigen::Dynamic > controlpp::join_to_vector ( const Eigen::Vector< T, LSize > &  l,
const Eigen::Vector< T, RSize > &  r 
)

◆ least_squares()

template<class T , int XRows, int XCols, int XOpt, int XMaxRows, int XMaxCols>
requires ((XRows >= XCols) || (XRows == Eigen::Dynamic) || (XCols == Eigen::Dynamic))
Eigen::Vector< T, XCols > controlpp::least_squares ( const Eigen::Matrix< T, XRows, XCols, XOpt, XMaxRows, XMaxCols > &  X,
const Eigen::Vector< T, XRows > &  y 
)

Solves the overdefined system \(y = X p\) for p.

There have to be more measurements than parameters. Meaning XRows >= XCols has to be true.

Parameters
Xthe systems matrix that describes how the parameters p can be transformed into the measured output y
ythe actual measured system output
Returns
the approximated optimal solution for the parameter vector p

◆ lqr() [1/2]

template<class T , int NStates, int NInputs, int NOutputs>
Eigen::Matrix< T, NInputs, NStates > controlpp::lqr ( const DiscreteStateSpace< T, NStates, NInputs, NOutputs >  Gss,
const Eigen::Matrix< T, NStates, NStates > &  Q,
const Eigen::Matrix< T, NInputs, NInputs > &  R 
)

Computes a discrete LQR controller from a discrete state space plant model.

Ways to choose Q (state penalty) and R (control penalty):

Brysons rule

[ Q = \text{diag}\left( \frac{1}{x^2_{1,\text{max}}}, \frac{1}{x^2_{2,\text{max}}}, \frac{1}{x^2_{3,\text{max}}}, \cdots \right) ]

[ R = \text{diag}\left( \frac{1}{u^2_{1,\text{max}}}, \frac{1}{u^2_{2,\text{max}}}, \frac{1}{u^2_{3,\text{max}}}, \cdots \right) ]

for states x and control inputs u.

Template Parameters
TThe value types of the parameters
NStatesThe number of states of the plant
NInputsThe number of inputs of the plant
NOutputsThen number of outputs of the plant
Parameters
QThe state weight matrix (penalizes large states)
RThe control weight matrix (penalizes control effort)
Returns
The gain matrix of the LQR controller as an Eigen::Matrix
See also
lqr_feed_forward

◆ lqr() [2/2]

template<class T , int NStates, int NInputs, int NOutputs, std::convertible_to< T > U1 = T, std::convertible_to< T > U2 = T>
Eigen::Matrix< T, NInputs, NStates > controlpp::lqr ( const DiscreteStateSpace< T, NStates, NInputs, NOutputs >  Gss,
const U1 &  r = static_cast<U1>(1),
const U2 &  eps = static_cast<U2>(0.001) 
)

Construcs a discrete LQR controller with automatic weights Q and R.

The weights Q (state penalty) and R (control penalty) are chosen automatically.

How Q is chosen:

\[ Q_1 = C^\top C; Q = Q_1 + I \| Q_1 \| \text{eps}^2; \]

How R is chosen:

\[ R = I * r \]

Template Parameters
TThe value type of the parameters
NStatesThe number of states of the plant
NInputsThe number of inputs of the plant
NOutputsThe number of outputs of the plant
Parameters
GssThe state space description of the plant
rThe control penalty (See r in the equations)
epsMakes sure to also penalises states that do not contribute to the output (see eps in the equations)
Returns
The LQR gain matrix as an Eigen::Matrix
See also
lqr_feed_forward

◆ lqr_bryson()

template<class T , int NStates, int NInputs, int NOutputs, std::convertible_to< T > U1 = T, std::convertible_to< T > U2 = T>
Eigen::Matrix< T, NInputs, NStates > controlpp::lqr_bryson ( const DiscreteStateSpace< T, NStates, NInputs, NOutputs >  Gss,
const Eigen::Vector< T, NOutputs > &  x_max,
const Eigen::Vector< T, NInputs > &  u_max 
)

Construcs a discrete LQR controller with weights trying to limit states and controller outputs.

The weights Q (state penalty) and R (control penalty) are chosen automatically to respect the limits $x_\text{max}$ (state limits) and $u_\text{max}$ (control output limits)

It is important to understand that those are not hard limits. The controller and the plant may overshoot the bounds - even by orders of magnitudes. It is just that a Q and R will be chosen where it is likely that the states and control signals stay within the bounds.

Chooses $Q$ as the diagonal matrix of $\frac{1}{x_\text{max}^2}$ and $R$ as $\frac{1}{u_\text{max}^2}$

Template Parameters
TThe value type of the parameters
NStatesThe number of states of the plant
NInputsThe number of inputs of the plant
NOutputsThe number of outputs of the plant
Parameters
GssThe state space description of the plant
x_max
u_max
Returns
The LQR gain matrix as an Eigen::Matrix
See also
lqr_feed_forward

◆ lqr_continuous()

template<class T , int NStates, int NInputs>
Eigen::Matrix< T, NInputs, NStates > controlpp::lqr_continuous ( const Eigen::Matrix< T, NStates, NStates > &  A,
const Eigen::Matrix< T, NStates, NInputs > &  B,
const Eigen::Matrix< T, NStates, NStates > &  Q = Eigen::Matrix<T, NStates, NStates>::Identity(),
const Eigen::Matrix< T, NInputs, NInputs > &  R = Eigen::Matrix<T, NInputs, NInputs>::Identity() 
)

Synthesizes the continuous LQR gain from plant matrices (A, B) and weights (Q, R)

Template Parameters
TThe valuetype of the parameters (usually float or double)
NStatesThe number of states in the plant
NInputsThe number of inputs of the plant
Parameters
APlant state transition matrix
BPlant input matrix
RControl wight matrix (Penalises control effort). Expected to be symetric positive definite
QState weight matrix (Penalises large plant states)
Returns
An LQR controller in contunuous state space form
See also
ContinuousStateSpace

◆ lqr_discrete()

template<class T , int NStates, int NInputs>
Eigen::Matrix< T, NInputs, NStates > controlpp::lqr_discrete ( const Eigen::Matrix< T, NStates, NStates > &  A,
const Eigen::Matrix< T, NStates, NInputs > &  B,
const Eigen::Matrix< T, NStates, NStates > &  Q = Eigen::Matrix<T, NStates, NStates>::Identity(),
const Eigen::Matrix< T, NInputs, NInputs > &  R = Eigen::Matrix<T, NInputs, NInputs>::Identity() 
)

Synthesizes the continuous LQR gain from plant matrices (A, B) and weights (Q, R)

Template Parameters
TThe valuetype of the parameters (usually float or double)
NStatesThe number of states in the plant
NInputsThe number of inputs of the plant
Parameters
APlant state transition matrix
BPlant input matrix
QState weight matrix (Penalises large plant states)
RControl wight matrix (Penalises control effort). Expected to be symetric positive definite
Returns
An LQR controller in contunuous state space form
See also
ContinuousStateSpace

◆ lqr_feed_forward()

template<class T , int NStates, int NInputs, int NOutputs>
Eigen::Matrix< T, NInputs, NOutputs > controlpp::lqr_feed_forward ( const DiscreteStateSpace< T, NStates, NInputs, NOutputs >  Gss,
Eigen::Matrix< T, NInputs, NStates >  LQR 
)

◆ lyapunov_solver()

template<class T , int NStates, int AOpt, int AMaxR, int AMaxC, int QOpt, int QMaxR, int QMaxC>
Eigen::Matrix< T, NStates, NStates > controlpp::lyapunov_solver ( const Eigen::Matrix< T, NStates, NStates, AOpt, AMaxR, AMaxC > &  A,
const Eigen::Matrix< T, NStates, NStates, QOpt, QMaxR, QMaxC > &  Q 
)

Solves the continuous time Lyapunov equation.

This function computes the stabilizing symmetric solution of the lyapunov equation:

\[ A^\top X + X A + Q = 0 \]

where A and Q are parameter and X is the matrix being solved for.


Soves the Lyapunov equation by:

  1. Building the Hamilton matrix
  2. Compute its stable eigenvectors
  3. Re-Partitions the eigenvectors
  4. Recovers X from the partitions
Parameters
AState matrix ( \(n \times n\)).
QState weighting matrix ( \(n \times n\), symmetric positive semidefinite).
Template Parameters
TScalar type (e.g., double, float).
NStatesDimension of the matrices
Returns
X the solution to the Lyapunov equation as an Eigen::Matrix with the dimensions NStates x NStates.
See also
hamilton_solver

◆ minor()

template<class T , int Rows, int Cols, int Options, int MaxRows, int MaxCols>
Eigen::Matrix< T, Rows-1, Cols-1 > controlpp::minor ( const Eigen::Matrix< T, Rows, Cols, Options, MaxRows, MaxCols > &  A,
size_t  ex_row,
size_t  ex_col 
)

returns the minor matrix excluding the provided column and row

Parameters
AThe source matrix
ex_rowThe row to be excluded
ex_colThe column to be excluded

◆ operator!=() [1/4]

template<class T , int N>
bool controlpp::operator!= ( const FixedPolynom< T, N > &  lhs,
const FixedPolynom< T, N > &  rhs 
)

◆ operator!=() [2/4]

template<class T , int N>
constexpr bool controlpp::operator!= ( const FixedRationalPolynom< T, N > &  lhs,
const FixedRationalPolynom< T, N > &  rhs 
)
constexpr

◆ operator!=() [3/4]

template<class T , int N>
bool controlpp::operator!= ( const Polynom< T, N > &  lhs,
const Polynom< T, N > &  rhs 
)

◆ operator!=() [4/4]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr bool controlpp::operator!= ( const TransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const TransferFunction< T, NumOrder1, DenOrder1 > &  rhs 
)
constexpr

◆ operator*() [1/23]

template<class T >
Bode< T > controlpp::operator* ( const Bode< T > &  l,
const Bode< T > &  r 
)

◆ operator*() [2/23]

template<class T , int NumOrder, int DenOrder>
Bode< T > controlpp::operator* ( const Bode< T > &  l,
const ContinuousTransferFunction< T, NumOrder, DenOrder > &  r 
)

◆ operator*() [3/23]

template<class T , std::convertible_to< T > T2>
Bode< T > controlpp::operator* ( const Bode< T > &  l,
const T2 &  r 
)

◆ operator*() [4/23]

template<class T , int NumOrder, int DenOrder>
Bode< T > controlpp::operator* ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  l,
const Bode< T > &  r 
)

◆ operator*() [5/23]

template<class T , class Tscalar , int NumOrder, int DenOrder>
auto controlpp::operator* ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  lhs,
const Tscalar &  rhs 
)

◆ operator*() [6/23]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
auto controlpp::operator* ( const ContinuousTransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const ContinuousTransferFunction< T, NumOrder2, DenOrder2 > &  rhs 
)

◆ operator*() [7/23]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr auto controlpp::operator* ( const DiscreteTransferFunction< T, NumOrder, DenOrder > &  lhs,
const Tscalar &  rhs 
)
constexpr

◆ operator*() [8/23]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr auto controlpp::operator* ( const DiscreteTransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const DiscreteTransferFunction< T, NumOrder2, DenOrder2 > &  rhs 
)
constexpr

◆ operator*() [9/23]

template<class T , int N>
FixedPolynom< T, N > controlpp::operator* ( const FixedPolynom< T, N > &  lhs,
const FixedPolynom< T, N > &  rhs 
)

Non growing multiplication.

Note that this multiplication does not grow the result to fit all posible values. The correct size has to be allocated beforehand by the user.

◆ operator*() [10/23]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
FixedPolynom< Tpoly, N > controlpp::operator* ( const FixedPolynom< Tpoly, N > &  lhs,
const Tscalar &  rhs 
)

◆ operator*() [11/23]

template<class T , int N>
constexpr FixedRationalPolynom< T, N > controlpp::operator* ( const FixedRationalPolynom< T, N > &  lhs,
const FixedRationalPolynom< T, N > &  rhs 
)
constexpr

◆ operator*() [12/23]

template<class T , std::convertible_to< T > Tscalar, int N>
constexpr FixedRationalPolynom< T, N > controlpp::operator* ( const FixedRationalPolynom< T, N > &  lhs,
const Tscalar &  rhs 
)
constexpr

◆ operator*() [13/23]

template<class T , int lOrder, int rOrder>
Polynom< T, lOrder+rOrder > controlpp::operator* ( const Polynom< T, lOrder > &  lhs,
const Polynom< T, rOrder > &  rhs 
)

◆ operator*() [14/23]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int Order>
Polynom< Tpoly, Order > controlpp::operator* ( const Polynom< Tpoly, Order > &  lhs,
const Tscalar &  rhs 
)

◆ operator*() [15/23]

template<class T , std::convertible_to< T > T2>
Bode< T > controlpp::operator* ( const T2 &  l,
const Bode< T > &  r 
)

◆ operator*() [16/23]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, NumOrder, DenOrder > controlpp::operator* ( const TransferFunction< T, NumOrder, DenOrder > &  lhs,
const Tscalar &  rhs 
)
constexpr

◆ operator*() [17/23]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr TransferFunction< T, NumOrder1+NumOrder2, DenOrder1+DenOrder2 > controlpp::operator* ( const TransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const TransferFunction< T, NumOrder2, DenOrder2 > &  rhs 
)
constexpr

◆ operator*() [18/23]

template<class T , class Tscalar , int NumOrder, int DenOrder>
auto controlpp::operator* ( const Tscalar &  lhs,
const ContinuousTransferFunction< T, NumOrder, DenOrder > &  rhs 
)

◆ operator*() [19/23]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr auto controlpp::operator* ( const Tscalar &  lhs,
const DiscreteTransferFunction< T, NumOrder, DenOrder > &  rhs 
)
constexpr

◆ operator*() [20/23]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
FixedPolynom< Tpoly, N > controlpp::operator* ( const Tscalar &  lhs,
const FixedPolynom< Tpoly, N > &  rhs 
)

◆ operator*() [21/23]

template<class T , std::convertible_to< T > Tscalar, int N>
constexpr FixedRationalPolynom< T, N > controlpp::operator* ( const Tscalar &  lhs,
const FixedRationalPolynom< T, N > &  rhs 
)
constexpr

◆ operator*() [22/23]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int Order>
Polynom< Tpoly, Order > controlpp::operator* ( const Tscalar &  lhs,
const Polynom< Tpoly, Order > &  rhs 
)

◆ operator*() [23/23]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, NumOrder, DenOrder > controlpp::operator* ( const Tscalar &  lhs,
const TransferFunction< T, NumOrder, DenOrder > &  rhs 
)
constexpr

◆ operator+() [1/18]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
auto controlpp::operator+ ( const ContinuousTransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const ContinuousTransferFunction< T, NumOrder2, DenOrder2 > &  rhs 
)

◆ operator+() [2/18]

template<class Tpoly , class Tscalar , int NumOrder, int DenOrder>
auto controlpp::operator+ ( const ContinuousTransferFunction< Tpoly, NumOrder, DenOrder > &  lhs,
const Tscalar &  rhs 
)

◆ operator+() [3/18]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr auto controlpp::operator+ ( const DiscreteTransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const DiscreteTransferFunction< T, NumOrder2, DenOrder2 > &  rhs 
)
constexpr

◆ operator+() [4/18]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int NumOrder, int DenOrder>
constexpr auto controlpp::operator+ ( const DiscreteTransferFunction< Tpoly, NumOrder, DenOrder > &  lhs,
const Tscalar &  rhs 
)
constexpr

◆ operator+() [5/18]

template<class T , int N>
FixedPolynom< T, N > controlpp::operator+ ( const FixedPolynom< T, N > &  lhs,
const FixedPolynom< T, N > &  rhs 
)

◆ operator+() [6/18]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
requires (N >= 1)
FixedPolynom< Tpoly, N > controlpp::operator+ ( const FixedPolynom< Tpoly, N > &  lhs,
const Tscalar &  rhs 
)

◆ operator+() [7/18]

template<class T , int N>
constexpr auto controlpp::operator+ ( const FixedRationalPolynom< T, N > &  lhs,
const FixedRationalPolynom< T, N > &  rhs 
)
constexpr

rational addition of polynomials

calculates:

\[ \frac{num_1(x)}{den_1(x)} \frac{num_2(x)}{den_2(x)} \]

Template Parameters
TThe value type of the polynomial parameters
NumOrder1The size of the numerator of the left-hand-side addition argument
DenOrder1The size of the denominator of the left-hand-side addition argument
NumOrder2The size of the numberator of the right-hand-side addition argument
DenOrder1The size of the denominator of the right-hand-side addition argument
Parameters
lhsThe left-hand-side additino argument as a rational polynom
rhsThe right-hand-side addition argument as a rational polynom

◆ operator+() [8/18]

template<class T , std::convertible_to< T > Tscalar, int N>
constexpr auto controlpp::operator+ ( const FixedRationalPolynom< T, N > &  lhs,
const Tscalar &  rhs 
)
constexpr

◆ operator+() [9/18]

template<class T , int Nl, int Nr>
Polynom< T,(Nl > Nr) ? Nl :Nr > controlpp::operator+ ( const Polynom< T, Nl > &  lhs,
const Polynom< T, Nr > &  rhs 
)

◆ operator+() [10/18]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
Polynom< Tpoly, N > controlpp::operator+ ( const Polynom< Tpoly, N > &  lhs,
const Tscalar &  rhs 
)

◆ operator+() [11/18]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, std::max(NumOrder, DenOrder), DenOrder > controlpp::operator+ ( const TransferFunction< T, NumOrder, DenOrder > &  lhs,
const Tscalar &  rhs 
)
constexpr

◆ operator+() [12/18]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr TransferFunction< T, std::max(NumOrder1+DenOrder2, NumOrder2+DenOrder1), DenOrder1+DenOrder2 > controlpp::operator+ ( const TransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const TransferFunction< T, NumOrder2, DenOrder2 > &  rhs 
)
constexpr

rational addition of polynomials

calculates:

\[ \frac{num_1(x)}{den_1(x)} \frac{num_2(x)}{den_2(x)} \]

Template Parameters
TThe value type of the polynomial parameters
NumOrder1The size of the numerator of the left-hand-side addition argument
DenOrder1The size of the denominator of the left-hand-side addition argument
NumOrder2The size of the numberator of the right-hand-side addition argument
DenOrder1The size of the denominator of the right-hand-side addition argument
Parameters
lhsThe left-hand-side additino argument as a rational polynom
rhsThe right-hand-side addition argument as a rational polynom

◆ operator+() [13/18]

template<class Tpoly , class Tscalar , int NumOrder, int DenOrder>
auto controlpp::operator+ ( const Tscalar &  lhs,
const ContinuousTransferFunction< Tpoly, NumOrder, DenOrder > &  rhs 
)

◆ operator+() [14/18]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int NumOrder, int DenOrder>
constexpr auto controlpp::operator+ ( const Tscalar &  lhs,
const DiscreteTransferFunction< Tpoly, NumOrder, DenOrder > &  rhs 
)
constexpr

◆ operator+() [15/18]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
requires (N >= 1)
FixedPolynom< Tpoly, N > controlpp::operator+ ( const Tscalar &  lhs,
const FixedPolynom< Tpoly, N > &  rhs 
)

◆ operator+() [16/18]

template<class T , std::convertible_to< T > Tscalar, int N>
constexpr auto controlpp::operator+ ( const Tscalar &  lhs,
const FixedRationalPolynom< T, N > &  rhs 
)
constexpr

◆ operator+() [17/18]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
Polynom< Tpoly, N > controlpp::operator+ ( const Tscalar &  lhs,
const Polynom< Tpoly, N > &  rhs 
)

◆ operator+() [18/18]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, std::max(NumOrder, DenOrder), DenOrder > controlpp::operator+ ( const Tscalar &  lhs,
const TransferFunction< T, NumOrder, DenOrder > &  rhs 
)
constexpr

◆ operator-() [1/29]

template<class T >
Bode< T > controlpp::operator- ( const Bode< T > &  b)

◆ operator-() [2/29]

template<class T >
Bode< T > controlpp::operator- ( const Bode< T > &  l,
const Bode< T > &  r 
)

◆ operator-() [3/29]

template<class T , int NumOrder, int DenOrder>
Bode< T > controlpp::operator- ( const Bode< T > &  l,
const ContinuousTransferFunction< T, NumOrder, DenOrder > &  r 
)

◆ operator-() [4/29]

template<class T , std::convertible_to< T > T2>
Bode< T > controlpp::operator- ( const Bode< T > &  l,
const T2 &  r 
)

◆ operator-() [5/29]

template<class T , int NumOrder, int DenOrder>
ContinuousTransferFunction< T, NumOrder, DenOrder > controlpp::operator- ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  a)

◆ operator-() [6/29]

template<class T , int NumOrder, int DenOrder>
Bode< T > controlpp::operator- ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  l,
const Bode< T > &  r 
)

◆ operator-() [7/29]

template<class T , class Tscalar , int NumOrder, int DenOrder>
auto controlpp::operator- ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  lhs,
const Tscalar &  rhs 
)

◆ operator-() [8/29]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
auto controlpp::operator- ( const ContinuousTransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const ContinuousTransferFunction< T, NumOrder2, DenOrder2 > &  rhs 
)

◆ operator-() [9/29]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr auto controlpp::operator- ( const DiscreteTransferFunction< T, NumOrder, DenOrder > &  lhs,
const Tscalar &  rhs 
)
constexpr

◆ operator-() [10/29]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr auto controlpp::operator- ( const DiscreteTransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const DiscreteTransferFunction< T, NumOrder2, DenOrder2 > &  rhs 
)
constexpr

◆ operator-() [11/29]

template<class T , int N>
FixedPolynom< T, N > controlpp::operator- ( const FixedPolynom< T, N > &  lhs,
const FixedPolynom< T, N > &  rhs 
)

◆ operator-() [12/29]

template<class T , int N>
FixedPolynom< T, N > controlpp::operator- ( const FixedPolynom< T, N > &  values)

◆ operator-() [13/29]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
requires (N >= 1)
FixedPolynom< Tpoly, N > controlpp::operator- ( const FixedPolynom< Tpoly, N > &  lhs,
const Tscalar &  rhs 
)

◆ operator-() [14/29]

template<class T , int N>
constexpr auto controlpp::operator- ( const FixedRationalPolynom< T, N > &  lhs,
const FixedRationalPolynom< T, N > &  rhs 
)
constexpr

◆ operator-() [15/29]

template<class T , std::convertible_to< T > Tscalar, int N>
constexpr auto controlpp::operator- ( const FixedRationalPolynom< T, N > &  lhs,
const Tscalar &  rhs 
)
constexpr

◆ operator-() [16/29]

template<class T , int N>
constexpr FixedRationalPolynom< T, N > controlpp::operator- ( const FixedRationalPolynom< T, N > &  poly)
constexpr

◆ operator-() [17/29]

template<class T , int N>
Polynom< T, N > controlpp::operator- ( const Polynom< T, N > &  poly)

◆ operator-() [18/29]

template<class T , int Nl, int Nr>
Polynom< T,(Nl > Nr) ? Nl :Nr > controlpp::operator- ( const Polynom< T, Nl > &  lhs,
const Polynom< T, Nr > &  rhs 
)

◆ operator-() [19/29]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
Polynom< Tpoly, N > controlpp::operator- ( const Polynom< Tpoly, N > &  lhs,
const Tscalar &  rhs 
)

◆ operator-() [20/29]

template<class T , std::convertible_to< T > T2>
Bode< T > controlpp::operator- ( const T2 &  l,
const Bode< T > &  r 
)

◆ operator-() [21/29]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, std::max(NumOrder, DenOrder), DenOrder > controlpp::operator- ( const TransferFunction< T, NumOrder, DenOrder > &  lhs,
const Tscalar &  rhs 
)
constexpr

◆ operator-() [22/29]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr TransferFunction< T, std::max(NumOrder1+DenOrder2, NumOrder2+DenOrder1), DenOrder1+DenOrder2 > controlpp::operator- ( const TransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const TransferFunction< T, NumOrder2, DenOrder2 > &  rhs 
)
constexpr

◆ operator-() [23/29]

template<class T , int NumOrder1, int DenOrder1>
constexpr TransferFunction< T, NumOrder1, DenOrder1 > controlpp::operator- ( const TransferFunction< T, NumOrder1, DenOrder1 > &  poly)
constexpr

◆ operator-() [24/29]

template<class T , class Tscalar , int NumOrder, int DenOrder>
auto controlpp::operator- ( const Tscalar &  lhs,
const ContinuousTransferFunction< T, NumOrder, DenOrder > &  rhs 
)

◆ operator-() [25/29]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr auto controlpp::operator- ( const Tscalar &  lhs,
const DiscreteTransferFunction< T, NumOrder, DenOrder > &  rhs 
)
constexpr

◆ operator-() [26/29]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
requires (N >= 1)
FixedPolynom< Tpoly, N > controlpp::operator- ( const Tscalar &  lhs,
const FixedPolynom< Tpoly, N > &  rhs 
)

◆ operator-() [27/29]

template<class T , std::convertible_to< T > Tscalar, int N>
constexpr auto controlpp::operator- ( const Tscalar &  lhs,
const FixedRationalPolynom< T, N > &  rhs 
)
constexpr

◆ operator-() [28/29]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
Polynom< Tpoly, N > controlpp::operator- ( const Tscalar &  lhs,
const Polynom< Tpoly, N > &  rhs 
)

◆ operator-() [29/29]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, std::max(NumOrder, DenOrder), DenOrder > controlpp::operator- ( const Tscalar &  lhs,
const TransferFunction< T, NumOrder, DenOrder > &  rhs 
)
constexpr

◆ operator/() [1/19]

template<class T >
Bode< T > controlpp::operator/ ( const Bode< T > &  l,
const Bode< T > &  r 
)

TODO: make it also work for bode that have different frequency vectors.

Template Parameters
T
Parameters
l
r
Returns

◆ operator/() [2/19]

template<class T , int NumOrder, int DenOrder>
Bode< T > controlpp::operator/ ( const Bode< T > &  l,
const ContinuousTransferFunction< T, NumOrder, DenOrder > &  r 
)

◆ operator/() [3/19]

template<class T , std::convertible_to< T > T2>
Bode< T > controlpp::operator/ ( const Bode< T > &  l,
const T2 &  r 
)

◆ operator/() [4/19]

template<class T , int NumOrder, int DenOrder>
Bode< T > controlpp::operator/ ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  l,
const Bode< T > &  r 
)

◆ operator/() [5/19]

template<class T , class Tscalar , int NumOrder, int DenOrder>
auto controlpp::operator/ ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  lhs,
const Tscalar &  rhs 
)

◆ operator/() [6/19]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
auto controlpp::operator/ ( const ContinuousTransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const ContinuousTransferFunction< T, NumOrder2, DenOrder2 > &  rhs 
)

◆ operator/() [7/19]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr auto controlpp::operator/ ( const DiscreteTransferFunction< T, NumOrder, DenOrder > &  lhs,
const Tscalar &  rhs 
)
constexpr

◆ operator/() [8/19]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr auto controlpp::operator/ ( const DiscreteTransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const DiscreteTransferFunction< T, NumOrder2, DenOrder2 > &  rhs 
)
constexpr

◆ operator/() [9/19]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int N>
FixedPolynom< Tpoly, N > controlpp::operator/ ( const FixedPolynom< Tpoly, N > &  lhs,
const Tscalar &  rhs 
)

◆ operator/() [10/19]

template<class T , int N>
constexpr auto controlpp::operator/ ( const FixedRationalPolynom< T, N > &  lhs,
const FixedRationalPolynom< T, N > &  rhs 
)
constexpr

◆ operator/() [11/19]

template<class T , std::convertible_to< T > Tscalar, int N>
constexpr auto controlpp::operator/ ( const FixedRationalPolynom< T, N > &  lhs,
const Tscalar &  rhs 
)
constexpr

◆ operator/() [12/19]

template<class Tpoly , std::convertible_to< Tpoly > Tscalar, int Order>
Polynom< Tpoly, Order > controlpp::operator/ ( const Polynom< Tpoly, Order > &  lhs,
const Tscalar &  rhs 
)

◆ operator/() [13/19]

template<class T , std::convertible_to< T > T2>
Bode< T > controlpp::operator/ ( const T2 &  l,
const Bode< T > &  r 
)

◆ operator/() [14/19]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, NumOrder, DenOrder > controlpp::operator/ ( const TransferFunction< T, NumOrder, DenOrder > &  lhs,
const Tscalar &  rhs 
)
constexpr

◆ operator/() [15/19]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr TransferFunction< T, NumOrder1+DenOrder2, DenOrder1+NumOrder2 > controlpp::operator/ ( const TransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const TransferFunction< T, NumOrder2, DenOrder2 > &  rhs 
)
constexpr

◆ operator/() [16/19]

template<class T , class Tscalar , int NumOrder, int DenOrder>
auto controlpp::operator/ ( const Tscalar &  lhs,
const ContinuousTransferFunction< T, NumOrder, DenOrder > &  rhs 
)

◆ operator/() [17/19]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr auto controlpp::operator/ ( const Tscalar &  lhs,
const DiscreteTransferFunction< T, NumOrder, DenOrder > &  rhs 
)
constexpr

◆ operator/() [18/19]

template<class T , std::convertible_to< T > Tscalar, int N>
constexpr auto controlpp::operator/ ( const Tscalar &  lhs,
const FixedRationalPolynom< T, N > &  rhs 
)
constexpr

◆ operator/() [19/19]

template<class T , std::convertible_to< T > Tscalar, int NumOrder, int DenOrder>
constexpr TransferFunction< T, DenOrder, NumOrder > controlpp::operator/ ( const Tscalar &  lhs,
const TransferFunction< T, NumOrder, DenOrder > &  rhs 
)
constexpr

◆ operator<<() [1/4]

template<class T >
std::ostream & controlpp::operator<< ( std::ostream &  stream,
const ComplexTimeSeries< T > &  timeseries 
)

◆ operator<<() [2/4]

template<class T , int NStates, int NInputs = 1, int NPerfOutputs = 1, int NMeasOutputs = 1, int NDisturbances = 1>
std::ostream & controlpp::operator<< ( std::ostream &  stream,
const ContinuousGeneralisedPlant< T, NStates, NInputs, NPerfOutputs, NMeasOutputs, NDisturbances > &  G 
)

◆ operator<<() [3/4]

std::ostream & controlpp::operator<< ( std::ostream &  stream,
dft_estimate_error  err 
)
inline

◆ operator<<() [4/4]

std::ostream & controlpp::operator<< ( std::ostream &  stream,
EBodeCsvReadError  val 
)

◆ operator==() [1/4]

template<class T , int N>
bool controlpp::operator== ( const FixedPolynom< T, N > &  lhs,
const FixedPolynom< T, N > &  rhs 
)

Compares two polynomials for equality.

Template Parameters
TThe datatype of the polynomials
NThe size of the polynomials
Parameters
lhsthe left-hand-side polynomial of the comparison
rhsthe right-hand-sode polynomial of the comparison
Returns
a boolean value that is true if both polynomials have the same parameters

◆ operator==() [2/4]

template<class T , int N>
constexpr bool controlpp::operator== ( const FixedRationalPolynom< T, N > &  lhs,
const FixedRationalPolynom< T, N > &  rhs 
)
constexpr

◆ operator==() [3/4]

template<class T , int N>
bool controlpp::operator== ( const Polynom< T, N > &  lhs,
const Polynom< T, N > &  rhs 
)

Compares two polynomials for equality.

Template Parameters
TThe datatype of the polynomials
NThe size of the polynomials
Parameters
lhsthe left-hand-side polynomial of the comparison
rhsthe right-hand-sode polynomial of the comparison
Returns
a boolean value that is true if both polynomials have the same parameters

◆ operator==() [4/4]

template<class T , int NumOrder1, int DenOrder1, int NumOrder2, int DenOrder2>
constexpr auto controlpp::operator== ( const TransferFunction< T, NumOrder1, DenOrder1 > &  lhs,
const TransferFunction< T, NumOrder1, DenOrder1 > &  rhs 
)
constexpr

◆ pade_delay()

template<class T , int NumOrder, int DenOrder = NumOrder>
requires (NumOrder <= DenOrder)
ContinuousTransferFunction< T, NumOrder, DenOrder > controlpp::pade_delay ( delay)

Creates a continuous transfer function approximating a delay using the pade approximation.

‍The standard Pade approximation where the order of the numerator is equal to the order of the denominator exhibits a jump at t=0 in its step response. To avoid this the use of pade approximations where the numerator order is one less than that of the denominator is reccomended. This gives a better step response

SOME REMARKS ON PADÉ-APPROXIMATION by M.Vajta

Parameters
delayThe delay that should be approximated using a
Template Parameters
TThe value type of the ContinuousTransferFunction
NumOrderThe order of the numerator
DenOrderThe order of the denominator
See also
https://ris.utwente.nl/ws/portalfiles/portal/134422804/Some_remarks_on_Pade-approximations.pdf

◆ pade_den_param()

template<class T = double>
constexpr T controlpp::pade_den_param ( unsigned long  m,
unsigned long  n,
unsigned long  k 
)
constexpr

Calculates the numerator parameters of the pade approximation.

Calculates the parameter:

\[ Q_k = \frac{(n + m - k)! n!}{(n + m)! k! (n - k)!} \]

For a Pade approximation like:

\[ A = \frac{\sum_{k = 0}^{m} P_k s^k}{\sum_{k = 0}^{n} Q_k s^k} \]

Parameters
mIs the order of the numerator
nIs the order of the denominator
kIs the order of the parameter
Template Parameters
Tthe result type of the function (used for the final division)
Returns
The pade parameter of the numerator at the k-th order
See also
pade_num_param
https://ris.utwente.nl/ws/portalfiles/portal/134422804/Some_remarks_on_Pade-approximations.pdf

◆ pade_num_param()

template<class T = double>
constexpr T controlpp::pade_num_param ( std::int32_t  m,
std::int32_t  n,
std::int32_t  k 
)
constexpr

Calculates the numerator parameters of the pade approximation.

Calculates the parameter:

\[ P_k = \frac{(m + n - k)! m!}{(m + n)! k! (m - k)!} \]

For a Pade approximation like:

\[ A = \frac{\sum_{k = 0}^{m} P_k s^k}{\sum_{k = 0}^{n} Q_k s^k} \]

Parameters
mIs the order of the numerator
nIs the order of the denominator
kIs the order of the parameter
Template Parameters
Theresult type of the division
Returns
The pade parameter of the numerator at the k-th order
See also
pade_den_param
https://ris.utwente.nl/ws/portalfiles/portal/134422804/Some_remarks_on_Pade-approximations.pdf

◆ pade_param_reccursice()

template<class T = double>
constexpr T controlpp::pade_param_reccursice ( P_k,
std::int32_t  m,
std::int32_t  n,
std::int32_t  k 
)
constexpr

Calculates the next pade parameter recursively.

use 1 as the first parameter to calculate the next parameter

\[ \frac{P_{k+1}}{P_k} = \frac{(m - k)}{(k + 1) (m + n - k)} \]

Parameters
P_kThe previous pade parameter
mThe order of the numerator
nThe order of the denominator
kThe order of the parameter
Returns
The next pade parameter

◆ pade_params()

template<class T = double>
constexpr void controlpp::pade_params ( T *  params,
std::size_t  size,
std::uint32_t  m,
std::uint32_t  n 
)
constexpr

Calculates all pade parameters up to the given size.

Parameters
paramsA pointer to an array of doubles to store the parameters
sizeThe size of the array
mThe order of the numerator
nThe order of the denominator
Template Parameters
TThe type of the parameters (default: double)

◆ poles() [1/2]

template<class T , int NumOrder, int DenOrder>
Eigen::Vector< std::complex< T >, DenOrder > controlpp::poles ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf)

◆ poles() [2/2]

template<class T , int NumOrder, int DenOrder>
Eigen::Vector< std::complex< T >, DenOrder+1 > controlpp::poles ( const TransferFunction< T, NumOrder, DenOrder > &  tf)

◆ pow()

template<class T >
constexpr T controlpp::pow ( const T &  base,
const int &  exp 
)
constexpr

Power function for integral exponents.

◆ prewarp_tustin() [1/2]

template<class T , int N>
Eigen::Vector< T, N > controlpp::prewarp_tustin ( const Eigen::Vector< T, N > &  omegas,
const T &  Ts 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
prewarp_tustin(const T& omega, const T& Ts)
prewarp_tustin(const Eigen::Vector<T, N>& omegas, const T& Ts)
unwarp_tustin(const T& omega, const T& Ts)
unwarp_tustin(const Eigen::Vector<T, N>& omegas, const T& Ts)

◆ prewarp_tustin() [2/2]

template<class T >
T controlpp::prewarp_tustin ( const T &  omega,
const T &  Ts 
)

Prewarps frequencies for the tustin transformation.

The tustin transformation stretches frequencies with the scaling:

\[ \omega_d = \frac{2}{T_s} \text{atan}\left( \frac{\omega_c T_s}{2} \right) \]

where:

  • \( \omega_c \) is the frequency set in continuous time
  • \( \omega_d \) is where the frequency will be placed at after discretisation (tustin)
  • \( T_s \) is the sample time of the discretisation

So for example if you place a continuous time notch filter at 300 Hz and then discretise it with the tustin transformation at a sample frequency of Fs=1kHz the discretised notch will land at 240.6 Hz.

To have the frequencies after the discretisation exactly at the given frequency we 'pre-warp' them with the inverse function which this function provides:

\[ \omega_\text{pre} = \frac{2}{T_s} \text{tan}\left( \frac{\omega_\text{target} T_s}{2} \right) \]

Note that this function returns rad/s and not rad/sample

Template Parameters
TThe value type
Parameters
omegaThe frequency before the pre-warping (in rad/s)
TsThe sample time that is also used for the tustin discretisation
Returns
The pre-warped/pre-scaled frequency (in rad/s) so that after applying the tustin transformation the set frequency is exactly at omega.
See also
prewarp_tustin(const T& omega, const T& Ts)
prewarp_tustin(const Eigen::Vector<T, N>& omegas, const T& Ts)
unwarp_tustin(const T& omega, const T& Ts)
unwarp_tustin(const Eigen::Vector<T, N>& omegas, const T& Ts)

◆ product_over()

template<class T >
constexpr T controlpp::product_over ( from,
to 
)
constexpr

Calculates the product of all numbers in the closed open range [from, to)

Returns
An integer
Template Parameters
TThe value type of the range
Parameters
fromThe first number in the range
toThe last number in the range (exclusive)

◆ read_bode_from_csv()

tl::expected< Bode< double >, std::variant< EBodeCsvReadError, csvd::ReadError > > controlpp::read_bode_from_csv ( std::istream &  stream,
const csvd::Settings &  csv_settings = csvd::Settings(),
EFrequencyInterpretation  freq_interp = EFrequencyInterpretation::AutoHz,
EMagnitudeInterpretation  mag_interp = EMagnitudeInterpretation::Auto,
EPhaseInterpretation  phase_interp = EPhaseInterpretation::AutoDeg 
)

Loads bode data from csv data.

TODO

Automatic data discovery:

First: searches for the frequency data range. Then for the real and imaginary data ranges. If real and imaginary data could not be identified magnitudes and phases will be searched for.

All following textual comparisons are case insensitive.

  • Assumes colums starting with "f" to be the frequency data.
    • If the frequency data name contains "hz" the frequency is interpreted as Hertz.
    • If the frequency data name contains "rad" the frequency is interpreted as Radiant.
  • Assumes columns starting with "re" or "im" to be the real and imaginary amplitudes.
  • If complex amplitudes could not be found assumes that columns starting with "mag" or "ph" to be absolute magnitudes and phase
    • If the magnitude column header contains "dB" the magnitude data will be interpreted in deci-Bell.
    • If the phase column header contains "deg" the phase data is interpreted in degree.
    • If the phase column header contains "rad" the phase data is interpreted in radiants.
See also
EFrequencyInterpretation
EMagnitudeInterpretation
EPhaseInterpretation
Parameters
stream
settings
Returns
If successful: A bode structure. On failure/error: a variant with an error of the csv reader (csvd::ReadError) or an error of assembing a bode from the csv EBodeCsvReadError.

◆ shift_up() [1/2]

template<class Iterator , class T >
void controlpp::shift_up ( Iterator  first,
Iterator  last,
const T &  v0 = T(0) 
)

Shifts the values in a range up by one position and inserts a new value (copy operation) at the beginning of the range.

Template Parameters
IteratorThe type of the iterators that define the range to shift
TThe type of the value to insert at the beginning of the range
Parameters
firstThe first iterator of the range (points to the first element of the range)
lastThe last iterator of the range (points past the last element of the range)
v0The value to insert at the beginning of the range (default: T(0))

◆ shift_up() [2/2]

template<class Iterator , class T >
void controlpp::shift_up ( Iterator  first,
Iterator  last,
T &&  v0 = T(0) 
)

Shifts the values in a range up by one position and inserts a new value (move operation) at the beginning of the range.

Template Parameters
IteratorThe type of the iterators that define the range to shift
TThe type of the value to insert at the beginning of the range
Parameters
firstThe first iterator of the range (points to the first element of the range)
lastThe last iterator of the range (points past the last element of the range)
v0The value to insert at the beginning of the range (default: T(0))

◆ slowest_fastest_frequencies()

template<class T , int NumOrder, int DenOrder>
std::tuple< T, T > controlpp::slowest_fastest_frequencies ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf,
alternative = static_cast<T>(1) 
)

Calculates the slowest (lowest) and fastest (highest) frequencies of a continuous transfer function.

Example:

const auto [slowest, fastest] = slowest_fastest_frequencies(tf);
std::tuple< T, T > slowest_fastest_frequencies(const ContinuousTransferFunction< T, NumOrder, DenOrder > &tf, T alternative=static_cast< T >(1))
Calculates the slowest (lowest) and fastest (highest) frequencies of a continuous transfer function.
Definition analysis.hpp:66
Parameters
tfA continuous time transfer function
alternativeThe value to be returned if the transfer function has no dynamics and frequencies to be evaluated.
Returns
A tuple [slowest_frequency, fastest_frequency] containing the fastest and slowest frequencies or the alternative.

◆ step() [1/3]

template<class T , int NumOrder, int DenOrder>
TimeSeries< T > controlpp::step ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf)

◆ step() [2/3]

template<class T , int NumOrder, int DenOrder>
TimeSeries< T > controlpp::step ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf,
const T &  sample_time,
const T &  simulation_time 
)

◆ step() [3/3]

template<class T , int NStates>
TimeSeries< T > controlpp::step ( const DiscreteStateSpace< T, NStates, 1, 1 > &  dss,
double  Ts,
double  simulation_time 
)

calculates the step response of a system

Parameters
dssA discrete state space model of the system
TsThe sampling frequency
simulation_timeThe time to be simulated
Returns
A time series of dynamically sized Eigen::Vectors

◆ symplectic_solver()

template<class T , int N>
Eigen::Matrix< T, N/2, N/2 > controlpp::symplectic_solver ( const Eigen::Matrix< T, N, N >  S)

Solves the hamilton matrix.

For example when solveing the CARE (continuous time ricatti equation).

The solution of the hamiltoin matrix is understood as the result of the operations:

  1. Compute its stable eigenvectors
  2. Re-Partitions the eigenvectors
  3. Recovers X (ricatti result) from the partitions
Template Parameters
TThe value type of the parameters/matrix elements (ususally float or double)
NThe size of the hamilton matrix
Parameters
HThe hamilton matrix
Returns
The solution of the hamilton matrix
See also
lyapunov_solver
care_solver

◆ to_continuous_state_space() [1/2]

template<class T , int NumOrder, int DenOrder>
ContinuousStateSpace< T, DenOrder, 1, 1 > controlpp::to_continuous_state_space ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  ctf)

constructs a continuous state space function from a continuous transfer function

◆ to_continuous_state_space() [2/2]

template<class T , int NumOrder, int DenOrder>
ContinuousStateSpace< T, DenOrder, 1, 1 > controlpp::to_continuous_state_space ( const TransferFunction< T, NumOrder, DenOrder > &  rp)

constructs a continuous state space function from a rational polynom

◆ to_dB()

template<class T >
T controlpp::to_dB ( const T &  value)

◆ to_deg() [1/2]

template<class T , int N>
Eigen::Vector< T, N > controlpp::to_deg ( const Eigen::Vector< T, N > &  rad)

◆ to_deg() [2/2]

template<class T >
T controlpp::to_deg ( const T &  rad)

◆ to_discrete_state_space() [1/2]

template<class ValueType , int NumOrder, int DenOrder>
DiscreteStateSpace< ValueType, DenOrder, 1, 1 > controlpp::to_discrete_state_space ( const DiscreteTransferFunction< ValueType, NumOrder, DenOrder > &  dtf)

constructs a continuous state space function from a continuous transfer function

◆ to_discrete_state_space() [2/2]

template<class T , int NumOrder, int DenOrder>
requires (NumOrder <= DenOrder)
DiscreteStateSpace< T, DenOrder, 1, 1 > controlpp::to_discrete_state_space ( const TransferFunction< T, NumOrder, DenOrder > &  rp)

constructs a discrete state space function from a rational polynom

◆ to_hz() [1/2]

template<class T , int N>
Eigen::Vector< T, N > controlpp::to_hz ( const Eigen::Vector< T, N > &  radps)

◆ to_hz() [2/2]

template<class T >
T controlpp::to_hz ( const T &  radps)

Converts a number from radiants per second to herz.

Template Parameters
TThe data type
Parameters
radpsThe input value in radiants per second
Returns
A value in herz

◆ to_rad() [1/2]

template<class T , int N>
Eigen::Vector< T, N > controlpp::to_rad ( const Eigen::Vector< T, N > &  deg)

◆ to_rad() [2/2]

template<class T >
T controlpp::to_rad ( const T &  deg)

◆ to_radps() [1/2]

template<class T , int N>
Eigen::Vector< T, N > controlpp::to_radps ( const Eigen::Vector< T, N > &  hz)

◆ to_radps() [2/2]

template<class T >
T controlpp::to_radps ( const T &  hz)

Converts a number from herz to radiants per second.

Template Parameters
TThe data type
Parameters
radpsThe input value in herz
Returns
A value in herz

◆ to_state_space() [1/4]

template<class T , int NumOrder, int DenOrder>
ContinuousStateSpace< T, DenOrder, 1, 1 > controlpp::to_state_space ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  ctf)

constructs a continuous state space function from a continuous transfer function

◆ to_state_space() [2/4]

template<class ValueType , int NumOrder, int DenOrder>
DiscreteStateSpace< ValueType, DenOrder, 1, 1 > controlpp::to_state_space ( const DiscreteTransferFunction< ValueType, NumOrder, DenOrder > &  dtf)

constructs a continuous state space function from a continuous transfer function

◆ to_state_space() [3/4]

template<class T , int NRows, int NCols, int Opts, int NMaxRows, int NMaxCols>
StateSpace< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::Dynamic > controlpp::to_state_space ( const Eigen::Matrix< TransferFunction< T, Eigen::Dynamic, Eigen::Dynamic >, NRows, NCols, Opts, NMaxRows, NMaxCols > &  Mtf)

Generates the block diagonal state space representation of the system of transfer functions.

The matrix of transfer functions represensts a multiple input and multiple output system where:

  • the number of rows corresponds to the systems outputs
  • and the number of columns corresponds to the systems inputs
Template Parameters
TThe data type of the matrix elements and transfer function parameters. (Usually float or double)
Parameters
MtfA Matrix of transfer functions
Returns
The state space representation of the matrix of transfer functions

◆ to_state_space() [4/4]

template<class T , int NumOrder, int DenOrder>
StateSpace< T, DenOrder, 1, 1 > controlpp::to_state_space ( const TransferFunction< T, NumOrder, DenOrder > &  rp)

calculates the observer-normed state space representation from a rational polynomial

◆ to_state_space_controller_norm()

template<class T , int NumOrder, int DenOrder>
StateSpace< T, DenOrder, 1, 1 > controlpp::to_state_space_controller_norm ( const TransferFunction< T, NumOrder, DenOrder > &  rp)

calculates the control-normed state space representation from a rational polynomial

The transfer function:

\[ Tf(s) = \frac{b_0 + b_1 s + \cdots + b_n s^{n}}{a_0 + a_1 s + \cdots + a_n s^{n}} \]

will be turned into the state space system:

\[ \dot{x} = A x + B u y = C x + D u \]

with:

\[ \hat{a}_j = a_j / a_n \]

\[ \hat{b}_j = b_j / a_n \]

\[ A = \begin{bmatrix} 0 & 1 & 0 & 0 & \cdots & 0 \\ 0 & 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & 0 & \cdots & 1 \\ -\hat{a}_0 & -\hat{a}_1 & -\hat{a}_2 & -\hat{a}_3 & \cdots & -\hat{a}_{n-1} \end{bmatrix} \]

\[ B = \begin{bmatrix} 0 \\ \vdots \\ 1 \end{bmatrix} \]

\[ C = \begin{bmatrix} \hat{b}_0 - \hat{a}_0 \hat{b}_n & b_1 - \hat{a}_1 \hat{b}_n & \cdots & \hat{b}_{n-1} - \hat{a}_{n-1} \hat{b}_n \end{bmatrix} \]

\[ D = \hat{b}_n \]

◆ to_state_space_observer_norm()

template<class T , int NumOrder, int DenOrder>
StateSpace< T, DenOrder, 1, 1 > controlpp::to_state_space_observer_norm ( const TransferFunction< T, NumOrder, DenOrder > &  rp)

calculates the observer-normed state space representation from a rational polynomial

◆ to_string()

std::string_view controlpp::to_string ( dft_estimate_error  err)
inline

◆ to_transfer_function() [1/2]

template<class T , int states>
ContinuousTransferFunction< T, states+1, states+1 > controlpp::to_transfer_function ( const ContinuousStateSpace< T, states, 1, 1 > &  dss)

Transforms a discrete state space system to a discrete transfer function.

Returns
a discrete transfer function controlpp::DiscreteTransferFunction
See also
controlpp::DiscreteTransferFunction

◆ to_transfer_function() [2/2]

template<class T , int states>
TransferFunction< T, states+1, states+1 > controlpp::to_transfer_function ( const StateSpace< T, states, 1, 1 > &  css)

transforms a continuous state space system representation to a transfer function representation

Uses the formular:

\[ G(s) = \mathbf{C} \left( s \mathbf{I} - \mathbf{A} \right)^{-1} \mathbf{B} + D \]

◆ unwarp_tustin() [1/2]

template<class T , int N>
Eigen::Vector< T, N > controlpp::unwarp_tustin ( const Eigen::Vector< T, N > &  omegas,
const T &  Ts 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
prewarp_tustin(const T& omega, const T& Ts)
prewarp_tustin(const Eigen::Vector<T, N>& omegas, const T& Ts)
unwarp_tustin(const T& omega, const T& Ts)
unwarp_tustin(const Eigen::Vector<T, N>& omegas, const T& Ts)

◆ unwarp_tustin() [2/2]

template<class T >
T controlpp::unwarp_tustin ( const T &  omega,
const T &  Ts 
)

provides the inverse to prewarp_tustin:

\[ \omega_d = \frac{2}{T_s} \text{atan}\left( \frac{\omega_c T_s}{2} \right) \]

Calculates where the tustin transformation would actually place the frequency after discretisation.

Template Parameters
TThe value type
Parameters
omegaThe input frequency
TsThe sample time
Returns
The frequency where the tustin transformation would actually place the frequency after discretisation
See also
prewarp_tustin(const T& omega, const T& Ts)
prewarp_tustin(const Eigen::Vector<T, N>& omegas, const T& Ts)
unwarp_tustin(const T& omega, const T& Ts)
unwarp_tustin(const Eigen::Vector<T, N>& omegas, const T& Ts)

◆ unwrap()

template<class T , int N>
Eigen::Vector< T, N > controlpp::unwrap ( const Eigen::Vector< T, N > &  y,
const T &  modulo 
)

Unwinds modulo jumps.

Checks wheather jumps in occur that are larger than the threshold, and if so the modulo is added or subtracted n times so that the step \(y_{k+1} - y_{k}\) is within the bounds [-threshold, +threshold].

Parameters
yThe vector to be unwrapped
moduloThe modulo to unwrap. Will be added/subtracted n times to minimize variance.
Returns
An eigen vector, the size of the input with the unwrapped values

◆ unwrap_deg()

template<class T , int N>
Eigen::Vector< T, N > controlpp::unwrap_deg ( const Eigen::Vector< T, N > &  phases)

Unwinds phase jumps of \(2 \pi\) in degrees.

Parameters
phaseA vector op phases (deg)
Returns
A vector with the corrected phases (deg)
See also
unwrap
unwrap_rad

◆ unwrap_rad()

template<class T , int N>
Eigen::Vector< T, N > controlpp::unwrap_rad ( const Eigen::Vector< T, N > &  phases)

Unwinds phase jumps of \(2 \pi\) in radiants.

Parameters
phaseA vector op phases (rad)
Returns
A vector with the corrected phases (rad)
See also
unwrap
unwrap_deg

◆ write_csv() [1/2]

template<class T >
void controlpp::write_csv ( std::ostream &  stream,
const Bode< T > &  bode 
)

Prints a bode plot to an output stream as a .csv file.

Parameters
streamThe stream to be printed to
bodeThe bode container with the frequencies, magnitudes and phases
Returns
A reference to the stream object for operation chaining.
See also
Bode

◆ write_csv() [2/2]

template<class T >
void controlpp::write_csv ( std::ostream &  stream,
const TimeSeries< T > &  timeseries 
)

Prints the timeseries as a .csv file.

Template Parameters
TThe datatype of the timeseries
NThe size of the timeseries
Parameters
streamThe output stream/file that should be printed to
timeseriesThe timeseries holding the data
Returns
a reference to the stream for operator<< chaining

◆ zeros() [1/6]

template<class T , int NumOrder, int DenOrder>
Eigen::Vector< std::complex< T >, NumOrder > controlpp::zeros ( const ContinuousTransferFunction< T, NumOrder, DenOrder > &  tf)

◆ zeros() [2/6]

template<class T >
Eigen::Vector< std::complex< T >, 0 > controlpp::zeros ( const Polynom< T, 0 > &  polynom)

Returns an empty vector resembling the absence of solutions.

◆ zeros() [3/6]

template<class T >
Eigen::Vector< std::complex< T >, 1 > controlpp::zeros ( const Polynom< T, 1 > &  polynom)

calculates the zeros/roots of a polynomial

Specialisation for polynomials of degree 1.

Solves the following equation:

\[ 0 = a_0 + a_1 x \]

Returns
an eigen vector of complex numbers which are the roots of the polynomial

◆ zeros() [4/6]

template<class T >
Eigen::Vector< std::complex< T >, 2 > controlpp::zeros ( const Polynom< T, 2 > &  polynom)

calculates the zeros/roots of a polynomial

Specialisation for polynomials of degree 1.

\[ 0 = a_0 + a_1 x + a_2 x^2 \]

Returns
an eigen vector of complex numbers which are the roots of the polynomial

◆ zeros() [5/6]

template<class T , int N>
requires (N > 1)
Eigen::Vector< std::complex< T >, N > controlpp::zeros ( const Polynom< T, N > &  polynom)

Calculates the zeros of a polynomial.

Uses the companion matrix to solve for the zeros of the polynomial

◆ zeros() [6/6]

template<class T , int NumOrder, int DenOrder>
Eigen::Vector< std::complex< T >, NumOrder+1 > controlpp::zeros ( const TransferFunction< T, NumOrder, DenOrder > &  tf)