-
Notifications
You must be signed in to change notification settings - Fork 95
Code Structure
The whole MPC is based on ACADO (http://acado.github.io/). ACADO's C++ interface is used to describe the quadrotor model and parameters for transcription into a quadratic program, which is then solved with qpOASES (https://projects.coin-or.org/qpOASES). To compile and run, none of these dependencies are needed, since the generated code is already included in this repository. To modify the model and solver options, please install ACADO from http://acado.github.io/install_linux.html.
The code is organized as follows:
The auto-generated model, transcription, and solver is built as a library called mpc_solver
.
This library consist of purely auto-generated code with nomenclature, code-style and structure as used in ACADO.
To wrap this into a standard interface, the library mpc_wrapper
is used.
ACADO uses arrays with column-major format to store matrices, since this is rather inconvenient, mpc_wrapper
provides interfaces using Eigen objects by mapping the arrays.
- It is written to be compatible even with changing model descriptions in the
mpc_solver
. - It should prevent the most common runtime errors caused by the user by doing some initialization and checks with hardcoded parameters, which are overwritten in normal usage.
To provide not only a solver, but a full controller, mpc_controller
is a library based on the previous mpc_solver
and mpc_wrapper
, providing all funcitonality to implement a controller with minimal effort. It provides two main execution modes:
-
Embedded: The mpc_controller can be included in any oder controller class or copilot by generating an object with the default constructor "MPC::MpcController controller();". It still registers node-handles to publish the predicted trajectory after each control cycle, but does nothing more. It only provides the interfaces of
ControllerBase
as in theLargeAngleController
but without a specific class for parameters. -
Standalone (not yet provided): The
mpc_controller
object can be passed node-handles or creates its own, registers multiple subscribers and publishers to get a state estimate as well as the control goals (pose or trajectory) and registers a timer to run a control loop. It works as a full standalone controller which can be used with the oneliner:MPC::MpcController<double> controller(ros::NodeHandle(), ros::NodeHandle("~"));
as intest/control_node.cpp
andlaunch/mpc_controller.launch
.
- The main source code for the ROS node is contained in
include
andsrc
. - The launch file to start the ROS node is located in
launch
, whereas the corresponding parameter file(s) are stored inparameters
in the.yaml
file format. -
model
contains the MPC-descriptionquadrotor_model_thrustrates.cpp
which uses ACADO to generate the code inmodel/quadrotor_mpc_codegen
. -
externals
contains the qpOASES solver used by the MPC.