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:
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.
P.S. I apologize if I picked the wrong category for this
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.
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.
I have done this successfully in the past. The key is to find the combination of Simulink code generation settings that give a sensible output. I don’t have access to the files at present but I should be able to share a project template in a month or two.
Hello, here you can find an interface for ArduCopter and ArduPlane:
ArduRover is not supported yet, but maybe someone could add it (the basic procedure to create the interface is described below in the “contribution” section of the readme file)?
I have already successfully used the ArduCopter interface several times for flight tests.
I have a question that is probably more directed to the developers.
Is there any interest in merging such an interface?
Some work would be needed to merge it, but actually it’s not that elaborate either.
Roughly speaking, the interface is structured as follows:
In ArduPilot there is a new flight mode, which grabs target inputs (stick inputs and waypoints) and measured values (from the state estimator) and stores them in two structs.
Then there is a Matlab/Simulink template, which also has these structs defined as input variables.
The user can then implement any controller (rate controller, position controller, position controller or combinations thereof) in Matlab/Simulink based on these input variables.
Finally, the Matlab/Simulink template provides an output for the servos/motors and an output for logging.
These outputs are defined as inputs in the new ArduPilot flight mode.
With the Simulink Coder a C++ class (three files) can be generated from the template. We are currently copying these files manually into our ArduPilot fork to update the custom flight mode.
I have recently successfully used the ArduCopter interface to test a new passive fault-tolerant flight control law:
I tested the ArduPlane interface with a tailsitter.