MATLAB Answers

Drive the Rotation on a body in Virtual Reality from a simulink model signal

28 views (last 30 days)
Hi, I have a model of a dynamic system (a car) which define 7 DoF (the 4 vertical motion of the wheels + Heave, Pitch and Roll of the body of the car). The car is positioned on 4 pads which are used to provide vertical inputs to the car (similar to a 4-Post rig shaker) The model works fine without the virtual reality.
I realized a virtual reality version of my system (4 wheels + a block for the body + 4 pads)
The virtual reality works fine when only the linear motions are driven
Now I am having problem with driving the "rotation" field of the body.
I tried using a bus creator but this does not work.
I suppose the rotation is a vector(3) with rotation around x,y and z respectively. am I right/
Any help on this is very appreciated
Thanks
G

  0 Comments

Sign in to comment.

Accepted Answer

Mischa Kim
Mischa Kim on 6 Dec 2013
The problem is, that you have 3 rotation angles (yaw, pitch, roll) about different rotation axes and that the VR model requires one rotation parameter, a 4-vector. As explained by Jan, this 4-vector consists of the rotation axis (first 3 elements) and the rotation angle (4th element). So the questions is, how to convert the 3 – they are basically Euler – angles into one rotation axis and one rotation angle.
One way would be to compute the overall rotation matrix R(psi, theta, phi) and then use Euler’s theorem to compute rotation axis and angle.
So, say you have a typical yaw-pitch-roll (3-2-1) rotation sequence about psi, theta, phi. The overall rotation matrix from inertial to body reference frame is given by
R(psi, theta, phi) = R1(phi)R2(theta)R3(psi),
where
R3(psi) = [ cos(psi) sin(psi) 0;
-sin(psi) cos(psi) 0;
0 0 1]
R2(theta) = [cos(theta) 0 -sin(theta);
0 1 0;
sin(theta) 0 cos(theta)]
R1(phi) = [1 0 0;
0 cos(phi) sin(phi);
0 -sin(phi) cos(phi)]
Careful with the particular notation (minus signs) of your rotation sequence, which might be different from the one shown above.
The last step, backing out rotation axis and angle from the overall rotation matrix, I’ll leave up to you. Once you have those, you can use a Mux block to form the 4-vector and feed the signal into the VR.

  1 Comment

Giuseppe Naselli
Giuseppe Naselli on 7 Dec 2013
Hi Mischa!
Yes it WORKS!!!!!! great!
Just to add my bit to your answer for other people that will look at this.
Build the Rotation matrix as suggested by Mischa (I made sure the 3D Virtual Reality World" had the same Axis system reference of my Simulink model)
Place a simulink block "Rotation Matrix to VRML Rotation" just after the Rotation matrix
This basically transforms the rotation matrix into a quaternion as required by the Virtual Reality rotation field.
[Rotation Matrix]-->[Rotation Matrix to VRML Rotationx]-->[VR block body.rotation field]
Thanks Mischa with your help was easier than expected!
G

Sign in to comment.

More Answers (1)

Jan Houska
Jan Houska on 4 Dec 2013
Rotation is not a 3-element vector. Instead, it is a 4-element vector where the first three elements specify the direction of the axis to rotate around and the fourth element is the rotation angle. Try to look at e.g the vrmemb1 example to see how this works. For more information about the VRML97 nodes and fields please see the VRML97 Specification.

  0 Comments

Sign in to comment.

Sign in to answer this question.