PID Control 1.0
Discrete time implementation of P, PI, PD, PID. Including derivative filter, integral clamping, feed-forward, gain scheduling in standard and parallel form.
Loading...
Searching...
No Matches
utility.h File Reference

Utility functions for the Control System library. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T>
constexpr T saturate (T x, T x_min, T x_max)
 Saturates a value within a specified range.

Detailed Description

Utility functions for the Control System library.

This header provides generic utility functions used by the control system components.

Author
Abhinay Kumar
Version
1.0.0
Date
2026-08-11

Definition in file utility.h.

Function Documentation

◆ saturate()

template<typename T>
T saturate ( T x,
T x_min,
T x_max )
inlineconstexpr

Saturates a value within a specified range.

If x is less than the minimum limit, the minimum limit is returned. If x is greater than the maximum limit, the maximum limit is returned. Otherwise, the input value is returned unchanged.

The function is implemented as a generic function and can be used with different numeric types.

Template Parameters
TNumeric data type.
Parameters
[in]xInput value to be saturated.
[in]x_minMinimum allowed value.
[in]x_maxMaximum allowed value.
Returns
Saturated value within the range [x_min, x_max].
Note
The caller should ensure that x_min is less than or equal to x_max.
Example
double output = saturate(input, -10.0, 10.0);
constexpr T saturate(T x, T x_min, T x_max)
Saturates a value within a specified range.
Definition utility.h:51

Definition at line 51 of file utility.h.