|
| MPC (F &&f, CR &&cr, Eigen::Vector< double, Ncr > &&crl, Eigen::Vector< double, Ncr > &&cru, MPCParams &&prm={}) |
| Create an MPC instance. More...
|
|
| MPC (const F &f, const CR &cr, const Eigen::Vector< double, Ncr > &crl, const Eigen::Vector< double, Ncr > &cru, const MPCParams &prm={}) |
| Same as above but for lvalues. More...
|
|
| MPC ()=default |
| Default constructor.
|
|
| MPC (const MPC &)=default |
| Default copy constructor.
|
|
| MPC (MPC &&)=default |
| Default move constructor.
|
|
MPC & | operator= (const MPC &)=default |
| Default copy assignment.
|
|
MPC & | operator= (MPC &&)=default |
| Default move assignment.
|
|
| ~MPC ()=default |
| Default destructor.
|
|
std::pair< U, QPSolutionStatus > | operator() (const T &t, const X &x, std::optional< std::reference_wrapper< std::vector< U > > > u_traj=std::nullopt, std::optional< std::reference_wrapper< std::vector< X > > > x_traj=std::nullopt) |
| Calculate new MPC input. More...
|
|
void | set_udes (std::function< U(T)> &&u_des) |
| Set the desired input trajectory (absolute time) More...
|
|
void | set_udes (const std::function< U(T)> &u_des) |
| Set the desired input trajectory (absolute time, rvalue version) More...
|
|
template<typename Fun >
requires (std::is_same_v<std::invoke_result_t<Fun, Scalar<U>>, U>) |
void | set_udes_rel (Fun &&f, T t0=T(0)) |
| Set the desired input trajectory (relative time). More...
|
|
void | set_xdes (std::function< X(T)> &&x_des, std::function< Tangent< X >(T)> &&dx_des) |
| Set the desired state trajectory and velocity (absolute time) More...
|
|
void | set_xdes (const std::function< X(T)> &x_des, const std::function< Tangent< X >(T)> &dx_des) |
| Set the desired state trajectory (absolute time, rvalue version) More...
|
|
template<typename Fun >
requires (std::is_same_v<std::invoke_result_t<Fun, Scalar<X>>, X>) |
void | set_xdes_rel (Fun &&f, T t0=T(0)) |
| Set the desired state trajectry (relative time, automatic differentiation). More...
|
|
void | set_weights (const MPCWeights< X, U > &weights) |
| Update MPC weights. More...
|
|
void | reset_warmstart () |
| Reset initial guess for next iteration to zero. More...
|
|
template<Time T, LieGroup X, Manifold U, typename F, typename CR, std::size_t Kmesh = 4, diff::Type DT = diff::Type::Default>
class smooth::feedback::MPC< T, X, U, F, CR, Kmesh, DT >
Model-Predictive Control (MPC) on Lie groups.
- Template Parameters
-
T | time type, must be a std::chrono::duration-like |
X | state space LieGroup type |
U | input space Manifold type |
F | callable type that represents dynamics |
CR | callable type that represents running constraints |
DT | differentiation method |
Kmesh | number of collocation points per mesh interval |
This MPC class keeps and repeatedly solves an internal OCP that is updated to track a time-dependent trajectory defined via set_xdes() and set_udes().
Definition at line 380 of file mpc.hpp.
template<Time T, LieGroup X, Manifold U, typename F , typename CR , std::size_t Kmesh = 4, diff::Type DT = diff::Type::Default>
smooth::feedback::MPC< T, X, U, F, CR, Kmesh, DT >::MPC |
( |
F && |
f, |
|
|
CR && |
cr, |
|
|
Eigen::Vector< double, Ncr > && |
crl, |
|
|
Eigen::Vector< double, Ncr > && |
cru, |
|
|
MPCParams && |
prm = {} |
|
) |
| |
|
inline |
Create an MPC instance.
- Parameters
-
f | callable object that represents dynamics \( \mathrm{d}^r x_t = f(x, u) \) as a function \( f : X \times U \rightarrow \mathbb{R}^{\dim \mathfrak{g}} \). |
cr | callable object that represents running constraints \( c_{rl} \leq c_r(x, u) \leq
c_{ru} \) as a function \( c_r : X \times U \rightarrow \mathbb{R}^{n_{c_r}} \). |
crl,cru | running constraints bounds |
prm | MPC parameters |
- Note
- Allocates dynamic memory for work matrices and a sparse QP.
-
The functions f and cr are are linearized around the desired trajectory and must therefore be instances of first-order differentiable types. For best results, cr should be (group-)linear and f locally well approximated around \( x_{des} \) by a (group-)linear function.
- Todo:
- Optimization: The only time-dependent parts of the QP are the dynamics and end constraints, so only those need to be updated.
Definition at line 405 of file mpc.hpp.
template<Time T, LieGroup X, Manifold U, typename F , typename CR , std::size_t Kmesh = 4, diff::Type DT = diff::Type::Default>
smooth::feedback::MPC< T, X, U, F, CR, Kmesh, DT >::MPC |
( |
const F & |
f, |
|
|
const CR & |
cr, |
|
|
const Eigen::Vector< double, Ncr > & |
crl, |
|
|
const Eigen::Vector< double, Ncr > & |
cru, |
|
|
const MPCParams & |
prm = {} |
|
) |
| |
|
inline |
Same as above but for lvalues.
Definition at line 427 of file mpc.hpp.
template<Time T, LieGroup X, Manifold U, typename F , typename CR , std::size_t Kmesh = 4, diff::Type DT = diff::Type::Default>
Reset initial guess for next iteration to zero.
Definition at line 603 of file mpc.hpp.
template<Time T, LieGroup X, Manifold U, typename F , typename CR , std::size_t Kmesh = 4, diff::Type DT = diff::Type::Default>
Set the desired input trajectory (absolute time, rvalue version)
Definition at line 529 of file mpc.hpp.
template<Time T, LieGroup X, Manifold U, typename F , typename CR , std::size_t Kmesh = 4, diff::Type DT = diff::Type::Default>
Set the desired input trajectory (absolute time)
Definition at line 524 of file mpc.hpp.
template<Time T, LieGroup X, Manifold U, typename F , typename CR , std::size_t Kmesh = 4, diff::Type DT = diff::Type::Default>
template<typename Fun >
requires (std::is_same_v<std::invoke_result_t<Fun, Scalar<U>>, U>)
Set the desired input trajectory (relative time).
- Parameters
-
f | function double -> U<double> s.t. u_des(t) = f(t - t0) |
t0 | absolute zero time for the desired trajectory |
Definition at line 539 of file mpc.hpp.
template<Time T, LieGroup X, Manifold U, typename F , typename CR , std::size_t Kmesh = 4, diff::Type DT = diff::Type::Default>
void smooth::feedback::MPC< T, X, U, F, CR, Kmesh, DT >::set_xdes |
( |
const std::function< X(T)> & |
x_des, |
|
|
const std::function< Tangent< X >(T)> & |
dx_des |
|
) |
| |
|
inline |
Set the desired state trajectory (absolute time, rvalue version)
Definition at line 559 of file mpc.hpp.
template<Time T, LieGroup X, Manifold U, typename F , typename CR , std::size_t Kmesh = 4, diff::Type DT = diff::Type::Default>
void smooth::feedback::MPC< T, X, U, F, CR, Kmesh, DT >::set_xdes |
( |
std::function< X(T)> && |
x_des, |
|
|
std::function< Tangent< X >(T)> && |
dx_des |
|
) |
| |
|
inline |
Set the desired state trajectory and velocity (absolute time)
Definition at line 550 of file mpc.hpp.
template<Time T, LieGroup X, Manifold U, typename F , typename CR , std::size_t Kmesh = 4, diff::Type DT = diff::Type::Default>
template<typename Fun >
requires (std::is_same_v<std::invoke_result_t<Fun, Scalar<X>>, X>)
Set the desired state trajectry (relative time, automatic differentiation).
Instead of providing {x(t), dx(t)} of the desired trajectory, this function differentiates a function x(t) so that the derivative does not need to be specified.
- Parameters
-
f | function s.t. desired trajectory is x(t) = f(t - t0) |
t0 | absolute zero time for the desired trajectory |
Definition at line 575 of file mpc.hpp.