Utility Functions and Macros
WinchControllers.@limit
— Macromacro limit(name, minmax, max=nothing)
Limit the value of a variable.
Parameters:
- name: the name of the scalar variable that shall be limited
- minmax: if max is provided, this is the lower value to which the variable is clamped, otherwise it is the upper value
- max: the upper value to which to limit the provided variable or nothing
Usage:
- @limit x 1 4 # limits the value to the range 1 .. 4, modifies x
- @limit x 10 # limits the value to the range -inf .. 10, modifies x
WinchControllers.saturate
— Functionsaturate(value, min_, max_)
Calculate a saturated value, that stays within the given limits.
Parameters:
- value: the input value
- min_: the lower value to which it shall be clamped
- max_: the upper value to which it shall be clamped
Returns:
- the clamped value
Remark:
- consider using the function
clamp
or the macro@limit
instead
WinchControllers.merge_angles
— Functionmerge_angles(alpha, beta, factor_beta)
Calculate the weighted average of two angles. The weight of beta, factor_beta must be between 0 and 1.
WinchControllers.get_startup
— Functionget_startup(wcs::WCSettings, samples)
Create a signal, that is rising with wcs.t_startup from zero to one and then stays constant.
Parameters:
- wcs: the winch controller settings
- samples: the number of samples to create
Returns:
- a vector of length
samples
with the startup signal
WinchControllers.get_triangle_wind
— Functionget_triangle_wind(wcs::WCSettings, min, max, freq, samples)
Create a triangle wind signal, that varies between min and max with the given frequency.
Parameters:
- wcs: the winch controller settings
- min: the minimum wind speed
- max: the maximum wind speed
- freq: the frequency of the triangle wave
- samples: the number of samples to create
Returns:
- a vector of length
samples
with the triangle wind signal
WinchControllers.rms
— Functionrms(x)
Compute the root mean square (RMS) of the input vector x
.
Arguments
x
: A vector of numerical values.
Returns
- The root mean square value of the vector
x
, calculated asnorm(x) / sqrt(length(x))
.
WinchControllers.copy_examples
— Functioncopy_examples()
Copy all example scripts to the folder "examples" (it will be created if it doesn't exist).