Servers by jDrones

Incorporating control system designed in Simulink into ArduPilot on Pixhawk 2.1 with code generation

Hello all,

I am working with a vehicle which currently uses ArduPilot (ArduRover) and a Pixhawk 2.1. I have designed a novel control system in Matlab/Simulink. I would like to incorporate this control system into the vehicle’s current system, but I have limited experience with C++ so I would like to use one of Simulink’s code generation tools to make this easier. There is a lot of documentation from matlab/simulink on these tools, but my understanding is that I need a hardware support package to make the automatic code generation work. I found these and I would appreciate help with determining if either would be useful to me:

  1. https://www.mathworks.com/matlabcentral/fileexchange/39037-apm2-simulink-blockset
    this package seems to be designed for ArduPilot Mega 2.0 and not Pixhawk.

  2. https://www.mathworks.com/hardware-support/pixhawk.html
    this package is designed for Pixhawk, but specifically mentions PX4, although it seems to use this interchangeably with Pixhawk. My concern is that if it is meant for use specifically with the px4 control system I may not be able to generate useful code from it. The user guide is here: https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/hardware-support/files/Simulink_Pixhawk_Support_v2.1.pdf

I am anticipating this process will require generating code and then consulting with someone more knowledgeable in programming to incorporate into our existing control system, but I want to make sure that any code I am able to generate automatically is usable.

Thank you!

P.S. I apologize if I picked the wrong category for this

Michael,

I am very much interested in the question you have posed for the ArduPilot community. Have you been able to sort this out?

Best,

-Javier

Michael,
What does your control system cover? taking the sensor input and pilot commands and calculating the outputs to the motors? or does it go further than that. I know a group that essentially replaced the attitude controller in the ardupilot software using the pictures to code feature in matlab/simulink. Sounded like they had to map the appropriate inputs and outputs to their controller in simulink. I don’t know the details but it sounds like pictures to code generated either the cpp or object file that they then included into the compilation process using the standard ardupilot compilation tools. Sorry I can’t help you any more. I definitely know that the compilation process was not contained within the matlab/simulink environment.

Hope this helps.
Regards,
Bill

I played with code generation tools and the support packages I listed, but the output was more complex than I wanted so I shelved the project

This control system is for a marine unmanned surface vehicle that takes inputs of body centered velocity and acceleration in three degrees of freedom and inertial position and heading and would output signals that can be converted to motor speeds and angles.

When you say pictures to code do you mean the Simulink coder? I was looking for the correct setting to make this work with a PixHawk and ArduRover when I found the packages I listed in the first post. Thanks for the tip.

Best,
Michael

hi @mas30d, I have a question about your simulink model. I am currently trying to create a custom simulink model for a drone.

Any help will be greatly appreciated. I have sent you a dm.

Thanks.

Servers by jDrones