simulink ros2 generated node rate

Hi all,
I'm using ROS toolbox with matlab 2022a, ros2 foxy and cyclonedds rmw all on ubuntu 20.04.
I created a simple publisher node model within Simulink which publish some message each iteration.
When I generate ros2 node from the Simulink model I set my model's solver type as fix-step with some fixed-time step, which I assume to be the working frequency of the generated ros2 node.
After the node is generated I run it but the publish rate is way faster than I set on the fixed-time step configuration of the model.
Am I missing some settings of the code-generation that controls the working rate of the node?
Thanks,
Iftach.

3 Kommentare

Jagadeesh Konakalla
Jagadeesh Konakalla am 28 Apr. 2022
Hi Iftach,
There are few factors that affects the publish frequency from Simulink model.
  • Sample time of the model
  • Size of the message data.
  • Number of publishers in the model
The generated code will publish the message at the sample time mentioned in the simulink model. During the Simulink Simulation, you need to consider the message data passing between Simulink and ROS 2 network. Where as in the generated code, the node runs on the ROS 2 and Simulink is not in the loop.
Can you share your Simulink model ? What is the base rate that model is configured ? How are you measurng the publish frequency ? How much fast that you see generated node publishes than Simulation ?
Thanks,
Jagadeesh K
Iftach Naftaly
Iftach Naftaly am 9 Mai 2022
Hi Jagadeesh,
Thanks for your help.
I created a simple model which publish only one topic /my_topic on std_msgs/Bool.
The base rate of the model is 100 [Hz] (meaning the solver is set to fixed step with fixed step size of 0.01). After generating the code for the ros2 node, I ran the node and measured the rate with ros2 topic hz /my_topic and got about 250[Hz] avarage rate.
I'm working with CycloneDDS RMW implementation.
Thanks again,
Iftach.
Iftach Naftaly
Iftach Naftaly am 19 Jun. 2022
It seem that this issue will be solved with the new updates of 2022b, especially the loop rate conrtol with ROS2 Time object.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Jagadeesh Konakalla
Jagadeesh Konakalla am 4 Nov. 2022

0 Stimmen

It seem that this issue will be solved with the new updates of 2022b, especially the loop rate conrtol with ROS2 Time object.

Produkte

Version

R2022a

Gefragt:

am 28 Apr. 2022

Beantwortet:

am 16 Mai 2025

Community Treasure Hunt

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

Start Hunting!

Translated by