Controlpp
Loading...
Searching...
No Matches
controlpp::timevar::PControl< T > Class Template Reference

A P (Proportional) controller. More...

#include <controlpp/TimeVariantControl.hpp>

Public Types

using value_type = T
 

Public Member Functions

constexpr PControl (const PControl &)=default
 Default copy constructor.
 
constexpr PControl (const T &kp)
 Construct a P (Proportional) controller with a constant gain.
 
constexpr void kp (const T &kp)
 sets the proportional gain
 
constexpr const T & kp () const
 returns the current gain
 
constexpr T input (const T &u)
 Adds a new sample.
 
constexpr T input (const T &u, const T &Ts)
 Adds a new sample.
 
constexpr T operator() (const T &u)
 Adds a new sample.
 
constexpr T operator() (const T &u, const T &Ts)
 Adds a new sample.
 
constexpr void reset ()
 resets the internal states of the filter
 

Friends

constexpr ValueSampletimePair< T > operator>> (const ValueSampletimePair< T > &p, PControl &c)
 

Detailed Description

template<class T>
class controlpp::timevar::PControl< T >

A P (Proportional) controller.

has the following transfer function

\[ y_k = k_p u_k \]

where:

  • \(y_k\) is the output of the controller of the data sample k
  • \(u_k\) is the k-th input sample
  • \(k_p\) is the controller gain
Template Parameters
Tthe data type the controller uses, like float or double

Member Typedef Documentation

◆ value_type

template<class T >
using controlpp::timevar::PControl< T >::value_type = T

Constructor & Destructor Documentation

◆ PControl() [1/2]

template<class T >
constexpr controlpp::timevar::PControl< T >::PControl ( const PControl< T > &  )
constexprdefault

Default copy constructor.

◆ PControl() [2/2]

template<class T >
constexpr controlpp::timevar::PControl< T >::PControl ( const T &  kp)
inlineconstexpr

Construct a P (Proportional) controller with a constant gain.

Parameters
kpthe proportional gain of the controller

Member Function Documentation

◆ input() [1/2]

template<class T >
constexpr T controlpp::timevar::PControl< T >::input ( const T &  u)
inlineconstexpr

Adds a new sample.

Parameters
uthe new sample input
Returns
the new output based on the input

◆ input() [2/2]

template<class T >
constexpr T controlpp::timevar::PControl< T >::input ( const T &  u,
const T &  Ts 
)
inlineconstexpr

Adds a new sample.

Parameters
uthe new sample input
Tssample time (unused - there for compatibility)
Returns
the new output based on the input

◆ kp() [1/2]

template<class T >
constexpr const T & controlpp::timevar::PControl< T >::kp ( ) const
inlineconstexpr

returns the current gain

◆ kp() [2/2]

template<class T >
constexpr void controlpp::timevar::PControl< T >::kp ( const T &  kp)
inlineconstexpr

sets the proportional gain

Parameters
kpthe new proportional gain for the next sample value

◆ operator()() [1/2]

template<class T >
constexpr T controlpp::timevar::PControl< T >::operator() ( const T &  u)
inlineconstexpr

Adds a new sample.

Parameters
uthe new sample input
Returns
the new output based on the input

◆ operator()() [2/2]

template<class T >
constexpr T controlpp::timevar::PControl< T >::operator() ( const T &  u,
const T &  Ts 
)
inlineconstexpr

Adds a new sample.

Parameters
uthe new sample input
Tssample time (unused - there for compatibility)
Returns
the new output based on the input

◆ reset()

template<class T >
constexpr void controlpp::timevar::PControl< T >::reset ( )
inlineconstexpr

resets the internal states of the filter

For P control elements this is a no-op.

Friends And Related Symbol Documentation

◆ operator>>

template<class T >
constexpr ValueSampletimePair< T > operator>> ( const ValueSampletimePair< T > &  p,
PControl< T > &  c 
)
friend

The documentation for this class was generated from the following file: