Simulink 3D Animation: Zwei Actors miteinander verbinden

14 ビュー (過去 30 日間)
Klaus
Klaus 2025 年 1 月 24 日 12:14
コメント済み: Klaus 2025 年 2 月 4 日 6:53
Hallo,
ich versuche mit Simulink 3D Animation ein Inverses Pendel aufzubauen. Ich habe dafür eine Box (Wagen) und einen Zylinder (Pendel) im Simulation 3D-Actor erstellt.
Cart = sim3d.Actor(ActorName='Cart', ...
Mobility=sim3d.utils.MobilityTypes.Movable);
createShape(Cart,'box', [0.04 0.1 0.04]);
Cart.Color = [1 0 0];
Cart.Translation = [0 0 0];
add(world,Cart,Actor);
Pendulum = sim3d.Actor(ActorName='Pendulum', ...
Mobility=sim3d.utils.MobilityTypes.Movable);
createShape(Pendulum,'cylinder', [0.01 0.01 0.5],3);
Pendulum.Color = [0 0 1];
Pendulum.Translation = [-0.02 0 0.25+0.02];
add(world,Pendulum,Actor);
Über entsprechende Inputs kann ich auch die einzelnen Actors animieren (Translation, Rotation). Kann ich das Pendel mit dem Wagen "verbinden", so dass das Pendel nicht um den Schwerpunkt, sondern um den Verbindungspunkt mit dem Wagen rotiert?
  1 件のコメント
Klaus
Klaus 2025 年 2 月 4 日 6:53
DANKE - das hilft sehr weiter! Auch der Hinweis auf "joints" in der 2025A!

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

採用された回答

Nishan Nekoo
Nishan Nekoo 2025 年 2 月 3 日 21:14
編集済み: Nishan Nekoo 2025 年 2 月 3 日 21:15
Hi Klaus,
One way to do this is to add the Pendulum as a "child" of the Cart instead of the "Actor":
>> add(World,Pendulum,Cart)
Then instead of modifying the translation for the Pendulum so that it is translated correctly relative to the cart, modify its mesh transform using the following workaround:
>> Pendulum.DynamicMesh.transformMesh([0 0 -0.25]);
Then set the Translation to the following:
>> Pendulum.Translation = [0 0 0.02];
Now when the cart moves, the pendulum will move along with it. In addition, the Pendulum rotates about its end point connected to the cart. See the code I used in my Simulation 3D Actor and the attached images.
Hope that helps! I would also check out the prerelease notes for R2025a for a new construct (joints) that may help in modeling these systems instead if using the workaround above.
Nishan
Cart = sim3d.Actor(ActorName="Cart");
Cart.Mobility = sim3d.utils.MobilityTypes.Movable;
Cart.createShape('box', [0.04 0.1 0.04]);
Cart.Color = [1 0 0];
Cart.Translation = [0 0 0];
add(World,Cart,Actor);
Pendulum = sim3d.Actor(ActorName='Pendulum', ...
Mobility=sim3d.utils.MobilityTypes.Movable);
createShape(Pendulum,'cylinder', [0.01 0.01 0.5],3);
Pendulum.Color = [0 0 1];
Pendulum.Translation = [0 0 0.02];
Pendulum.DynamicMesh.transformMesh([0 0 -0.25]);
add(World,Pendulum,Cart);

その他の回答 (0 件)

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!