RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
rz::Pid< Error, Output > Class Template Reference

A PID controller from an error to an output, e.g. Pid<Angle, Voltage> for a turn. More...

#include <Pid.hpp>

Classes

struct  Gains
struct  Config

Public Types

using ProportionalGain = decltype(Output{} / Error{})
using IntegralGain = decltype(Output{} / (Error{} * Duration{}))
using DerivativeGain = decltype(Output{} * Duration{} / Error{})

Public Member Functions

 Pid (Config config)
Output update (Error error, Duration dt)
 The output for error, dt after the previous update.
void reset ()
 Forgets the accumulated integral and the previous error, e.g. before a new motion.

Detailed Description

template<class Error, class Output>
class rz::Pid< Error, Output >

A PID controller from an error to an output, e.g. Pid<Angle, Voltage> for a turn.

The gains carry units, so au::volts(12.0) / au::degrees(90.0) is a valid proportional gain for Pid<Angle, Voltage> and a gain with the wrong units does not compile. The derivative acts on the error, and the first update after construction or reset() has no derivative term.

Member Typedef Documentation

◆ DerivativeGain

template<class Error, class Output>
using rz::Pid< Error, Output >::DerivativeGain = decltype(Output{} * Duration{} / Error{})

◆ IntegralGain

template<class Error, class Output>
using rz::Pid< Error, Output >::IntegralGain = decltype(Output{} / (Error{} * Duration{}))

◆ ProportionalGain

template<class Error, class Output>
using rz::Pid< Error, Output >::ProportionalGain = decltype(Output{} / Error{})

Constructor & Destructor Documentation

◆ Pid()

template<class Error, class Output>
rz::Pid< Error, Output >::Pid ( Config config)
inlineexplicit

Member Function Documentation

◆ reset()

template<class Error, class Output>
void rz::Pid< Error, Output >::reset ( )
inline

Forgets the accumulated integral and the previous error, e.g. before a new motion.

◆ update()

template<class Error, class Output>
Output rz::Pid< Error, Output >::update ( Error error,
Duration dt )
inlinenodiscard

The output for error, dt after the previous update.


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