ROS Toolbox / Code Generation / MW_BASERATE_PERIOD

2 visualizaciones (últimos 30 días)
Jaehyeon Im
Jaehyeon Im el 10 de Jul. de 2019
Respondida: Ganesh Regoti el 24 de Jul. de 2019
Hello Mathworks team, always thank you for the hard work.
I'm now working with ROS Toolbox, making my algorithms and generating code to my linux machine.
I checked that generated ROS Node in Linux PC works well, but one thing the function's period is kind of wierd.
I want to run my Function subsystem working as callback function (every Topic A is subscribed, the function runs).
So I made 'Enable block' in my Function subsystem and connect it with Subscribe block's 'IsNew' signal refer to the tutorials in your pages.
Here's the problem, after generating codes and executing in Linux, Topic 'A' is published per 10ms but my Function runs per 20ms.
And I looked into some generated code, my Function's period is handled by the variable "MW_BASERATE_PERIOD" which value is 0.2.
I checked that my Function runs with period 10ms after I changed that variable to 0.1.
I wonder that why my Function runs with this period and also doesn't run as callback function way.
I look foward to your answer, thanks !

Respuestas (1)

Ganesh Regoti
Ganesh Regoti el 24 de Jul. de 2019
From your question, I understand that there are two sections to be answered
1. MW_BASERATE_PERIOD set to 0.2: It is nothing but the step size of the Simulink model, the default calculation
for step size is clearly mentioned in the below link
But you can manually set the step size in Simulink
For fixed-step solver: Model Configuration Parametes> Solver Details > Fixed-Step Size
For variable step solver: We cannot set the step size to fixed but constraints can be added like max step size, min
step size. Model Configuration Parametes> Solver Details
2.Enable Sub Systems: The enable sub system reacts at the transitions. Suppose the enable block is fed with the
1, then the subsystem continues to run until it is fed with 0. And continues to be in that state until it is fed with 1
again.
So, the enable sub-system doesn’t run as the callback because it can be controlled only at transitions i.e., one can
start or stop the subsystem. There is a clear explanation of Enable Subsystems in the following link

Categorías

Más información sobre Publishers and Subscribers en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by