Effacer les filtres
Effacer les filtres

Issues setting CoordinateSystem for sim3d.Actor to MATLAB in Simulink; need correct initialization method. Also need third-person view in Simulation 3D Scene Configuration

6 vues (au cours des 30 derniers jours)
I'm encountering issues when trying to set the CoordinateSystem property for the sim3d.Actor object in Simulink. According to the documentation, this property should be configurable to use the MATLAB coordinate system, but it results in an error. I need guidance on the correct method to achieve this in the initialization script.
Additionally, I want to configure the Simulation 3D Scene Configuration block so that when selecting my Actor defined in the Simulation 3D Actor block as the Scene view, the view is in third person rather than the default coordinates [0 0 0].
Issue 1: Changing Coordinate System
I am trying to set the CoordinateSystem property for a sim3d.Actor object to use the MATLAB coordinate system. Here is the current initialization script:
fileName = "QuadCopter_Body.stl";
Body = sim3d.Actor('ActorName', 'Body', ...
'Mobility', sim3d.utils.MobilityTypes.Movable, ...
'ActorClassId', sim3d.utils.SemanticType.Vehicle, ...
'CoordinateSystem', 'MATLAB');
World.add(Body, Actor);
Body.load(fileName, [1 1 1]/100);
Body.Color = [0, 0, 1];
Body.Scale = [10 10 10];
Translation = [0.341 0.286 0.042;
-0.341 0.286 0.042;
0.341 -0.286 0.042;
-0.341 -0.286 0.042];
propellerFileName = "QuadCopter_Propeller.stl";
for propellerIndex = 1:4
actorName = sprintf('Propeller%d', propellerIndex);
Propeller = sim3d.Actor('ActorName',actorName, ...
'Mobility', sim3d.utils.MobilityTypes.Movable, ...
'ActorClassId', sim3d.utils.SemanticType.Vehicle);
World.add(Propeller, Actor);
Propeller.load(propellerFileName, [1 1 1]/100);
Propeller.Color = [1, 0, 0];
Propeller.Translation = Translation(propellerIndex, :);
Propeller.Rotation = [0 0 0 ];
Propeller.Scale = [10 10 10];
end
Actor.save("quadcopter.mat")
This is the error:
'CoordinateSystem' is not a recognized parameter. For a list of valid name-value pair argument, see the documentation for this function.
Issue 2: Setting Third-Person View
I also want to set the view in the Simulation 3D Scene Configuration block to be in third person when selecting my Actor defined in the Simulation 3D Actor block. Currently, the view defaults to the coordinates [0 0 0]. How can I change this view to a third-person perspective?

Réponses (1)

Nishan Nekoo
Nishan Nekoo le 14 Juin 2024
Modifié(e) : Nishan Nekoo le 14 Juin 2024
Hi Alessandro,
Thank you for your questions and I apologize for the delay in providing an answer. Here is an answer to both your issues:
1. The 'CoordinateSystem' is not available as a Name-Value Argument and instead this Property must be set after the Body has been created like so:
Body = sim3d.Actor('ActorName', 'Body', ...
'Mobility', sim3d.utils.MobilityTypes.Movable, ...
'ActorClassId', sim3d.utils.SemanticType.Vehicle);
Body.CoordinateSystem = 'MATLAB';
2. Unfortunately, this is a known limitation that we are looking to improve in a future release. For now, you can use a Simulation 3D Camera instead that is attached to the Actor, then set a relative translation and rotation from the actor to achieve a third-person perspective. To visualize the camera images that are output by the Image port, use a Video Viewer or To Video Display block.

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by