Dynamic change of coordinates for body position in Modelica MultiBody Library

315 Views Asked by At

I'm fairly new to Modelica, just started a few months ago due to a project I've been working on. Mostly doing work with multibody mechanical systems using the MultiBody library included in the standard Modelica distribution.

I need to change a body position according to the coordinates calculated dynamically during the simulation, but I can't find a way to do so.

This is the vector variable that calculates the position of the center of mass of the given system:

Modelica.SIunits.Length CMG[2];

CMG[1] = ... + cos(part3rotation.angles[3]) ... + part3origin[1] ...;
CMG[2] = ...;

I would like to position a massless body (FixedShape) at the coordinates (CMG[1], CMG[2]) as a way to display the center of mass and its movement during the simulation.

Is there any way to do this?

I've tried to attach the body to a fixed translation component but it expects a parameter (PARAM) instead of a variable (VAR) and this causes an error.

Software used: Modelica 3.2.2 and Wolfram SystemModeler 5.0.

3

There are 3 best solutions below

0
On BEST ANSWER

The solution was to modify the FixedTranslation class to include a new input:

input Modelica.SIunits.Position xyz[3];

and modify the equations:

frame_b.r_0 = frame_a.r_0 + xyz;

Connecting the CMG vector to the xyz vector of the class did the trick.

0
On

I would add a frame Modelica.Mechanics.MultiBody.Interfaces.Frame_b to your body, and then add the following equations (taken from FixedTranslation):

frame_b.r_0 = your_three_d_vector;
frame_b.R = frame_a.R; // or some other orientation

/* Force and torque balance */
zeros(3) = frame_a.f + frame_b.f; // and maybe some other forces in your system
zeros(3) = frame_a.t + frame_b.t + cross(r, frame_b.f); // and maybe some other torques and forces in your system

In order to add an additional connector in Modelica, we would have to consider not only the potential variables (in this case, the position and orientation), but also the flow variables (forces and torques).

0
On

I suppose you calculate the position of the center of mass of the whole system relatively to the inertial system. Then you can completely omit frame_a in your class and thus it would not be necessary to always connect frame_a explicitely to world.frame_b which obviously is obsolete.

Be only sure to use Connections.root(frame_b.R) instead of Connections.branch(frame_a.R, frame_b.R) as originally defined in FixedTranslation.

And one more comment. It is advisable to directly work with vectors instead of position vector components, and to use functions from Modelica.Mechanics.MultiBody.Frames for vector transformations.