FunctionOfTimeUpdater.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
8 #include "ControlSystem/Averager.hpp"
9 #include "ControlSystem/Controller.hpp"
10 #include "ControlSystem/PiecewisePolynomial.hpp"
11 #include "ControlSystem/TimescaleTuner.hpp"
12 
13 // IWYU pragma: no_forward_declare FunctionsOfTime::PiecewisePolynomial
14 
15 /// \cond
16 class DataVector;
17 namespace gsl {
18 template <class T>
19 class not_null;
20 } // namespace gsl
21 /// \endcond
22 
23 /// \ingroup ControlSystemGroup
24 /// Responsible for updating the FunctionOfTime map parameters.
25 /// `modify`: updates the FunctionOfTime map parameters, changing the maps.
26 /// `measure`: provides updated information to the ControlSystem, without
27 /// modifying the maps.
28 ///
29 /// `modify` computes the control signal, which relies on \f$Q\f$ and its
30 /// derivatives. The Averager is responsible for numerically computing the
31 /// derivatives, and as such, requires sufficient data (the number of points
32 /// being dependent on the `DerivOrder`). This data is provided to the Averager
33 /// through `measure`. We do not `modify` at every `measure` (even once the
34 /// Averager has sufficient data to compute derivatives) since `modify` requires
35 /// updating the maps, which could potentially hold up other processes that rely
36 /// on these maps.
37 template <size_t DerivOrder>
39  public:
41  Controller<DerivOrder>&& controller,
42  TimescaleTuner&& timescale_tuner) noexcept;
43 
44  FunctionOfTimeUpdater(FunctionOfTimeUpdater&&) noexcept = default;
45  FunctionOfTimeUpdater& operator=(FunctionOfTimeUpdater&&) noexcept = default;
47  FunctionOfTimeUpdater& operator=(const FunctionOfTimeUpdater&) = delete;
48  ~FunctionOfTimeUpdater() = default;
49 
50  /// Provides \f$Q(t)\f$ to the averager, which internally updates the averaged
51  /// values of \f$Q\f$ and derivatives stored by the averager
52  void measure(double time, const DataVector& raw_q) noexcept;
53 
54  /// Computes the control signal, updates the FunctionOfTime and updates the
55  /// TimescaleTuner
56  void modify(
58  double time) noexcept;
59 
60  private:
61  Averager<DerivOrder> averager_;
62  Controller<DerivOrder> controller_;
63  TimescaleTuner timescale_tuner_;
64 };
A PND (proportional to Q and N derivatives of Q) controller that computes the control signal: where ...
Definition: Controller.hpp:33
A weighted exponential averager of and its derivatives implementing Appendix A in ...
Definition: Averager.hpp:34
Implementations from the Guideline Support Library.
Definition: ConservativeFromPrimitive.hpp:10
A function that has a piecewise-constant MaxDerivth derivative.
Definition: PiecewisePolynomial.hpp:19
Responsible for updating the FunctionOfTime map parameters. modify: updates the FunctionOfTime map pa...
Definition: FunctionOfTimeUpdater.hpp:38
Stores a collection of function values.
Definition: DataVector.hpp:46
Manages control system timescales.
Definition: TimescaleTuner.hpp:40
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12