Issues setting CoordinateSystem for sim3d.Actor to MATLAB in Simulink; need correct initialization method. Also need third-person view in Simulation 3D Scene Configuration
9 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Nishan Nekoo
on 14 Jun 2024
Edited: Nishan Nekoo
on 14 Jun 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.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!