# How to implement a novel control algorithm for a drone

I and my research team are working on a novel drone design based on trirotor. The difference between this design and a trirotor is that it has an extra propeller to generate additional thrust, therefore we can not use the open-source autopilot ArduPilot anymore. I have prototyped a control algorithm on MATLAB/Simulink but I don't know how to implement this algorithm on the drone. I have encountered this on so many papers but I still don't know how they did it.

What type of hardware and coding should I need to prepare and learn in order to realize the algorithm? Should we continue to learn and modify the source code of open-source Autopilot like Ardupilot or it would be easier for us to start from scratch with a hardware?

• Welcome to Robotics, Hoàng Đình Thịnh. You said you have a control algorithm in Matlab - what is the trouble you're having in implementing the algorithm? It should be a copy/paste operation for you, with editing as required to fit the destination language syntax. Please edit your question to clarify what specifically you're having trouble with. – Chuck Sep 17 '18 at 16:36
• Hi, I'm taking a look at ArduPilot firmware since it has very good implementation of Kalman filter that I can take advantage of. However, reading the Ardupilot source code seems daunting for me. I have a fully working Simulink model at the moment, and I do not know how to get started with implementing the algorithm: continue using Ardupilot or start from scratch with, say Arduino. I've edited my questions based upon your suggestions. Many thanks. – Hoàng Đình Thịnh Sep 17 '18 at 16:53

Assuming you know how to model a regular quadrotor as $$\dot{x} = Ax + Bu$$, the only difference with the addition of the extra propeller will be in your control matrix and control vector (one more dimension and different control derivatives).

You need to assess 2 things:

1. which sensors are needed and their interface
2. which ESCs you have and their interface.

Once you know that it is possible to find the proper control board can fit your purpose. You should go for something micro-controller based like arduino. I suggest you not to start from scratch but from an available open source project and replace in the code what is needed for you tri-copter. This way you don't need to rewrite all the utilities for communication, sensors readings and so on.

You will need to have some skill in C/C++ to do that. You might be able to retrieve your matlab prototype via a library using matlab c-code generating tools.

• Hi, I've been trying to learn from Ardupilot but I've had a hard time trying to comprehend the source code since there are too many modes and a lot of finite-state machine codes. Would you recommend me continue learning from Ardupilot or should I start fresh from, some Arduino codes available online? Many thanks. – Hoàng Đình Thịnh Sep 17 '18 at 16:50
• I think you should get familiar with the ArduPilot functionalities and modes from the documentation and then identify what you would use and/or re-use and modify. From there only look at the code related to that. Ardupilot at full is a complex software, if you are not familiar with the high-level functioning you can easily get lost in the source code. I suggest you to look for the attitude controller (which is what you are likely to need for your special design) – N. Staub Sep 27 '18 at 14:27