![]() |
Controlpp
|
Utilities to work with Bode data. More...
Functions | |
| template<class T > | |
| Bode< T > | controlpp::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 > | controlpp::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 > & | controlpp::frequencies (const Bode< T > &bode) |
| Converts and returns the frequency vector in rad. | |
| template<class T > | |
| Eigen::Vector< T, Eigen::Dynamic > | controlpp::frequencies_hz (const Bode< T > &bode) |
| Converts and returns the frequency vector in Hz. | |
| template<class T > | |
| Eigen::Vector< T, Eigen::Dynamic > | controlpp::real (const Bode< T > &bode) |
| Converts and returns the frequency vector in rad/s. | |
| template<class T > | |
| Eigen::Vector< T, Eigen::Dynamic > | controlpp::imag (const Bode< T > &bode) |
| Converts and returns the frequency vector in rad/s. | |
| template<class T > | |
| const Eigen::Vector< T, Eigen::Dynamic > & | controlpp::values (const Bode< T > &bode) |
| Returns the complex values of the bode data. | |
| template<class T > | |
| Eigen::Vector< T, Eigen::Dynamic > | controlpp::magnitudes (const Bode< T > &bode) |
| Creates a vector containing the absolute magnitudes. | |
| template<class T > | |
| Eigen::Vector< T, Eigen::Dynamic > | controlpp::magnitudes_dB (const Bode< T > &bode) |
| Creates a vector of magnitudes in dB. | |
| template<class T > | |
| Eigen::Vector< T, Eigen::Dynamic > | controlpp::phases (const Bode< T > &bode) |
| Creates a vector of phases in rad. | |
| template<class T > | |
| Eigen::Vector< T, Eigen::Dynamic > | controlpp::phases_deg (const Bode< T > &bode) |
| Creates a vector of phases in degree. | |
| template<class T > | |
| TimeSeries< T > | controlpp::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 > | controlpp::impulse (const Bode< T > &bode) |
| Calculates the time-series of a frequency response. | |
| template<class T > | |
| void | controlpp::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 > | controlpp::step (const Bode< T > &bode) |
| Calculates the step response time-value pairs from frequency-value data. | |
| template<class T > | |
| TimeSeries< T > | controlpp::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 > | controlpp::operator+ (const Bode< T > &l, const Bode< T > &r) |
| Adds two bode plots together. | |
| template<class T , std::convertible_to< T > T2> | |
| Bode< T > | controlpp::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 > | controlpp::operator+ (const T2 &l, const Bode< T > &r) |
| Adds a scalar value and a bode plot together. | |
| template<class T > | |
| Bode< T > | controlpp::operator+ (const Bode< T > &b) |
| Negates the bode plot values. | |
Utilities to work with Bode data.
| const Eigen::Vector< T, Eigen::Dynamic > & controlpp::frequencies | ( | const Bode< T > & | bode | ) |
Converts and returns the frequency vector in rad.
Note that this will use a const reference from the bode data and will not allocate a new vector.
| bode | The bode data to get the frequencies from |
| Eigen::Vector< T, Eigen::Dynamic > controlpp::frequencies_hz | ( | const Bode< T > & | bode | ) |
Converts and returns the frequency vector in Hz.
Note that this will allocate a new vector.
| bode | The bode data to get the frequencies from |
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| Eigen::Vector< T, Eigen::Dynamic > controlpp::imag | ( | const Bode< T > & | bode | ) |
Converts and returns the frequency vector in rad/s.
Note that this will allocate a new vector.
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| bode | The bode data |
| TimeSeries< T > controlpp::impulse | ( | const Bode< T > & | bode | ) |
Calculates the time-series of a frequency response.
Allows for arbitrary number, spacing and density-changes of samples.
Automatically estimates time-steps and the simulation time from the bode data.
Tip: For step responses do not do:
instead use the step function
| bode | A frequency response or bode plot/measurement |
| TimeSeries< T > controlpp::impulse | ( | const Bode< T > & | bode, |
| const T & | time_step, | ||
| const T & | simulation_time | ||
| ) |
Calculates the impulse-response of frequency data.
Assumes the frequency-response is only the one sided analytical form containing only positive frequencies. Thus it extends the frequency response to negative frequencies by mirroring it around the y axis in its conjugate complex form.
Uses linear piecewise first order integration in between data points
If the bode does not include a DC frequency sample (at 0 Hz) one will be added with the value of the smallest frequency in the data
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| bode | The frequency response data (assumed to only contain the one sided positive frequencies) |
| time_step | The timestep for the integration |
| simulation_time | The simulation time over which to simulate. This is the minimal simulation time and may be overstepped by one timestep. |
| void controlpp::integrate | ( | TimeSeries< T > & | out, |
| const TimeSeries< T > & | in, | ||
| const T & | v0 = T(0) |
||
| ) |
Integrates the time series and writes it to out.
Resizes out accordingly
out and in may be the same time-series object
| T | The value type |
| out | The output time-series where the result will be written to |
| in | The input time-series that will be integrated over |
| v0 | The start of the integration. Integration constant C in other nomiclatures. |
| Eigen::Vector< T, Eigen::Dynamic > controlpp::magnitudes | ( | const Bode< T > & | bode | ) |
Creates a vector containing the absolute magnitudes.
Calculates the absolute magnitudes from the complex magnitudes.
Will allocate a new vector and return it.
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| bode | The bode data |
| Eigen::Vector< T, Eigen::Dynamic > controlpp::magnitudes_dB | ( | const Bode< T > & | bode | ) |
Creates a vector of magnitudes in dB.
Calculates the magnitudes from the complex magnitudes.
Will allocate a new vector and return it.
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| bode | The bode data |
Adds two bode plots together.
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| l | Bode data on the left side of the addition operator |
| r | Bode data on the right side of the addition operator |
| Bode< T > controlpp::operator+ | ( | const Bode< T > & | l, |
| const T2 & | r | ||
| ) |
Adds a bode plot and a scalar value together.
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| T2 | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| l | Bode data on the left side of the addition operator |
| r | A scalar value on the right side of the addition operator |
| Bode< T > controlpp::operator+ | ( | const T2 & | l, |
| const Bode< T > & | r | ||
| ) |
Adds a scalar value and a bode plot together.
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| T2 | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| l | A scalar value on the left side of the addition operator |
| r | Bode data on the right side of the addition operator |
| Eigen::Vector< T, Eigen::Dynamic > controlpp::phases | ( | const Bode< T > & | bode | ) |
Creates a vector of phases in rad.
Calculates the phases from the complex magnitudes
Will allocate a new vector.
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| bode | The bode data |
| Eigen::Vector< T, Eigen::Dynamic > controlpp::phases_deg | ( | const Bode< T > & | bode | ) |
Creates a vector of phases in degree.
Calculates the phases from the complex magnitudes
Will allocate a new vector.
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| bode | The bode data |
Prewarps the frequency axis of a bode plot for tustin discretisation.
Note that this will allocate a new Bode object.
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| bode | The bode data to prewarp |
| Ts | The sample time that also the tustin discretisation is using. |
| Eigen::Vector< T, Eigen::Dynamic > controlpp::real | ( | const Bode< T > & | bode | ) |
Converts and returns the frequency vector in rad/s.
Note that this will allocate a new vector.
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| bode | The bode data |
| TimeSeries< T > controlpp::step | ( | const Bode< T > & | bode | ) |
Calculates the step response time-value pairs from frequency-value data.
Internally this will calculate the impulse response first and then integrates in the time domain. This way is numerically more stable than integrating in the frequency domain by 1/s multiplication and transforming that.
Automatically estimates the time-step and simulation time from the bode/frequency-response data.
| T | The data type. Typically float or double. |
| bode | The step response of the system |
| TimeSeries< T > controlpp::step | ( | const Bode< T > & | bode, |
| const T & | time_step, | ||
| const T & | simulation_time | ||
| ) |
Calculates the step response time-value pairs from frequency-value data.
| T | The data type. Typically float or double. |
| bode | The step response of the system |
| time_step | The time step used for the time series data |
| simulation_time | The time until the step response will be calculated (+1 for rounding). |
Unwarps the frequency axis of a bode plot for tustin discretisation.
Note that this will allocate a new Bode object.
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| bode | The bode data to unwarp |
| Ts | The sample time that also the tustin discretisation is using. |
| const Eigen::Vector< T, Eigen::Dynamic > & controlpp::values | ( | const Bode< T > & | bode | ) |
Returns the complex values of the bode data.
Will allocate a new vector and return it.
| T | The value type used to represent numbers. Usually float, double or a custom fixpoint type |
| bode | The bode data |