How to performe simulation SITL with Gazebo using PX4 Autopilots Support from UAV Toolbox? ERROR displayed

First of all I'm on Ubuntu 20.04.6 LTS and MATLAB 2023a. I've installed the PX4 Autopilot Support from UAV toolbox.I'm trying to performe a SITL with the PX4 Autopilots Support from UAV Toolbox with Gazebo . I created a Simulink blank project, I added a PX4 accelerometer and I've connected it to scopes in order to see if the I/O connection is working. In the settings the only simulator available is jMAVsim there's no Gazebo, but nevermind I've tried the same to launch an I/O connection in SITL(PX4 Host target) with jMAVSIM to check if everything is working.The setup of the PX4 toolbox is the Design Flight Controller Algorithm in Simulink.
When I try to launch the I/O connection (SITL) an error is displayed:
MATLAB System block 'accelerometer_PX4/Accelerometer/PX4 uORB Read/SourceBlock' error occurred when invoking 'setupImpl' method of 'px4.internal.block.Subscriber'. The error was thrown from '
'/home/matteo/Documents/MATLAB/SupportPackages/R2023a/toolbox/target/supportpackages/px4/+px4/+internal/+block/Subscriber.p' at line 196
'/home/matteo/MATLAB/toolbox/target/codertarget/sltoolstrip/m/+codertarget/+internal/+sltoolstrip/ConnectedIOHandler.m' at line 106
'/home/matteo/MATLAB/toolbox/target/codertarget/sltoolstrip/m/+codertarget/+sltoolstrip/EmbeddedHardwareBoardContext.m' at line 493'.
Caused by:
Cannot create a communication link with the remote server. Please check the input arguments(ADDRESS and PORT) and make sure the server is running.
Additional Information: Connection refused [system:111]
How can I fix this problem?
I'm devoloping my master thesis and I have to design a costum controller and implement it on a quadcopter using PX4 Autopilot. Before doing this I have to do the SITL on Gazebo and then flash the controller on a PixHawk controller.

 Accepted Answer

Can you verify that the SITL and jMAVSim are launched without any errors on your machine? We have seen Java dependency issues with jMAVSim on Ubuntu and you might need to resolve those before going ahead with Simulink. Since anyway you want to continue in the future with Gazebo, I would suggest you to give it a try with Gazebo. Yeah, I agree there are no options given for Gazebo, but you can choose the option Simulink plant and proceed with the SITL simulation from Simulink. Before you are running the Controller model make sure you have manually started the gazebo environment and that it is ready for simulation.

3 Comments

I succeeded in running the simulation with jMAVsim but i still do not get how to perform SITL with Gazebo. What do you mean to start manally gazebo enviroment? Do I have to run a simulation with gazebo with the PX4 firmware validated when I built the PX4 Toolchain for Simulink? (I mean the firmware I downloaded following this documentation https://it.mathworks.com/help/supportpkg/px4/ug/download-px4-source-code-ubuntu.html )What is the command to start the gazebo simulation from the PX4 firmware mounted with the mathworks toolchain?
I launched the gazebo simulation from the px4 firmware but when the simulation starts I have this error on the terminal:
ERROR [simulator] poll timeout 0, 22
How can I fix it?
Try starting the controller first and then running the plant

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!