Skip to content

Latest commit

 

History

History

realtime

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Real-time L4CasADi

This is the underlying framework enabling Real-time Neural-MPC in our paper

Real-time Neural-MPC: Deep Learning Model Predictive Control for Quadrotors and Agile Robotic Platforms

Arxiv Link

Real-time L4CasADi provides an easy template to approximate a PyTorch Model in CasADi as first- or second-order Taylor-Approximation. The approximation has to updated by the user from a Python interface depending on the use-case.

The necessary parameters to update the approximation can be inferenced in parallel in PyTorch potentially on a GPU. This makes this approach efficient for large models where multiple approximations are used in parallel in an optimization (MPC with multiple shooting nodes).

Real-time L4CasADi in Acados MPC

We provide a example of how to use Real-time L4CasADi in Acados MPC in this example. Note that this is a dummy example of a single integrator with a learned residual dynamic set to zero. However, it demonstrates the integration of RealTimeL4CasADi in Acados (RTI-)MPC.

Examples

l4c_model = l4c.realtime.RealTimeL4CasADi(pyTorch_model, approximation_order=1) # approximation_order=2
x_sym = cs.MX.sym('x', 2, 1)
y_sym = l4c_model(x_sym)
casadi_func = cs.Function('model_rt_approx',
[x_sym, l4c_model.get_sym_params()],
[y_sym])
x = np.ones([1, size_in]) # torch needs batch dimension
casadi_param = l4c_model.get_params(x)
casadi_out = casadi_func(x.transpose((-2, -1)), casadi_param) # transpose for vector rep. expected by casadi

Citing

If you use our work please cite our paper

@article{salzmann2023neural,
  title={Real-time Neural-MPC: Deep Learning Model Predictive Control for Quadrotors and Agile Robotic Platforms},
  author={Salzmann, Tim and Kaufmann, Elia and Arrizabalaga, Jon and Pavone, Marco and Scaramuzza, Davide and Ryll, Markus},
  journal={IEEE Robotics and Automation Letters},
  doi={10.1109/LRA.2023.3246839},
  year={2023}
}