## Fourier analysis definition

@FOURIER_ANALYSIS_DEFINITION {
@FOURIER_ANALYSIS_NAME {FourierName} {
@FOURIER_ANALYSIS_TYPE {FourierType}
@PARAMETERS {
@NUMBER_OF_FREQUENCIES {Nf}
@CIRCULAR_FREQUENCY {Ω}
}
@PARAMETERS {
@NUMBER_OF_FREQUENCIES {Nf}
@NUMBER_OF_TIME_STEPS {ns}
}
@PARAMETERS {
@FOURIER_FREQUENCIES {f1, f2,... , fN}
@GAIN_COEFFICIENT {g}
@OUTPUT_CHANNEL_NUMBER {Nc}
}
}
}

### Notes

1. It is often useful to perform a Fourier analysis of a signal. Three types of Fourier analysis can be performed, as selected by the flag FourierType: discrete Fourier transform, Fast fourier transform and on-line Fourier transform. Fourier analysis is performed on signals, which are defined by a sequence of discrete pairs, (ti, si), i = 1, 2,... , N, where si = s(ti) is the discrete value of the signal at time ti, and N the number of sampling points. Note that the sampling points are not necessarily equally spaced in time.
2. Fourier analysis is, in general, a post-processing operation: once the response of the system has been computed, a signal is extracted and the complete signal, i.e. all pairs (ti, si), i = 1, 2,... , N, is available to perform the Fourier analysis. The discrete Fourier and Fourier analysis are post processing operations. In contrast, on-line Fourier analysis provides estimates of the signal's Fourier component magnitudes at specific frequencies as the response of the system is being computed: as each new pair, (ti, si), becomes available, it is used to refine the estimates signal's Fourier component magnitudes.
3. Three types of Fourier analysis can be performed on the signal, based on the value of parameter FourierType.
• If FourierType = DISCRETE_FOURIER, a discrete Fourier transform of the signal will be performed, as defined by the following equation
s(t) = a0 + a1s sin Ωt + a1c cos Ωt + a2s sin 2Ωt + a2c cos 2Ωt + ... + aNfs sin NfΩt + aNfc cos NfΩt.
This analysis requires two input parameters, the number of frequencies, Nf, to be used in the Fourier expansion, and the fundamental circular frequency of the signal, Ω. It is assumed that the signal is defined over one period, T, where T = 2π/Ω. If it is not, signal preconditioning must be used to select one period of the signal precisely.
• If FourierType = FOURIER, a Fourier transform of the signal will be performed, as defined by the following equation
Si = Σn = 1Ns sN { cos [(n-1) (2π(i-1))/Ns] - j sin [(n-1) (2π(i-1))/Ns]},        i = 1, 2,... ,Ns
where j = √(-1), and Ns the number of data points in the signal. The output of the post processing operation are the absolute value of the complex numbers Si as a function of frequency.
This analysis uses two optional parameters, the number of time steps of the signal, ns, and the number of frequencies, Nf, to be extracted. If the the number of time steps, ns, is not defined, the default value is ns = N. Since the algorithms used for the Fourier transform assume equally spaced sampling points, the first phase of the algorithm is to resample the original signal, defined by N discrete values, to create a new signal with ns equally spaced discrete values. Linear interpolation is used in this operation. While the Fourier transform is defined for all values of k = 1, 2,... , ns, only those values below the Nyquist frequency are relevant, i.e., k ≤ ns/2. If Nf is not defined, Nf = ns/2.
• If FourierType = ON_LINE, an on-line Fourier analysis will be performed, as defined by the following equation
s(t) = a0 + a1s sin Ωt + a1c cos Ωt + a2s sin 2Ωt + a2c cos 2Ωt + ... + aNfs sin NfΩt + aNfc cos NfΩt.
The goal of this analysis is to estimate the magnitudes of the Fourier components of a signal at specific, given frequencies, i.e., to estimate coefficients a0, ais, and aic, for i = 1, 2,..., Nf.
This analysis requires the following input: the number of frequencies, Nf, to be used in the Fourier expansion, the frequency content of the signal, fk, k=1, 2,..., Nf, and the gain coefficient, g. The optimal value of the gain coefficient is twice the time step size divided by the fundamental period of the signal. The frequency content of the signal must be known prior to performing an on-line Fourier analysis, which only estimates the amplitudes of the signal at those frequencies. If the user provided frequency content, fk, k=1, 2,..., Nf, is not correct, erroneous amplitudes will be estimated.
Typically, the on-line Fourier analysis is used to condition a signal to be used by a controller. A single Fourier components will be returned to the controller, as defined output channel number, 0 ≤ Nc ≤ 2Nf + 1.
•  Nc 0 1 2 3 4 ... 2Nf - 1 2Nf Component a0 a1s a1c a2s a2c ... aNfs aNfc
4. It is possible to attach comments to the definition of the object; these comments have no effect on its definition.

#### Example 1

In the first example, a signal SignalRotationC extracts the relative rotation at a revolute joint; this relative rotation is shown in fig. 1. Note the preconditioning applied to the signal to extract from the simulation one single period of the periodic response. Next, a discrete Fourier transform of this signal is performed; 5 harmonics are computed and the base circular frequency of the signal is given as Ω = 5 rad/sec. Figure 2 shows the sine and cosine components of the given signal. The left figure shows a bar chart with a0 and ais, i = 1, 2,... , Nf, and the right figure shows a bar chart with a0 and aic, i = 1, 2,... , Nf.

SIGNAL_DEFINITION {
@SIGNAL_NAME {SignalRotationC} {
@SENSOR_NAME {SensorRotationC}
@CHANNEL_NUMBER {4}
@SIGNAL_PRECONDITIONING_NAME {PreconRotationC}
@SIGNAL_CONDITIONING_NAME {FourierDiscrete}
}
}
SIGNAL_PRECONDITIONING_DEFINITION {
@SIGNAL_PRECONDITIONING_NAME {PreconRotationC} {
@INITIAL_TIME {2.51327412287183}
@NORMALIZED_TIME_RANGE {0.0, 1.25663706143592}
@TIME_AXIS_LABEL {REVOLUTIONS [DEG]}
}
}
FOURIER_ANALYSIS_DEFINITION {
@FOURIER_ANALYSIS_NAME {FourierDiscrete} {
@FOURIER_ANALYSIS_TYPE {DISCRETE_FOURIER}
@PARAMETERS {
@NUMBER_OF_FREQUENCIES {5}
@CIRCULAR_FREQUENCY {5.0}
}
}
} ##### Figure 1. Output created by signal SignalRotationC.  #### Example 2

Signal SignalRotationC extracts the relative rotation at a revolute joint; this relative rotation is shown in fig. 1. Note the preconditioning applied to the signal to extract from the simulation one single period of the periodic response. Next, the Fourier transform of this signal is performed and the first 25 values of the transform are computed, k = 1, 2,... , 25. Figure 4 shows the result of the analysis: the norms, |Sk|, of the complex numbers generated by the Fourier transform are shown for k = 1, 2,... , 25. Since the number k have no physical meaning, the horizontal axis is transformed to physical frequencies, fk = k / (ns Δt), where Δt is the signal sampling rate.

FOURIER_ANALYSIS_DEFINITION {
@FOURIER_ANALYSIS_NAME {Fourier} {
@FOURIER_ANALYSIS_TYPE {FOURIER}
@PARAMETERS {
@NUMBER_OF_FREQUENCIES {25}
}
}
} 