How do I make SimMechanics Visualization focus on one body in a model in SimMechanics 2.7.1 (R2008a)?

1 view (last 30 days)
I have a simple model which contains a center body and a satellite. The satellite orbits the central body using Newton's law of gravitation. I want the visualization to track the satellite and not the central body.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 24 Nov 2009
The ability for SimMechanics Visualization to focus on one body when there is more than one is not available in SimMechanics 2.7.1(R2008a).
There are two possible workarounds:
1) If there is only one body in the model, you can focus on that body by first clicking on "Fit Machine to View" and then unchecking the SimMechanics->Viewpoint->Enable Automatic Axis Resize option. This will cause the visualization focus to move with the body.
2) If there are multiple bodies in your model, you can manually manipulate the camera object to make it follow a certain body. Attached is an example MATLAB file as well as a modified version of the SimMechanics mech_rolling_sphere demo, which demonstrate this approach. When you run the modified demo model, you will notice the ball will be tracked by the camera. This workaround has been implemented by taking the following steps:
a. Measure the position of the point to track using a body sensor (in this case the Sphere)
b. Feed the position using a MATLAB block to the setMachineCamera function
c. The setMachineCamera function finds the visualization window, gets its camera object and updates it using the body position
More information about the setMachineCamera function can be found in its comments. Note that this approach may be reducing performance of your simulation due to the presence of a MATLAB block in the Simulink model.

More Answers (0)

Categories

Find more on Simulation and Analysis in Help Center and File Exchange

Products


Release

R2008a

Community Treasure Hunt

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

Start Hunting!