Presentation Introduction To Virtual Reality in Simulink
Presentation Introduction To Virtual Reality in Simulink
Objective:
Show you how to simulate a mathematical system in Simulink and
visually check your equation on a real-virtual system.
r 1.5m
h0 20m
Note: y is measured from the
ground to the center of the ball.
dy 2
g
2
dt
Collision equation
dy 2
dy 2
if y r , Fy m 2 K 0 r y mg m 2
dt
dt
K0
dy 2
r y g 2
m
dt
Before collision
After collision
rx
ry
ry
rx ry rz r
ry
rx
Note: There
compression!
is the amount
of compression
is
ball
rx rz ; ry y
Assumption: after collision, the deformation in the x and z direction are equal.
Collision equation
dy 2
if y r , 2 K r y g
dt
K0
m
After bouncing
Before bouncing
Sphere Volume
4 3
r
3
Ellipse Volume
4
rx ry rz with ry y
3
Lets assume rx
rz
4 2
4 3
rx y r rx rz
3
3
Scale equations
rx rz
r3
; ry y
y
r3
y
dy 2
g
dt 2
Collision equation
Scale equations
dy 2
if y r , 2 f g
dt
rx rz
f K r y
r3
; ry y
y
if y >= r
f = 0;
rx = r; ry = r; rz = r;
K = 500;
r = 1.5;
Step 3: drag and drop the Simulink Virtual Reality Sink block from the Simulink 3D
Animation Library
Step 4: Install the Virtual reality editor by typing the following command in the Matlab prompt
This Transform node is for the Sphere-Ball. To rename the Transform node: 1) Right-click
the Transform node. 2) Select the Edit Name menu item. 3) In the edit box to the left of
the Transform node, type Ball.
Step 8: Expand the Children Node, then the Shape and right-click on the Appearance node in
order to add an appearance under the appearance node.
Step 12: Click on Translation and Set the ball to its initial position, at 20 m
Note: After clicking on Apply, the Ball will Vanish from the Screen. Do not Panic. Do the following
to bring the ball back.
It is also advisable to save your file Now before continuing!!!
Note: Change the Viewpoint so as to have a good vision of the Ball. You can set different
viewpoint from the above viewpoint.
Step 14: Lets add our floor where the Ball is going to bounce. The Floor is nothing but a Box
Node.
Lets copy the Ball Transform Node and make change from this Node. Right Click the
Ball(Transform), Then Copy it. Then go to the Edit menu, then Paste
Step 15: Refer to previous steps and rename it as Floor. Then expand all, Go to the Shape
node and delete the Sphere, then add a Box instead.
Step 17: Then Go to Translation and bring the Floor position down
Note. You can Click on the wheel of your mouse and drag the mouse in order to slightly roatate and see
The system in 3D.
Step 18: Close it and save it when it prompts to do so, then go back in your Simulink Model,
Double-click on the VR Sink, then Browse and find the location of the file you just saved.
Step 20: Now Real things Start!!! We want to link our Simulink output signals to the Virtual Reality
Block. Since we are interested in the translation of the Ball, lets thick the Translation checkbox of
the Ball.
Note that the translation node is a 3 by 1 vector, representing the translation on the x, y and z
axis. Since we only have one translation here on the y axis, we sill use a VR Signal Expander. The
output width is 3 and the non-zero index is 2, meaning the value of y.
The VR Signal Expander can be found in the Simulink 3D Animation Tab
Step 21: We want to see the actual deformation of the ball. It can be done using the Scale along
the x, y and z axis