Is "conditionally" executing px4_simulink_app possible?

2 views (last 30 days)
Hello, I have some question about the usage of UAV Toolbox Support Package for PX4 Autopilots Toolbox.
In init.d/rcS file, there is a line
px4_simulink_app start
that enables to start custom simulink app in px4 module. Simultaneously, If I designed flight controller algorithm, commenting out
# mc_att_control start
# mc_pos_control start
in rc.mc_apps file is necessary to execute our simulink app without any collision with existing px4 control algorithm.
However, is it possible to "conditionally" executing this px4_simulink_app?
I know there is the "enabled subsystem" in simulink(Thanks again Arun Mathamkode to answer it) but this is conditionally executing the simulink block, not the px4_simulink_app itself.
What I want to do is leaving the existing px4 control algorithm, and conditionally executing my custom simulink app (For example, If I change the channel in my RC controller). If I make this using "enabled subsystem" block, I have to make the existing px4 control algorithm with simulink, and add my algorithm but this is very tough work because making the px4 control algorithm using simulink again is very hard and cumbersome.
Therefore, to summarize my question,
Q1. Is conditionally executing px4_simulink_app when existing px4 control algorithm runs possible?
Q2. If Q1 is impossible, what I can chose is making px4 control algorithm with simulink and add my custom algorithm, and upload that combined algorithm. Is there any already made "existing px4 controlller algorithm" using simulink? Or, Is there any method that I can easily duplicate the px4 code into Simulink block?
Please forgive my bad English.
Thank you for reading
Sincerely,
Jongwon Lee

Accepted Answer

Ankur Bose
Ankur Bose on 4 Jan 2022
Jongwon Lee,
This is what I have understood of your requirements. Please correct me if I missed anything
  • You would like to switch between your own custom controller algorithm in Simulink and the default PX4 provided controller while the drone is in flight
  • The switch would be an external control.
Today there is no model or block that completely embeds the default PX4 controller in Simulink. One thing I can suggest you is
  • Enable the multicopter controls in rcS that were disabled. (So that they are always enabled).
  • Add your own controller using Enabled System block in Simulink. The Enable signal can be controller using RC.
  • During flight, switch off your own controller when you want. The PX4 controller which are already enabled would kick in.
Now there is a possibility of collision of both the controllers in certain scenarios. But those scenarios might not be appliable for you and you might be able to use both the controllers. Youcan this out to verify this
  2 Comments
종원 이
종원 이 on 6 Jan 2022
Thank you so much for your kind answer. This is exactly what I asked.
One thing I am a little bit curious is that why do you think collision might not be appliable for my situation? I am a little concerned turn on two attitude controller(default & my custom algorithm) simultaneously will make problem due to collision. Wasn't it the reason why we commented mc_att_control start to avoid collision?
Thank you.
Ankur Bose
Ankur Bose on 6 Jan 2022
So instead of collision, think like this. There are two controllers who are taking input from sensors and generating PWM values (one might be a bit better than the other). So the PWM values will be somewhat in between of what the controllers are asking for, but that does not necessarily mean there will be huge difference between those values. So your drone might still be stable even if 2 controllers are running parallely and overwriting each other.
It all depends on how close your controller design matches that of PX4. The more close values they generate, it does not matter even if both are running

Sign in to comment.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!