The vehicle models in our VeSyMA suite of libraries are multibody models, so when using them it is helpful to understand some of the basics of working with 3-dimensional mechanical systems. This previous blog post explained about multibody orientations, so in this post I’m going to look at how variables in the mechanical systems can be resolved in different multibody frames.
Multibody Frames – A Recap
Our multibody models contain frames, which define the local coordinate system of the 3-dimensional component being modelled. These frames provide the interface between multibody models. As such frames contain:
- r_0 the position vector from the world frame to the connector frame, resolved in and relative to the world frame.
- R the orientation object to rotate the world frame into the connector frame.
- f and t the force and torque resolved in the connector frame.
All of our multibody experiments must contain a world model, this provides the world or ‘global’ reference coordinate system within our multibody experiments. The world also allows us to define gravity.
In our multibody experiments there will be many frames, which may be orientated differently as components move relative to each other, or if we have chosen to use a different local coordinate system to make parameterisation easier. As a simple example, lets look at a multibody pendulum model shown in Figure 1.
Figure 1- Simple multibody pendulum example, on the left is the Dymola diagram and on the right the animation showing the frames.
The Dymola diagram of the pendulum experiment, shown above left, consists of a world and a revolute joint allowing a body with mass to rotate around the world y-axis under the influence of gravity. A frame visualiser was added to the end of the body and the world frame animated so we can see the different frames in the above right image. As we can see the world frame and body frame have different orientations as the body moves.
Resolving Variables Between Frames
The Modelica Standard Library (MSL) contains a package of functions for working with multibody frames. I’m going to look at the functions that let you manipulate what frame a vector is resolved in.
Figure 2 – The Modelica.Mechanics.MultiBody.Frames package contains many functions for working with multibody frames.
Lets take a look at this using the example below with two bodies moving in space. The world frame is shown in black, body 1 with its associated frame in blue and body 2 with its associated frame in red. The video below shows that the orientations of the body frames change relative to the static world frame.
The Dymola models simulated in the above video is shown in the Dymola diagram below; only the bodies and frames were animated.
Figure 3 – Diagram of the two body models in Dymola, highlighting frame connectors.
For each body’s frame we know:
- their position relative to the world frame origin and resolved in the world frame (r01 and r02)
- their orientation object to rotate the world frame into the body frame (R01 and R02)
Figure 4 – Body frame definitions, those in black are known.
But what if we want to know the position of body 2 relative to body 1, resolved in the body 1 frame, i.e. r12 in Figure 4? For this we use the MSL resolve2 function to transform a vector from the first frame to the second frame of the given orientation object. In this case, the orientation object is R01 where the first frame is world and second frame is frame 1, and the vector is the difference between the frame 2 and frame 1 positions resolved in the world frame. This gives:
r12= Modelica.Mechanics.MultiBody.Frames.resolve2(R=R01, v1=r02-r01)
Using the model variables from figure 3, this equates to:
r12= Modelica.Mechanics.MultiBody.Frames.resolve2(R=body1.frame_a.R, v1=body2.frame_a.r_0 - body1.frame_a.r_0)
The body’s frame also contains the force vector resolved in that body’s frame, but what if we wanted the body 1 force vector resolved in the world frame instead. For this we can use the MSL resolve1 function to transform a vector from the second frame to the first frame in the given orientation object. So the orientation object is R01 again, and the vector is the forces at the body 1 frame resolved in frame 1. To calculate the force at frame 1 resolved in the world frame:
f0= Modelica.Mechanics.MultiBody.Frames.resolve1(R=R01, v2=f1)
f0= Modelica.Mechanics.MultiBody.Frames.resolve1(R=body1.frame_a.R, v2=body1.frame_a.f)
Alternatively what if we wanted the body 1 force vector resolved in frame 2 rather than frame 1. This time we can use the resolveRelative function to transform a vector resolved in frame 1 to frame 2 using the orientation objects of the frames. The vector input is the body 1 force resolved in frame 1, the frst orientation object is for frame 1 R01 and the second for frame 2 R02:
f2= Modelica.Mechanics.MultiBody.Frames.resolveRelative(v1=f1, R1=R01, R2=R02)
f2= Modelica.Mechanics.MultiBody.Frames.resolveRelative(v1=body1.frame_a.f, R1=body1.frame_a.R, R2=body2.frame_a.R)
Finally, what if we wanted to know the orientation object to rotate frame 1 into frame 2, i.e. R12 above in figure 4? For this we can use the MSL relativeRotation function to determine R12 from the known frame 1 and 2 orientation objects:
R12 = Modelica.Mechanics.MultiBody.Frames.relativeRotation(R01, R02)
R12= Modelica.Mechanics.MultiBody.Frames.relativeRotation(body1.frame_a.R, body2.frame_a.R)
So by using the frame functions available in MSL we can manipulate variables in our multibody models to be resolved in the frame or coordinate system of our choice.
Written by: Hannah Hammond-Scott – Modelica Project Leader
Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion.