measure the ROS loop time in simulink

3 ビュー (過去 30 日間)
Nathaniel Goldfarb
Nathaniel Goldfarb 2021 年 5 月 30 日
コメント済み: Nathaniel Goldfarb 2021 年 5 月 31 日
I am trying to figure out my control loop time in simulink for controlling my simulation using MATLAB 2021a.
I am using the loop control rate block found in these closed loop control example here
The comments say:
% The rate control may not be effective if the simulation model is too
% complex to be handled at the desired rate. To check the rate control
% performance, consider output rateObj.LastPeriod. Ideally it should be
% close to SampleTime during most part of the simulation.
How do I actually output/access the rateObj.LastPeriod in the model so I can make a historgram of the control rate?

採用された回答

Abhijeet Gadkari
Abhijeet Gadkari 2021 年 5 月 31 日
Hello Nathaniel,
The Simulation Rate Control block used in this example is a MATLAB System Object.
You can modify the stepImpl method of this system object class, ExampleHelperSimulationRateControl.m, to add an output argument as below.
function r = stepImpl(obj)
%stepImpl Regulates simulation update
if coder.target('MATLAB')
obj.RateObj.waitfor();
r = obj.RateObj.LastPeriod;
else
r = nan;
end
end
Save the ExampleHelperSimulationRateControl.m class and re-open the model.
You should now see an output port on the Simulation Rate Control block, as shown below.
-Abhijeet
  1 件のコメント
Nathaniel Goldfarb
Nathaniel Goldfarb 2021 年 5 月 31 日
thank you so much. this worked perfectly

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecialized Messages についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by