Installation

  1. Clone or download ParNMPC from Github: ParNMPC.
  2. Extract the downloaded file.

    Requirements

    ParNMPC supports MATLAB R2016a or later. The following tools are required:

    • MATLAB Coder
    • MATLAB Optimization Toolbox
    • MATLAB Parallel Computing Toolbox
    • MATLAB Symbolic Math Toolbox
    • Simulink Coder
    • C/C++ compiler supporting parallel code generation

    For compilers that do not support OpenMP, code generation will treat parallel computing as serial computing. Check Supported and Compatible Compilers for details.

    Warning

    ParNMPC may not work properly on MATLAB R2017b and R2018a because of the bug that exists in certain Windows 10 builds. Check sym bug report for details.

Directory Layout

The directory layout of ParNMPC is as follows:

.
├─ ParNMPC/                  # Toolkit
│  ├─ ...
├─ docs/                     # Homepage
│  ├─ ...                    
├─ SemiActiveDamper/         # Example of controlling a semi-active damper
│  ├─ NMPC_Problem_Formulation.m  # NMPC formulation and initialization
│  ├─ Simu_Matlab.m               # Closed-loop simulation in MATLAB
│  ├─ Simu_Matlab_Codegen.m       # Executable file generation for Simu_Matlab.m
│  ├─ Simu_Simulink.slx           # Closed-loop simulation in Simulink
│  ├─ Simu_Simulink_Setup.m       # Setup for the Simulink simulation
│  ├─ Timer.m                     # Your own timer function
├─ DoubleInvertedPendulum/   # Example of swinging up an inverted pendulum
│  ├─ ...                    
└─ Quadrotor/                # Example of controlling a quadrotor
│  ├─ ...      
└─ Vehicle/                  # Example of controlling a vehicle
│  ├─ ...                            

Getting Started

This example shows how to perform a Simulink closed-loop simulation in MATLAB R2018b.

  1. Select the Microsoft Visual C++ 2017 (C) compiler:

    >> mex -setup
    

  2. Navigate to the Quadrotor/ folder.

    >> cd  Quadrotor/
    

  3. Open NMPC_Problem_Formulation.m and run.

  4. Open Simu_Simulink_Setup.m and run.

  5. Open Simu_Simulink.slx and run.