smooth_feedback
Control and estimation on Lie groups
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
smooth::feedback::PID< T, G > Class Template Reference

Proportional-Integral-Derivative controller for Lie groups. More...

#include <pid.hpp>

Public Types

using TrajectoryReturnT = std::tuple< G, Tangent< G >, Tangent< G > >
 Desired trajectory consists of position, velocity, and acceleration. More...
 

Public Member Functions

 PID (const PIDParams &prm=PIDParams{}) noexcept
 Create a PID controller. More...
 
 PID (const PID &)=default
 Default copy constructor.
 
 PID (PID &&)=default
 Default move constructor.
 
PIDoperator= (const PID &)=default
 Default copy assignment.
 
PIDoperator= (PID &&)=default
 Default move assignment.
 
 ~PID ()=default
 Default destructor.
 
Tangent< G > operator() (const T &t, const G &x, const Tangent< G > &v)
 Calculate control input. More...
 
void set_kp (double kp)
 Set all proportional gains to kp. More...
 
template<typename Derived >
void set_kp (const Eigen::MatrixBase< Derived > &kp)
 Set proportional gains. More...
 
void set_kd (double kd)
 Set all derivative gains to kd. More...
 
template<typename Derived >
void set_kd (const Eigen::MatrixBase< Derived > &kd)
 Set derivative gains. More...
 
void set_ki (double ki)
 Set all integral gains to ki. More...
 
template<typename Derived >
void set_ki (const Eigen::MatrixBase< Derived > &ki)
 Set derivative gains. More...
 
void reset_integral ()
 Reset integral state to zero. More...
 
template<int K>
void set_xdes (T t0, const smooth::Spline< K, G > &c)
 Set desired trajectory as a smooth::Spline. More...
 
template<int K>
void set_xdes (T t0, smooth::Spline< K, G > &&c)
 Set desired trajectory as a smooth::Spline (rvalue version) More...
 
void set_xdes (const std::function< TrajectoryReturnT(T)> &f)
 Set desired trajectory. More...
 
void set_xdes (std::function< TrajectoryReturnT(T)> &&f)
 Set desired trajectory (rvalue version). More...
 

Detailed Description

template<Time T, LieGroup G>
requires (Dof<G> > 0)
class smooth::feedback::PID< T, G >

Proportional-Integral-Derivative controller for Lie groups.

Template Parameters
TTime type
GLieGroup state space type

This controller is designed for a system

\[ \begin{aligned} \mathrm{d}^r \mathbf{x}_t & = \mathbf{v}, \quad \mathbf{x} \in \mathbb{G}, \mathbf{v} \in \mathbb{R}^{\dim \mathbb{G}} \\ \frac{\mathrm{d}}{\mathrm{d}t} {\mathbf{v}} & = \mathbf{u}, \quad \mathbf{u} \in \mathbb{R}^{\dim \mathbb{G}} \end{aligned} \]

i.e. the input is the body acceleration.

Definition at line 39 of file pid.hpp.

Member Typedef Documentation

◆ TrajectoryReturnT

template<Time T, LieGroup G>
using smooth::feedback::PID< T, G >::TrajectoryReturnT = std::tuple<G, Tangent<G>, Tangent<G> >

Desired trajectory consists of position, velocity, and acceleration.

Definition at line 43 of file pid.hpp.

Constructor & Destructor Documentation

◆ PID()

template<Time T, LieGroup G>
smooth::feedback::PID< T, G >::PID ( const PIDParams prm = PIDParams{})
inlinenoexcept

Create a PID controller.

Parameters
prmparameters

At construction the proportional and derivative gains are set to 1, and the integral gains are set to 0.

Definition at line 53 of file pid.hpp.

Member Function Documentation

◆ operator()()

template<Time T, LieGroup G>
Tangent< G > smooth::feedback::PID< T, G >::operator() ( const T &  t,
const G &  x,
const Tangent< G > &  v 
)
inline

Calculate control input.

Parameters
tcurrent time
xcurrent state
vcurrent body velocity
Returns
input proportional to desired body acceleration

Definition at line 74 of file pid.hpp.

◆ reset_integral()

template<Time T, LieGroup G>
void smooth::feedback::PID< T, G >::reset_integral ( )
inline

Reset integral state to zero.

Definition at line 134 of file pid.hpp.

◆ set_kd() [1/2]

template<Time T, LieGroup G>
template<typename Derived >
void smooth::feedback::PID< T, G >::set_kd ( const Eigen::MatrixBase< Derived > &  kd)
inline

Set derivative gains.

Definition at line 112 of file pid.hpp.

◆ set_kd() [2/2]

template<Time T, LieGroup G>
void smooth::feedback::PID< T, G >::set_kd ( double  kd)
inline

Set all derivative gains to kd.

Definition at line 106 of file pid.hpp.

◆ set_ki() [1/2]

template<Time T, LieGroup G>
template<typename Derived >
void smooth::feedback::PID< T, G >::set_ki ( const Eigen::MatrixBase< Derived > &  ki)
inline

Set derivative gains.

Definition at line 126 of file pid.hpp.

◆ set_ki() [2/2]

template<Time T, LieGroup G>
void smooth::feedback::PID< T, G >::set_ki ( double  ki)
inline

Set all integral gains to ki.

Definition at line 120 of file pid.hpp.

◆ set_kp() [1/2]

template<Time T, LieGroup G>
template<typename Derived >
void smooth::feedback::PID< T, G >::set_kp ( const Eigen::MatrixBase< Derived > &  kp)
inline

Set proportional gains.

Definition at line 98 of file pid.hpp.

◆ set_kp() [2/2]

template<Time T, LieGroup G>
void smooth::feedback::PID< T, G >::set_kp ( double  kp)
inline

Set all proportional gains to kp.

Definition at line 92 of file pid.hpp.

◆ set_xdes() [1/4]

template<Time T, LieGroup G>
void smooth::feedback::PID< T, G >::set_xdes ( const std::function< TrajectoryReturnT(T)> &  f)
inline

Set desired trajectory.

The trajectory is a function from time to (position, velocity, acceleration). To track a time-dependent trajectory consider using smooth::Spline and set_xdes(T, const smooth::Spline<K, G> &) to set the desired trajectory.

For a constant reference target the velocity and acceleration should be constantly zero.

Note
For best performance the trajectory should be dynamically consistent, i.e.

\[ \mathrm{d}^r \mathbf{x}_t = \mathbf{v}, \\ \frac{\mathrm{d}}{\mathrm{d}t} \mathbf{v} = \mathbf{a}, \]

where (x, v, a) is the (position, velocity, acceleration)-tuple returned by the trajectory.

Definition at line 177 of file pid.hpp.

◆ set_xdes() [2/4]

template<Time T, LieGroup G>
void smooth::feedback::PID< T, G >::set_xdes ( std::function< TrajectoryReturnT(T)> &&  f)
inline

Set desired trajectory (rvalue version).

Definition at line 186 of file pid.hpp.

◆ set_xdes() [3/4]

template<Time T, LieGroup G>
template<int K>
void smooth::feedback::PID< T, G >::set_xdes ( t0,
const smooth::Spline< K, G > &  c 
)
inline

Set desired trajectory as a smooth::Spline.

Parameters
cdesired trajectory as a smooth::Spline
t0curve initial time s.t. the desired position at time t is equal to c(t - t0)

Definition at line 143 of file pid.hpp.

◆ set_xdes() [4/4]

template<Time T, LieGroup G>
template<int K>
void smooth::feedback::PID< T, G >::set_xdes ( t0,
smooth::Spline< K, G > &&  c 
)
inline

Set desired trajectory as a smooth::Spline (rvalue version)

Definition at line 152 of file pid.hpp.


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