Pushing a custom simulink UAV model to px4.

Hello @everyone,
Please, I am looking for a step by step tutorial on how to develop px4_simulink_app from UAV simulink model using Simulink UAV Toolbox support package, in order test the performance of my custom controller in a real-life quadrotor flight test.
Thank you.

 Accepted Answer

Have you tried out thecontroller deployment examples in the support package? The support package already contains controller deployment examples which you can run on Host or Autopilot. You dont need to develop the px4_simulink_app. The support package will take care of that for you

11 Comments

Thank you. I did check them. However, I am yet to understand how to excute it with my quadcopter model, I am looking how to send the position(x,y,z) and attitude(roll,pitch and yaw) through the uORB so I can put my simulink model in px4. I have both position and attitude controller combine with disturbance observers. I will appreciate if you can put me through. Thank you
Did you try deploying your model as mentioned in the example?
@Ankur Bose, Thank you for the response.
No, I did not, the reason being:
  1. I could not run the model on my pc, it was throwing up error messages,
  2. I could not comprehend the example model setup and how it relates with my model.
As a result, I am unable to ascertain which uORB blocks I needed to setup subscription and publishing for my model, Please I will appreciate any step by step guide on how to deploy my model with the support package, I have setup px4 support package toolchain,given below is the picture of my model... Thank you.
What was the error you got when you tried deploying the model?
UASLAB
UASLAB on 9 May 2023
Edited: UASLAB on 9 May 2023
This is one error I got when deploying this "Read Waypoints from the Mission uploaded from GroundControl station and follow it" example on linux
Error:Compilation failure for command "/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-g++ No such file or directory compilation terminated." (I shortened this error statement because I could not submit all of it for posting, it was not going.)
This second example 'Altitude and Position Tracking via Rate Controllers for X type Quadrotor Vehicle using UAV Toolbox Support Package for PX4 Autopilots' was successfully deployed but could not connect to QGC and I am getting the erorr below on terminal. jMAVSim is running but quadrotor not moving. The QGC and jMAVSim launches and connect well during hardware setup.
----INFO [px4] Startup script returned successfully
ERROR [simulator] poll timeout 0, 22
ERROR [simulator] poll timeout 0, 22
ERROR [simulator] poll timeout 0, 22
ERROR [simulator] poll timeout 0, 22
ERROR [simulator] poll timeout 0, 22----
Thank you.
could please give me a guide on how I can implement my model(the picture shown in the response above) with the support package? The example model are different from my model(I have my own quadrotor dynamics in which I am considering ground effect and wind disturbance).
I anticipate your response.
Thank you
I have been able to deploy as mentioned in the example but the quacopter in jMAVSim does not move even though the build was successful. I keep getting the error shown in the picture below(indicated by the blue box). Please, how do I resolvethis error? Thank you
How did you deploy? did you run Monitor & Tune?
I run Build Deploy & start. No, I did not run Monitor&Tune. Also, my control algorithm has continuous blocks (integrator and derivatives) in it...hope no problem with this... Thank you.
As per the documentation you shared, you have to run Monitor & Tune. See Task 3. Follow the doc to see the correct behavior
UASLAB
UASLAB on 19 May 2023
Edited: UASLAB on 19 May 2023
Okay.Thank you

Sign in to comment.

More Answers (2)

As per your initial question, I understand that you want to deploy the custom controller on a PX4 autopilot for a real flight test. From the Comments from the earlier answer, I see that you are facing issues with SITL as well. Since your end goal is to try with real hardware, I would recommend you start creating a custom controller and verify it with HITL before the actual flight. You can refer to the HITL example to get started.

4 Comments

Alright, I will follow your guide and try this on windows instead. I will feed you back on the outcomes. Thank you.
I am tried the HITL example but I am getting this error.
Caused by:
  • Unable to create a communication link with the serial port. Please check the input argument PORT and verify that a device is connected.
I have tried to check my serial conncetion but that did not solve the problem. Please how do I solve this, I am using pixhawk 4 mini.
have you set the serial port of your pixhawk Mini correctly in the HITL model?
Please, what can I do to solve this problem... I deployed my custom controller in SITL UAV Toolbox support package for PX4 using the example model, the controller could not stabilize the quadcopter in jMAVSim it goes up, fly around and then crash. The controller works well in the model base design in simulink.
Thank you.

Sign in to comment.

Please, what can I do to solve this problem... I deployed my custom controller in SITL UAV Toolbox support package for PX4 using the example model, the controller could not stabilize the quadcopter in jMAVSim it goes up, fly around and then crash. However, the controller works well in the model base design in simulink.
Thank you.

Products

Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!