Synchronize Simulink node with PX4 SITL - ROS - Gazebo

16 vues (au cours des 30 derniers jours)
Iftach Naftaly
Iftach Naftaly le 1 Avr 2021
Modifié(e) : Jakobus Louw le 28 Oct 2021
Hi all,
I'm trying to synchronize my simulink model with px4 SITL ( ROS and gazebo). Is there a good way to ensure that the simulink node staying sync with ROS - Gazebo time? I'm running on ubuntu 18.04 with ROS and gazebo9, matlab 2020b.
I tried few things:
  1. Use pacing simulation while running the node, but it can't run at real time above 50 [Hz] (it start to shift and looses its sync after few steps). I tried to slow down the px4 SITL but it dosent ensure sync with the simulink node.
  2. Build the model from simulink and generate standalone ROS node: the node was very senstive to my fix-step choise - I couldn't make it perfecly sync with px4 SITL.
  3. Build the model from simulink and generate standalone ROS node with "enable ros time simulation stepping": it gives my a "FATAL" error when trying to run the node, unless my fix-step time is exactly the /clock frequency (even not a multiply of this frequency). Is there a way to change the /clock frequency or choose some multiply of this frequency?
Ill appreciate any help,
Thanks,
Iftach.

Réponses (2)

Abhijeet Gadkari
Abhijeet Gadkari le 3 Mai 2021
Hello Iftach,
Option 3. seems the closest to achieve an almost "real-time" execution of your algorithm.
Typically setting the fixed-step size of the model to a multiple of /clock topic publish rate should be sufficient.
However, owing to the complexity of the issue, could you please contact technical support for further assistance?
Thanks.
Abhijeet
  1 commentaire
Iftach Naftaly
Iftach Naftaly le 3 Mai 2021
I'll contact the technical support.
Thank you.

Connectez-vous pour commenter.


Jakobus Louw
Jakobus Louw le 17 Juin 2021
You can syncronise Gazebo and Simulink with the Gazebo Pacer block in Simulink and a GazeboPlugin (provided by MathWorks) in your world file as described in the link.
I have managed to do that by launching a .world file and running a simulink model in sync with it.
However, the Gazebo Pacer block resets time in Gazebo which causes PX4 to stop.
So I am going to try starting Gazebo first, then sync with Simulink, then connect PX4. Ill update you if it works.
Please let us know if you find a solution.
  6 commentaires
Diego Rojas
Diego Rojas le 28 Oct 2021
Modifié(e) : Diego Rojas le 28 Oct 2021
Gotcha,thanks @Jakobus Louw! The issue I am having is that when I start the simulink model + gazebo pacer, the gazebo simulation switches from unpaused to paused. Line 11 in GazeboWorldImpl.cpp seems to pause gazebo. This then effects my ros nodes such as my camera data, and stops publishing data. Curious if you ran into this issue?
Jakobus Louw
Jakobus Louw le 28 Oct 2021
Modifié(e) : Jakobus Louw le 28 Oct 2021
I did not run into that issue.
Are you sure it pauses it? I remember when I ran Simulink with Gazebo it ran much slower than 1x speed. Maybe it just looks paused? Also, Gazebo and Simulink are then synced, but I dont know if ROS is then also synced with Gazebo

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by