bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::control::LQRController Class Reference

A linear state feedback about an operating point, \(u = u_{ref} - K (x - x_{ref})\), with optional bounds on each input. More...

#include <lqr.h>

Public Member Functions

 LQRController (const Matrix &K)
void set_reference (const Vector &x_ref, const Vector &u_ref)
 Set the operating point: the state to hold and the input that holds it. Both start at zero.
void set_input_bounds (const Vector &lower, const Vector &upper)
 Clip each input to [lower, upper].
Vector control (const Vector &x) const
const Matrix & gain () const noexcept
const Vector & state_reference () const noexcept
const Vector & input_reference () const noexcept
uint_t n_states () const noexcept
uint_t n_inputs () const noexcept

Detailed Description

A linear state feedback about an operating point, \(u = u_{ref} - K (x - x_{ref})\), with optional bounds on each input.

The gain usually comes from lqr() or dlqr() for a model linearised about the operating point, such as a hover or a trim, and the reference is that point: \(x_{ref}\) the state and \(u_{ref}\) the input that holds it there. Changing \(x_{ref}\) to another state the same input holds, such as another position at hover, makes the controller go there.

With bounds, each input is clipped to them. The gain was designed without them, so a clipped input no longer minimises the cost; LinearMPC takes the bounds into account instead.

Constructor & Destructor Documentation

◆ LQRController()

bitsim::control::LQRController::LQRController ( const Matrix & K)
explicit
Parameters
KThe gain, inputs x states

Member Function Documentation

◆ control()

Vector bitsim::control::LQRController::control ( const Vector & x) const
Returns
The input for the state x

◆ gain()

const Matrix & bitsim::control::LQRController::gain ( ) const
inlinenoexcept

◆ input_reference()

const Vector & bitsim::control::LQRController::input_reference ( ) const
inlinenoexcept

◆ n_inputs()

uint_t bitsim::control::LQRController::n_inputs ( ) const
inlinenoexcept

◆ n_states()

uint_t bitsim::control::LQRController::n_states ( ) const
inlinenoexcept

◆ set_input_bounds()

void bitsim::control::LQRController::set_input_bounds ( const Vector & lower,
const Vector & upper )

Clip each input to [lower, upper].

Exceptions
std::invalid_argumentif the sizes do not match, or lower > upper

◆ set_reference()

void bitsim::control::LQRController::set_reference ( const Vector & x_ref,
const Vector & u_ref )

Set the operating point: the state to hold and the input that holds it. Both start at zero.

Exceptions
std::invalid_argumentif the sizes do not match the gain

◆ state_reference()

const Vector & bitsim::control::LQRController::state_reference ( ) const
inlinenoexcept

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