libstp
Robotics library for Botball
Loading...
Searching...
No Matches
control_path.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5#include <vector>
6
8
10{
11
18class ControlPath final : public ControlElement
19{
20public:
21 ControlPath() = default;
22
24 void add(std::unique_ptr<ControlElement> element);
25
26 [[nodiscard]] std::string getType() const override { return "ControlPath"; }
27 [[nodiscard]] double getLowestTimeConstant() const override;
28 void initialize(double dt) override;
29 double calculate(double u, double dt) override;
30 [[nodiscard]] int optimizeGetNumParameters() const override;
31 void optimizeSetParameters(const std::vector<double>& params, int startIdx) override;
32
33private:
34 std::vector<std::unique_ptr<ControlElement>> elements_;
35};
36
37} // namespace libstp::autotune::control
Abstract base for every control element (P, I, D, PT1, ...).
void initialize(double dt) override
Reset internal state for a simulation run at sample time dt.
double calculate(double u, double dt) override
Advance one sample: feed input u, return output.
int optimizeGetNumParameters() const override
Number of tunable parameters this element consumes.
void optimizeSetParameters(const std::vector< double > &params, int startIdx) override
Load parameters from params starting at startIdx.
void add(std::unique_ptr< ControlElement > element)
Append an element to the chain (takes ownership).
std::string getType() const override
Short type tag, e.g. "P", "PT1", "ControlLoop".
double getLowestTimeConstant() const override
Lowest time constant of the element, or -1 if it has none.