Synchronize Simulink node with PX4 SITL - ROS - Gazebo

6 ビュー (過去 30 日間)
Iftach Naftaly
Iftach Naftaly 2021 年 4 月 1 日
編集済み: Jakobus Louw 2021 年 10 月 28 日
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.

回答 (2 件)

Abhijeet Gadkari
Abhijeet Gadkari 2021 年 5 月 3 日
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 件のコメント
Iftach Naftaly
Iftach Naftaly 2021 年 5 月 3 日
I'll contact the technical support.
Thank you.

サインインしてコメントする。


Jakobus Louw
Jakobus Louw 2021 年 6 月 17 日
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 件のコメント
Diego Rojas
Diego Rojas 2021 年 10 月 28 日
編集済み: Diego Rojas 2021 年 10 月 28 日
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 2021 年 10 月 28 日
編集済み: Jakobus Louw 2021 年 10 月 28 日
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

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by