Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 :
8 : /// \cond
9 : template <size_t DerivOrder>
10 : class Controller;
11 : class DataVector;
12 : template <bool AllowDecrease>
13 : class TimescaleTuner;
14 : /// \endcond
15 :
16 : namespace control_system {
17 : /*!
18 : * \ingroup ControlSystemGroup
19 : * \brief Calculate the measurement timescale based on the damping timescale,
20 : * update fraction, and DerivOrder of the control system
21 : *
22 : * The update timescale is \f$\tau_\mathrm{update} = \alpha_\mathrm{update}
23 : * \tau_\mathrm{damp}\f$ where \f$\tau_\mathrm{damp}\f$ is the damping timescale
24 : * (from the TimescaleTuner) and \f$\alpha_\mathrm{update}\f$ is the update
25 : * fraction (from the controller). For an Nth order control system, the averager
26 : * requires at least N measurements in order to perform its finite
27 : * differencing to calculate the derivatives of the control error. This implies
28 : * that the largest the measurement timescale can be is \f$\tau_\mathrm{m} =
29 : * \tau_\mathrm{update} / N\f$. To ensure that we have sufficient measurements,
30 : * we calculate the measurement timescales as \f$\tau_\mathrm{m} =
31 : * \tau_\mathrm{update} / N\f$ where \f$N\f$ is `measurements_per_update`.
32 : */
33 : template <size_t DerivOrder, bool AllowDecrease>
34 1 : DataVector calculate_measurement_timescales(
35 : const ::Controller<DerivOrder>& controller,
36 : const ::TimescaleTuner<AllowDecrease>& tuner,
37 : const int measurements_per_update);
38 : } // namespace control_system
|