Utility Functions and Macros

WinchControllers.@limitMacro
macro 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
source
WinchControllers.saturateFunction
saturate(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
source
WinchControllers.merge_anglesFunction
merge_angles(alpha, beta, factor_beta)

Calculate the weighted average of two angles. The weight of beta, factor_beta must be between 0 and 1.

source
WinchControllers.get_startupFunction
get_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
source
WinchControllers.get_triangle_windFunction
get_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
source
WinchControllers.rmsFunction
rms(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 as norm(x) / sqrt(length(x)).
source