Our target is to create an autonomous indoor robot, which use different control strategies to handle its movements. In this project we present one solution, which model the sensors and implement the model predictive control (MPC).
Some word about MPC control: The model predictive control (MPC) is a well-known control strategy used to solve online optimization problems, and is widely used in autonomous vehicle applications. MPC is computationally expensive and resource-consuming, especially when it comes to the limited resources of embedded computing platforms such as system-on-chip (SoC) and field programmable gate array (FPGA) platforms. Recently, machine learning (ML) has become an effective alternative to classical control systems in terms of reducing the execution time and resource consumption. Model predictive control (MPC) is one of the most commonly used control strategies due to its ability to solve an online optimization problem and handle soft and hard constraints. However, for complex and high non-linear systems, the implementation of MPC is a great challenge; it is often infeasible due to its high computational demands, especially with resource-limited embedded platforms.
The deep neural network is considered a self-optimized method due to its ability to optimize its behavior based on the provided information, and that makes DNNs suitable for complex dynamic systems. Using Matlab Simulink and the MPC tool we found that this creates headache is we use small FPGAs. For this reason at University of Miskolc, we created a DNN tool, which creates from the given input data a parametrizable DNN network based on the System Generator library elements from the given data.
A traditional MPC controller is presented in Fig. 1. The prediction strategy of the MPC controller is performed over the prediction horizon, which represents the next P time steps that the controller looks forward to the future. The MPC controller simulates several future scenarios, and the optimizer chooses the best scenario based on the cost function, which represents the error between the reference target and the predicted out- puts. The optimal scenario corresponds to the minimum cost function.
The controller is computationally expensive since it solves the online optimization problems every time step, which requires high computing capabilities and large memory. The computational load and the high resource consumption make the implementations of MPC on limited resources a big challenge.
The first step in designing the MPC model is to determine the input-output signals of the internal vehicle model and the second step is to set the parameters and determine the constraints. The manipulated variable (steering angle δ) and the disturbance (vx ρ) are determined as input signals, while lateral velocity vy, lateral deviation d, yaw angle θ, and yaw rate ω are determined as output signals (See Fig. 2).
The model equations are as follows:
The constraints are determined as follows: the steering angle is in the range [-1.04, 1.04] rad and the yaw angle rate is in the range [-0.26, 0.26] rad. The parameters were maintained during the design process until satisfactory behavior was obtained. The overall design of the MPC and plant model is shown in Fig. 4.
The design steps are as follow:
- First the traditional of the MPC controller was made; Validate and test the MPC design ; Design of the Deep Neural Network Model, Generate the data sets; Train the DNN model; Validate and test the DNN model; (These steps are particular for each new DNN so these steps are not presented here);
- The next step is to run the IP tool generator (see tool in the attachment);
- Run the simulation and hardware in the loop simulation (see the model and the init file attached);
- FPGA Deployment and test in hardware.
- Create the adaptive hardware platform for KRIA SOM KV260 (see tutorial https://github.com/Xilinx/Vitis-Tutorials/tree/2021.2/Vitis_Platform_Creation/Design_Tutorials/01-Edge-KV260)
- Import the AXI IP DNN to Vivado or Vitis (at the moment of editing and submitting the project we did not get feedback from Xilinx how to import in Vitis the Translated project)
For the auto generation of deep neural network IP the created DNN tool (See attachment file DNN Tool IP generator).
First with the DNN tool the DNN was created. In general terms one who will use the tool should give the following parameters:
The inputs of the tool are the following:
- the number of neurons for each layer
- the precision (floating point or FIX16 or FIX8)
- the weights
- biases
The output is a DNN IP generated in Matlab Simulink.
Remark: the tool is working but some optimizations and embellishment should be considered for different AMD Xilinx platforms. This is a function of the number of neurons and DSP elements contained by the PL (programmable logic). The tool was tested successfully for KC705 board and for Kria KV260 SOM.
First load the DNN_Generator.m file and edit as needed:
%Edit model_parameters_here...neuron_count = [6 20 10 10 1]; % number of neurons in each of the 7 layers%starting model...init;
Then run. The model is created and can be used for own purposes.
Simulation/Hardware in the loop simulation (HIL)Simulation was done in the Simulink environment and we obtained good results. Unfortunately for the Kria KV260 module the System Generator did not permit us to do Hardware in the loop simulation. We made HIL with the KC705 board for the DNN generated. The results obtained with the on KV260 simulation and HIL with KC705 were similar.
The Vivado project created as presented in the following figure (Fig. 5) was translated successfully and exported to Vitis. In the Vitis software we were unable to run even the "hello world" project. Vitis reported "platform not recognized.
In the figure (Fig. 5) can be observed that we created two IP-s one which is AXI compatible and one which has no AXI interface. Our experience was that one without AXI interface worked more correctly on the KC705 platform.
Just to show an example in the following figures we present the results for the the KC705 module, since we could not do HIL and tests on KV260.
The DNN_tool created is useful to implement any DNN network and can be tested in Simulink. Simulation, HIL and implementation can be done in FGPA.
The created tool is free to be used by anyone.
Unfortunately we were not able to test the Model Predictive Control in the Kria board, but probably in the near future we will solve the problem with the help of AMD-Xilinx staff.
The main problem we faced was how to integrate the DNN MPC model to Vitis, without using RTL kernel Wizard.
RemarksHow long it takes (for a person with advanced knowledge) to build a project?
The answer is: 1 hour to train and prepare the DNN. 5 minutes to install the DNN-tool and generate the IP. 10-20 minutes to create a Vivado project by importing the IPs and doing all the necessary setup. 5-30 minutes (depending on the size of the DNN and the optimization strategy) to create the Bitstream. 10 minutes to migrate to Vitis and run the project. 30 - 60 minutes to write the C program and test the results.
How long took us to build the DNN tool and test the tool on different platforms?
The answer is: 5 month working every day around 3-5 hours.
Comments
Please log in or sign up to comment.