How to implement an algorithm developed in matlab into ready to fly drone

#1

Hello,

My name is Jeremy, I’m a doctoral student in control field. I developed an algorithm in Matlab Simulink and I would like to implement it in the ready to fly drone described in the link below : https://docs.px4.io/en/flight_controller/intel_aero.html

The point is that I’m not familiar with coding into PX4 controllers and I hesitate between two directions. Maybe you can help me to choose the most appropriate one : The first one proposed by Mathworks presented in the link below propose to install an environment in Matlab able to build directly from Simulink to the PX4 target.


It’s a pretty attractive solution because it seems like “magical”. But there is also a lack of control on how things are performed and I’m not sure it’s done properly. Do you have any experience with this tool ? Does it work well ?

The second one would be to code directly in C++ the code download from github (https://github.com/PX4/Firmware) and then upload it into the ready to fly drone. But as I said I’m not familiar in coding and I’m a little bit afraid to go in this direction because it could take many many times I think. But anyway, if it’s valuable because it’s a safe way to make a clean job I could go in that direction. In this case would you have a good tutorial that explain specifically how to modify and implement a controller into a flight controller ? For instance if I want to change the PID for a LQR controller, how can I do that?

I’m not natural in English but if there is any need of clarifications don’t hesitate to ask me,

Thank you for answering,

Jérémy

1 Like
#2

Hi Jérémy i am a doctoral student in control field like you
and i want to develop an algorithm and a new controler for a quad home made
it’s seems that the solution of mathworks is good to try becuse coding with C will take you many time than the time that you spent on developing

#3

Hi @ismatitou, thank you for your feedback. Indeed, we will try the mathworks solutions which is probably much faster.

#4

Hey @Jeremy,

Did you finally end up using this method? I’m trying to do the same. Did you find any useful resources (ex. tutorials)?

#5

Hi @Safat,

The most usfull informations I found are here :

It explains how to install PSP to implement your algorithm from matlab into PX4 firmware.

Unfortunalty on my side I wasn’t able to install PSP on my computer. I have some error message I’m not able to debug it…

May be you will be more lucky than me if you try :wink:

1 Like
#6

When you say that you found the explanation/information from that link, do you mean that the User Guide is included as part of the PSP installation package?

I tried to download the PSP and it gave me a file for Matlab and steps on installation. I was more interested in the User Guide so that I can follow it and learn how to actually implement it.

Sorry for the late response by the way.