Upload custom flight controller on Pixhawk 4 via simulink, and flight tests


I developed my flight controller in simulink, and i tested it In SIL, HITL following the matlab examples Deploy PX4 on Host Computer with PX4 Host Target (PX4 Software-in-the-loop or SITL) - MATLAB & Simulink - MathWorks Italia https://it.mathworks.com/help/supportpkg/px4/setup-and-configuration_mw_06fa168c-661f-4e54-b3b0-197c970f0ac9.htm . Now i want try to perform the flight test with my fligth controller. Now, there isn’t any examples about perform real fligth tests. So, I uploaded the firmware following the HIL procedure:

Build the firmware and upload

  • Default startup script
  • Design flight controller in simulink
  • Boardo Pixhawk 4, whit px4_fmu-v5_default
  • Check that i’m not in HIL mode

Then after these passages i Build Start and deploy my fligth controller into Pixhawk 4.

Now if i try to connect my drone with Qground cotnrol station, all the sensors, frame, GPS, ecc… are ok. So I armed the drone and command the take off, but the motors didn’t start to spinn. I also tried with the example in matlab “px4demo_HardwareInLoopWithSimulinkPlantStart”, but even this dind’t work. I alredy cheked that all the wires are connected.

I also tried to upload the px4demo_PWM and it works, ( basiccally two engine spinn and other two doesn’t move).
But now, if instead to use a constat value 1 (bool) to arm the PWM block, i use the uORB message actuator armed, it doesn’t work.

  • I have all the stuffs in Qground control that are ok
  • I arm the drone, then the engine start to spinn for 1 second
  • After this second they stop, but the drone is still armed

I saw that the actuator_armed message is true, so the drone is armed.

Does anyone have an experience about upload firmware via Simulink and test it?
Thanks in adavce.