Why the time has not been synchronized between ros2 and simulink

조회 수: 3 (최근 30일)
Nupur
Nupur 2024년 5월 13일
댓글: Nupur 2024년 5월 16일
I am subscribing to ros2 topic which has a message type ''ackermann_msgs/AckermannDriveStamped". I checked the topic in ros2 environment and it has 30Hz frequency. Now when I subscribe in simulink and extract the 'sec' I don't get the time duration same as in ros2.
For example: The sample of header.stamp.sec in ros2 looks like this
[t(1)....t(30),t(31)....t(60)]= [1715612265....1715612265, 1715612266....1715612266]
And the sample of the same topic when been subscribed in simulink and been saved in worksapce looks like this:
[t(1)....t(215), t(216)....t(875)]= [1715612265....1715612265, 1715612266....1715612266]
I have tried the 'Simulation pacing', changed the sample time of the subscriber block, changed the fixed step size; still getting the same random time interval.
I am attaching the sample example with all the setting that I am using in Simulink. Please let me know if some setting in simulink is the fault or something else.

채택된 답변

Josh Chen
Josh Chen 2024년 5월 14일
Hi Nupur,
In the model 'Sample.slx' you shared, the 'To Workspace' blocks have been placed at the top level of the model. Hence, they will log values in each time step.
Instead, to log those data only when new message comes (which I assume is what you actually want?), you can place them inside the 'Enable Subsystem'.
Hope that helps,
Thanks,
Josh
  댓글 수: 3
Josh Chen
Josh Chen 2024년 5월 16일
Hi Nupur,
Simulink executes block step function in each time step, and as a result, the Subscribe block returns new output in each timestep. I am suspecting this is because the model is not running fast enough. You probably want to try giving a custom step here and see if it helps:
-Josh
Nupur
Nupur 2024년 5월 16일
Hi @Josh Chen No it didn't help. I already have a question published here. Please let me know if there is any latency issue between Autoware and Simulink or if there is some issue with the simulink model.
Thanks,
Nupur

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Specialized Messages에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by