[Multibody] Get body frame list from Matlab script
1 回表示 (過去 30 日間)
古いコメントを表示
Since it's not possible to display lines directly in mechanics explorer, I'm plotting speeds on a separate 2D plot for several points of a vehicle. These points correspond to the origins of all the frames defined for a solid block.
How can I access the list of these frames from a Matlab script and retrieve their origins?
By accessing this list, there will be no need to redefine all the 3D coordinates within the script at each change or add to the frame list.
0 件のコメント
回答 (1 件)
Yifeng Tang
2021 年 4 月 30 日
You'll probably need to attach a Transform Sensor to each solid so you can get all kinds of kinematic information of the solid. Some script snippets that may be useful:
% find all solid blocks
solids=find_system(modelA,'LookUnderMasks','all','FollowLinks','on', 'RegExp', 'on', 'ReferenceBlock','sm_lib/Body Elements/Brick Solid');
solids=[solids; find_system(modelA,'LookUnderMasks','all','FollowLinks','on', 'RegExp', 'on', 'ReferenceBlock','sm_lib/Body Elements/Cylindrical Solid')];
solids=[solids; find_system(modelA,'LookUnderMasks','all','FollowLinks','on', 'RegExp', 'on', 'ReferenceBlock','sm_lib/Body Elements/Ellipsoidal Solid')];
solids=[solids; find_system(modelA,'LookUnderMasks','all','FollowLinks','on', 'RegExp', 'on', 'ReferenceBlock','sm_lib/Body Elements/Extruded Solid')];
solids=[solids; find_system(modelA,'LookUnderMasks','all','FollowLinks','on', 'RegExp', 'on', 'ReferenceBlock','sm_lib/Body Elements/File Solid')];
solids=[solids; find_system(modelA,'LookUnderMasks','all','FollowLinks','on', 'RegExp', 'on', 'ReferenceBlock','sm_lib/Body Elements/Revolved Solid')];
solids=[solids; find_system(modelA,'LookUnderMasks','all','FollowLinks','on', 'RegExp', 'on', 'ReferenceBlock','sm_lib/Body Elements/Spherical Solid')];
To add blocks (e.g. sensor) programmatically: add_block (https://www.mathworks.com/help/simulink/slref/add_block.html)
To connect blocks: add_line (https://www.mathworks.com/help/simulink/slref/add_line.html)
You of course will also need scripts to retrieve the sensor readings
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Bodies についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!