Brick
Toggle main menu visibility
Loading...
Searching...
No Matches
feedback.h
Go to the documentation of this file.
1
/**
2
* @file feedback.h
3
* @brief A pure virual class to function as an interface for all feedback control loops
4
*
5
* This is designed as an interface for any control loops to use so long as they have:
6
* An output of any type
7
* A current and reference state of the same type
8
*/
9
10
#pragma once
11
12
#include "core/math/units.h"
13
14
/**
15
* @brief pure virtual class for generic feedback control loops.
16
*
17
* @param T the data type for states
18
* @param U the data type for output
19
*/
20
template
<
typename
T,
typename
U>
21
class
Feedback
{
22
public
:
23
/// Resets the internal state of the control loop
24
virtual
void
reset
() = 0;
25
26
/**
27
* @brief Updates the control loop output
28
*
29
* @param state the current state the control system is at
30
* @param reference the target state for the control system
31
* @param dt the timestep since the last time this method was called
32
* @return the controller output
33
*/
34
virtual
U
update
(
const
T& state,
const
T& reference,
const
units::Time& dt) = 0;
35
36
/// Gets the last saved output value
37
U
get_output
() {
return
output_; }
38
39
/// Gets the last saved error
40
U
get_last_error
() {
return
last_error_; }
41
42
/// Gets the currently stored reference state
43
T
get_reference
() {
return
reference_; }
44
45
/// Gets the currently stored state
46
T
get_state
() {
return
state_; }
47
48
U output_min_;
49
U output_max_;
50
51
protected
:
52
T reference_;
53
T state_;
54
T last_error_;
55
56
U output_;
57
};
Feedback
pure virtual class for generic feedback control loops.
Definition
feedback.h:21
Feedback::get_last_error
U get_last_error()
Gets the last saved error.
Definition
feedback.h:40
Feedback::reset
virtual void reset()=0
Resets the internal state of the control loop.
Feedback::get_output
U get_output()
Gets the last saved output value.
Definition
feedback.h:37
Feedback::update
virtual U update(const T &state, const T &reference, const units::Time &dt)=0
Updates the control loop output.
Feedback::get_reference
T get_reference()
Gets the currently stored reference state.
Definition
feedback.h:43
Feedback::get_state
T get_state()
Gets the currently stored state.
Definition
feedback.h:46
core
math
controls
feedback.h
Generated by
1.18.0