Simulink 3D Animation: Zwei Actors miteinander verbinden

6 visualizaciones (últimos 30 días)
Klaus
Klaus el 24 de En. de 2025
Comentada: Klaus el 4 de Feb. de 2025
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 comentario
Klaus
Klaus el 4 de Feb. de 2025
DANKE - das hilft sehr weiter! Auch der Hinweis auf "joints" in der 2025A!

Iniciar sesión para comentar.

Respuesta aceptada

Nishan Nekoo
Nishan Nekoo el 3 de Feb. de 2025
Editada: Nishan Nekoo el 3 de Feb. de 2025
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);

Más respuestas (0)

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!