- You can set the sample time parameter for all the source blocks in your model to your desired frequency,
- Set all source blocks to inherit sample time, setting the value in block parameters to -1, and set the FixedStepSize parameter of your Simulink model as shown below (using either MATLAB Command
speed up ROS controller loop rate
7 ビュー (過去 30 日間)
古いコメントを表示
Nathaniel Goldfarb
2021 年 5 月 31 日
コメント済み: Nathaniel Goldfarb
2021 年 6 月 4 日
I am using a MATLAB 2021a.
I made a sliding mode controller to control a robot in a simulation. I have been following several of the examples mainly the feedback example.
However I would really like to run my controller much faster thjen 0.02s I like to increase this by an order of magnitude. 0.02s is rather slow.
How can I increase the loop speed and make sure its stable?
0 件のコメント
採用された回答
Abhijeet Gadkari
2021 年 6 月 1 日
編集済み: Abhijeet Gadkari
2021 年 6 月 1 日
Hello Nathaniel,
Simulink simulation honors the sample time set by you in the model. So, reducing sample time of the model would run your algorithm at a higher frequency in simulation. There are 2 ways to achieve this.
set_param('robotROSFeedbackControlExample20b','FixedStepSize','0.01');
or Simulink Configuration Parameters)
However, the stability would depend on many factors and since Simulation is running on a host computer, the resource contention may affect your Simulation (may be if you shutdown everything else except Simulink simulation). Especially for Simulink model containing ROS (Publish, Subscribe) blocks, there is an inherent overhead of converting the ROS messages that could also affect your throughput.
While selecting the sample time, you need to consider the controller algorithm complexity and account for the ROS message to Simulink bus conversion. For instance, verify if your controller algorithm finishes processing loop within the desired sample time. You can use Simulink Profiler to get this information.
Moreover, deploying the Simulink model as a node would provide more stable execution, since that would run as a standalone application on your robot. But that too has its limitation on how fast you can schedule a thread on Linux. Typically 1 ms is widely accepted limit of most desktop Linux systems. Beyond this limit, the desktop operating system cannot sustain real-time execution (meeting the deadline) of your algorithm.
Let me know if you need further information.
-Abhijeet
2 件のコメント
Abhijeet Gadkari
2021 年 6 月 3 日
編集済み: Abhijeet Gadkari
2021 年 6 月 3 日
Hello Nathaniel,
I've attached a snap-shot of a simple model that uses the custom message, that you provided in your previous post.
I was able to generate code for this model in R2021a MATLAB.
Could you share your Simulink model?
-Abhijeet
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Network Connection and Exploration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!