Skip to content

Interpolator

A 1-D or 2-D interpolator that uses value tables to map an input signal range to an output signal range.


JCS Network Configuration

structure.yaml Configuration

type proc_interpolator

Signals - From Process

Signal name Type Required Description
y float32 required Interpolator output.
Signal name can be renamed by the user.

Signals - To Process

Signal name Type Required Description
x_1 float32 required Interpolator input 1.
If the signals value goes beyond the range of proc_interpolator_x1_coeffs, the the output of the interpolator will be clamped.
x_2 float32 required Interpolator input 2.
If the signals value goes beyond the range of proc_interpolator_x2_coeffs, the the output of the interpolator will be clamped.
interpolator_type linear_2d only.
a float32 optional Scale signal
If not used, may be set by parameter a_coeff
Defaults to 1.0 if not used.
b float32 optional Offset signal
If not used, may be set by parameter b_coeff
Defaults to 0.0 if not used.

Configuration Parameters

Parameter name Type Required Description
interpolator_type enum Required Selects the interpolator type.
x1_coeffs float32 required An array of interpolation coefficients for \(x_1\).
x2_coeffs float32 required An array of interpolation coefficients for \(x_2\).
f_x_coeffs float32 required An array of interpolation coefficients for \(f(x_1)\) or \(f(x_1, x_2\)).
a_coeff float32 optional Scale coefficient.
b_coeff float32 optional Offset coefficient.

The following transforms are available for parameter interpolator_type:

interpolator_type Description
linear_1d Single input, single output 1-D linear interpolator.
linear_2d Double input, single output 2-D linear interpolator.

Operation

Linear 1D

A 1-D linear interpolator defined by:

\[ y = a f(x_1) + b \]

where \(f(x_1)\) is the interpolated signal \(x_1\) and \(a\) and \(b\) are scale and offset signals or parameters.

Configuration requirements

Operation of the 1-D linear interpolator requires:

  • interpolator_type must be set to linear_1d.

  • x1_coeffs has a maximum length of 128 values.

  • f_x_coeffs has a maximum length of 128 values.
  • x1_coeffs and f_x_coeffs must be the same length.

  • Signal x_1 must be connected.

jcs_host will fail at startup if any of these requirements are not met.


Linear 2D

A 2-D linear interpolator defined by:

\[ y = a f(x_1, x_2) + b \]

where \(f(x_1, x_2)\) is the signal produced by 2-D linear interpolation of \(x_1\) and \(x_2\) and \(a\) and \(b\) are scale and offset signals or parameters.

Configuration requirements

Operation of the 2-D linear interpolator requires:

  • interpolator_type must be set to linear_2d.

  • x1_coeffs has a maximum length of 32 values.

  • x2_coeffs has a maximum length of 32 values.
  • f_x_coeffs has a maximum length of 1024 values.
  • The length of x1_coeffs * x2_coeffs must equal the length of f_x_coeffs.

  • Signal x_1 must be connected.

  • Signal x_2 must be connected.

jcs_host will fail at startup if any of these requirements are not met.


Scale and offset

The scale and offset may be:

  • Connected as signals. Parameters a_coeff and b_coeff have no effect.
  • Configure as parameters a_coeff and b_coeff.
  • Left unconfigured and unconnected as signals. In this case default values of \(a = 1.0\) and \(b = 0.0\) are applied.

Notes

Linear interpolator vs Solver speed

proc_interpolator is much faster than proc_solver. If a complicated function can be approximated well by the interpolator, then it is recommended to use proc_interpolator over the proc_solver.

As an example: During testing the force to torque transform given by \(\tau = F {bcsin(\theta) \over \sqrt{b^2 + c^2 - 2bccos(\theta)}}\) was ran in the solver, with any constants precomputed where possible. The same function was approximated by the interpolator (with an RMS error of \(0.0138Nmm\)). The solver had an average time of 11us and a maximum time of 19us to complete, while the interpolator had an average time of 2us and a maximum time of 4us.

1-D interpolator vs 2-D interpolator

Considering both execution speed and space required by interpolation coefficients, choose 1D interpolation with \(a\) and \(b\) coefficients over 2D interpolation if possible.

As an example: The force to torque transform from above is dependent on both \(F\) and \(\theta\) as input variables. At a first glance, it would seem appropriate to choose a 2-D interpolator. However, if we look at the equation we can see that it is actually only non-linear in \(\theta\), whereas \(F\) has a linear effect on the equation result. In this case it would be appropriate to use a 1D interpolator for the \(\theta\) component and use the \(a\) scaling signal for \(F\).