cBook‎ > ‎

### Robot Dynamics Simulation Subscribe to posts

#### -- Solidworks' Mass properties / Matlab Dynamics simulation

posted Mar 12, 2011, 7:42 AM by Javad Taghia   [ updated Apr 24, 2011, 12:36 AM ]

Solidworks is one of the best commercial softwares for design of mechanical objects and structures. The ability of this software to perform 3D designs easily and user friendly is noticeable.
There are so much interest in using this software in robotics' design as well. As you finished your robot kinematic structure and designing parts in details by use of Solidworks. This structure as a CAD sketch can be used to facilitate analyzing and simulation more efficiently and accurately.

In this short note, I am going to declare some hints and points in order to make usage of this software easier. I had a good experience in this regard in DFKI Bremen.
The project name was VI-Bot. I am not going to discuss the approaches which implied to perform design and analyzing in the mentioned project. But, I want to generalize my acquired experiences dealing with Solidworks and express in clear easy language.

It is better to divide this short tutorial in three main sections:
1. Mass properties window in Solidworks.
• How to get the valuable data from the window
• How to select an appropriate coordinate system
2. Implementation of a simple model in Solidworks
3. Using the extracted data for simulation in Matlab

## Mass Properties Window

In the below figure, a snap shot from the Solidworks' Mass Properties window is depicted.

There are different fields, numbers, expressions and data. Some of parts are pointed by red big arrows.
I am going to explain this window from the top to down. I think it is essential to get an accurate understanding about this window before going to use the data for any purpose.

There are 11 distinguishable pieces of data in this window:
1. Output coordinate system
2. Includes, hidden bodies/components
3. Assigned mass properties
4. Output coordinate system indicator
5. Mass
6. Volume
7. Surface area
8. Center of Mass
9. Principle axis of inertia and principle moment of inertia taken at center of mass
10. Moment of inertia, taken at center of mass aligned with output coordinate system
11. Moment of inertia, taken at output coordinate system

### Selecting POINT and Output Coordinate System

It is logical to start with a short description of moment of inertia. Moment of inertia according to Wikipedia definition is " ... a measure of an object's resistance to changes to its rotation.
In simple world we can consider this measure corresponds to the mass in linear mechanic. As you know we use moment of inertia in rotational mechanical analyzes.
Here I just use some important aspects of moment of inertia which are useful for our purpose that is explanation of Mass Prop. window in Solidworks.
Consider the moment of inertia as a tensor form. it means we have a 3 by 3 matrix for defining the moment of inertia for an object.
What is this tensor: the tensor is a matrix with some special properties (The definition of a tensor as a multidimensional array satisfying a "transformation law" traces back to the work of Ricci. from: http://en.wikipedia.org/wiki/Tensor#cite_ref-Kline_0-0).

Why we use a tensor? Because we want one general value for moment of inertia measure in our calculation which is independent from the axis of rotation.
What is the axis of rotation? Consider an object which is connected to a theoretically mass-less rod. this object is fixed at the end of the rod to one axis. So the totla mass which is considered just concentrated at object is at the end of the rod. In case of any rotation, the mass propagation will not change during rotation, because the rotation axis is fixed. what will happen if because of the structure of our robot we can not consider a fixed axis of rotation? In this case we need to have the value of moment of inertia corresponding to other axis of rotation. For easing this problem, and making an general explanation we use tensor of moment of inertia that is able to provide mass propagation in different cases of rotation around arbitrary rotational axis.

So we have a tensor as the result extracted from Mass Prop. window.
How to calculate moment of inertia if we do not have software as Solidworks? It is critical question, because if one is able to answer this question, he/she is able to analyze the data of Mass Prop. .

Consider I have one object similar to a cylinder.  I want to find moment of inertia for this object.
The first question which should be asked is:
Where is the POINT which we are going to calculate moment of inertia for this object?
And then:
What is the alignment of the coordinate system at this POINT?

The first question could be critical when you are using the value of moment of inertia tensor for your simulation of multi-body robots. Because you want to have the value at a point which is fixed during kinematic change of body. So select a point which is fixed in the body during robot performance.
For the second question, it is essential to know the scenario of simulation for your robot. I will explain it in more detail.

In The cylinder image you can see in below.

On this cylinder there are 4 points (p1,p2,p3,p4) and there are 6 different coordinate systems (CSs).
Because of symmetry in the shape of the cylinder the center of mass is located at the point 1. the other points 2, 3,4 are the points that we can con consider them as s symmetrical point (if we know that our object has uniform density overall).
You can consider each of these points or any other point on this object even out side the object like the point 4. Which one is a wise choice?

In the definition of the moment of inertia I emphasized on the mass propagation at different axis. Hence, we can understand that if the point which is selected as the POINT for calculating moment of inertia is at the location which the object is symmetrical we are more closer to finding the same mass distribution along each axis at the POINT.
Based on this conclusion, I decide the center of mass is the most appropriate point for this purpose.
Now, the question is What coordinate system alignment or easier question. What are the set of axis which we are going to calculate the mass propagation along?
As shown in the last picture of cylinder, the c1 is the one which can be selected because we can see the mass propagation is symmetrical along the axis (note: here just 2 axis for simplicity have been shown.). If you do some calculation based for getting the value of moment of inertia tensor you reach to one diagonal matrix as the resulting tensor of moment of inertia. The CS which has this symmetrical property which reached to a diagonal tensor is called principle axis of inertia and the diagonal tensor is called principle moment of inertia tensor.
Other points or other CSs do not have this properties. It means the tensor has non-diagonal elements. Just as a note, the moment of inertia non-diagonal elements can be positive or negative depending on the alignment of CS and the position of the point. The diagonal elements are always positive because the mass is always positive.

So, we understand that there is no limitation for considering POINT and CS for calculating moment of inertia. So, if you are doing to calculate by hand it is better to consider the simplest set of POINT and CS. But, how about the Mass Prop window? Where is the selected POINT and what is the CS? and other question Which one is better?

At first lets say in Solidworks there is no limitation actually as well for selecting the POINT and the CS. It is just necessary to define a coordinate system as you wish and then use the Mass Prop. tool to calculate the moment of inertia tensor in different points.
Why I say different points? It is the advantage of this software, when you define a CS and wants to get the inertia tensor value at the POINT which CS is positioned, the Mass Prop. tool gives you more data than you requested. Actually the last field (in our filed description list the 11th one) "Moment of inertia, taken at output coordinate system"  is the one you decided to find the tensor value at. It means for one object at the POINT which selected CS is located the moment of inertia is given.
It seems good, easily we reached to our wanted result. Actually it is right. But some important points should be considered as well. Firstly, it is necessary to look at your project as a big picture. Then decide about the sub assemblies in the whole exoskeleton or robot body. After these two steps you know how the kinematic chain of the robot is considered. You can calculate corresponding Jacobian matrix for your robot when you define the particular CSs at each "joint".  So, you have some predefined CSs in your exoskeleton. It is better to consider those CSs in your CAD also.
Hence I can specify some steps:

I. Define CSs of the whole body. Every moving joint must have on CSs, based on different methods for finding end effector transformation matrix we align the
CSs carefully, have a look on this Wiki page http://en.wikipedia.org/wiki/Denavit-Hartenberg_Parameters for one of the most famous methods.

II. Calculate moment of inertia at a POINT which is fixed during robot performance. So, it seems any point at center of mass is a good candidate.

III. Select the output coordinate system in the Mass Prop. as the one you assigned before for your model kinematic chain. It is at the joint.
Look at the below picture, the CS2 is adjusted at center of mass and it is aligned with the coordinate system at the joint CSj2.

IV. The calculated value at center of mass when the CS is aligned with output coordinate system is useful for our purpose.

Now, we get the value of moment of inertia when our coordinate system is aligned with the one at the join and at the POINT which is center of mass.

One important point should be noticed here, it is about a kind of convention in the representation of values in Mass Prop window. Take care the non-diagonal elements of the moment of inertia tensor are shown without negative sign. It means if you are going to use this value in other softwares as moment of inertia tensor you must multiply every NON-DIAGONAL elements in -1. Then the tensor is valid in the convention. For more detail you can do one simple example by this software and do the calculation manually for finding the difference between this representation and the convention of moment of inertia tensor.

### Coordinate Transformation in Solidworks

The question arising why is it important to know how to do coordinate transformation in Solidworks?
The answer is: in general when you have a defined CS an a joint because of any reason you may want to align the CS at center of mass in another configuration.
So the resulting moment of inertia tensor would be at POINT center of mass but the alignment is accordance to different output coordinate system. It is not the adjoining CS. Before going forward, I think it is good to define adjoining CS. Adjoining CS is the coordinate system that is assigned at the joint before the link, in the previous picture CSJ2 is an adjoining CS.
Why  is adjoining expression  important? Because in the next step we will see this adjoining keyword in Matlab simulation tool. When you are going to define the kinematic chain the importance of adjoining CS for easing definition will be clear.
Another important know is the POINT which is acceptable according to Matlab simulation tool. The POINT is always considered at center of mass (gravity) of the object.

Thus, we want to know everything accordance to the adjoining CS. When I get inertia tensor at center of mass but aligned with output CS different from adjoining CS. I have one problem. I need to know the transformation matrix of the Coordinate system that is aligned with the output CS. This transformation matrix is used in Matlab simulation tool for rectifying error due to non-aligned CS to adjoining CS.

The question is:
Can I get this transformation matrix directly by Solidworks tools?
The answer is no and yes.
No, because there is not any specific tool and direct general way to get this matrix.
Yes, because we use API code and some programming efforts to get the value. This method is not easy. It is a little bit tricky. For a simple code check this example:

So, in general, it is better to forget this alternative and try to follow a standard approach of using adjoining CS as the output CS in Mass Prop window. The moment of inertia tensor at center of mass aligned with output coordinate system (10th: Moment of inertia, taken at center of mass aligned with output coordinate system) is your data.
In summary:
The POINT is: Center of mass.
The output CS is: Adjoining CS.
The tensor is: the Moment of inertia, taken at center of mass aligned with output coordinate system data
NOTE: Do not forget to multiply -1 to non-diagonal elements as explained before.

### Another Useful Data in Mass Prop. Window

The second is one special case. Consider you are going to calculate principle moment of inertia tensor and you want to have one diagonal matrix in your calculation. In this case the Mass Prop. tool provides good service. You can use the three vectors of transformation of principle axis (9the: Principle axis of inertia in the window).
In summary:
The POINT is: Center of mass.
The output CS is: Adjoining CS.
The tensor is: the principle moment of inertia which is a diagonal matrix.
NOTE1: There is not any non-diagonal elements so multiply to -1 is not necessary.
NOTE2: The transformation matrix is given with in 3 vectors of Principle axis. Use these vectors to form 3 by 3 rotation matrix and 3 by one translation vector.

### Explaining other Mass Prop Fields

Here I am going to describe briefly every field of Mass Prop. window. Main fields' application have been explained in detail before.
1. Output coordinate system : As explained the best option is adjoining CS. So, defining the accurate adjoining CS is necessary before using this window tool.
2. Includes, hidden bodies/components: In Solidworks there is the possibility to hide some parts of bodies or sub assemblies in order to make more clear show. So, you can select inclusion or exclusion of hidden bodies by this option in mass properties calculation. After any change click on "Recalculate button"
3. Assigned mass properties: It is used if we want to assign different properties to the mass specifications of the selected body without interfering  the graphical model.
4. Output coordinate system indicator: At the top we will see which CS is considered as output CS. It is just for indication.
5. Mass: Amount of mass of our sub assembly our body.
6. Volume: Amount of volume.
7. Surface area: Surface area of body is calculated and is shown.
8. Center of Mass: a vector from output CS to center of mass. It is a useful data for finding translation vector which is essential in kinematic chain configuration in Matlab simulation tool. Because the output CS is adjoining CS the value is valid and useful in Matlab simulation.
9. Principle axis of inertia and principle moment of inertia taken at center of mass: This option has been explained in 1.3 section of this article.
10. Moment of inertia, taken at center of mass aligned with output coordinate system: This option has been explained in sections 1.1 and 1.2.
11. Moment of inertia, taken at output coordinate system: This option has been explained in section 1.1. In general you can get value of tensor at any arbitrary POINT which is located at desired output CS by this option. But, take care due to lack of direct method for finding coordinate transformation in Solidworks, this tensor is not very useful for our simulation. Specially when we use Matlab simulation tool.

## Implementation of a Simple Example in Solidworks

I am going to implement one simple example. In this example we have a very simple structure as illustrated in the picture below.

We can see there are two links (link1 and link2). There is one actuator consists of two parts (Act1, Act2). The first link is fixed at one end to the fixed structure( It is considered the ground of our structure in simulation implementation.).

Every link at the end which is connected to the actuator has a kind of cylindrical hole as shown in the picture below. During calculation by hand you can consider this hole or just ignore it in your calculation. The result is not far different from the value getting by software.

The specifications of the rigid bodies are summarized in the following table. These values are necessary for designing kinematic chain of the robot in simulation software.

 part name Mass    (grams) Length (millimeter) Radius (millimeter) link1,2 8397.4 400 50 hole in link - 100 10 act1 3141.59 50 50 act2 6283.19 100 50

We define CSs based on the configuration of our robot. We consider adjoining CSs at the same orientation to the World CS. The CSs are shown in the following picture:

I would like to point out some important hints here.

• The first point is we have two ultimates in selection of a simple rigid bodies. The minimum number can be achieved if we consider every moving joint as a new adjoining CS. So, the whole body between two moving joints considered as a rigid body. This body may have different components in different angles. It is not important in this assumption. We just draw an imaginary ellipsoid around those fixed parts between two moving joints. Then we calculate the moment of inertia tensor for this ellipsoid by use of Solidworks Mass Prop. tool easily not different with what we do for an uniform simple geometrical shape. The complicity does not bother us because the Mass prop does the hardest part which is calculation of moment of inertia tensor according to the output CS (adjoining CS at the first end of ellipsoid) and at center of mass of the ellipsoid.
Hence, in this way during simulation we can not observe the content of ellipsoids as our rigid bodies resembling the fixed parts between two moving joints. We can see the dynamic behavior of our structure in minimum simple form of illustration. The maximum number of parts are not limited. It is based on your need. It means you are going to divide the complex rigid body between two moving joints in number of separate parts. There is not any advantage actually in this division. Maybe for more understandable simulation some important fixed angles can be considered as separate fixed joint, or when you have one adjustable fixed joint. This joint will not change during the performance of robot but it changes the dynamic of robot during initialization. For example the robot hand length is adjustable. You decide about the length before running the robot by some sort of bolts and nuts. Then when you start the robot this adjusted length is fixed. If you do not have these two cases (important angles and adjustable fixed joints) it is not logical to increase the complexity of your dynamic model.

• The second point is related to the actuators at moving joints. During the simulation it is essential to consider the joints mass less. It means you just consider rotation around axis or  moving along axis or other complicated movements. But you do not consider mass for a joint. So, it is important to have in your mind that during selection of ellipsoid it is important to divide the actuator in two separate parts. consider one part of the actuator as the primitive link and the remaining part of actuator is considered as a part of ellipsoid of the successive link. So, in your model you have mass less joints. The actuator mass and components are divided in two parts each is added at one corresponding link.

• In the example here. I considered the ellipsoid1 composed of (link1 and act1) and the second ellipsoid composed of (act2 and link2). But, because I wanted to ease calculation by hand easily for your usage. I just divided the fixed rigid body in the ellipsoid1 in two separate parts as link1 and act 1. Similarly the ellipsoid2 in tow separate parts as link2 and act 2. So, here I did not used the  minimum number of ellipsoids approach. I extended the numbers to reach to simplicity and clear demonstration.
You can see the ellipsoids of our simple robot in minimum (black ones) and the non-minimum (green ones) approach (the one we are going to use). Also we can see the axis of rotation which is corresponds to the Z axis of the world CS and the mass-less rotational joint position.

In the following pictures we can see the result of Mass Prop. tool in Solidworks for our simple structure. Here we have four ellipsoids so we need four adjoining CSs and four moment of inertia tensors.But, I add one mass prop window for the whole body. This can be useful for getting the value of total mass, and the position of the center of gravity of our whole system at initial condition. Initial condition is the rest condition or the condition that our robot is configured to start at. Moreover, the circled values are important settings and data. For selection just one subassembly I hided the other unwanted bodies in Solidworks software to get the value specifically for particular ellipsoid. The Solidworks version is 2004.

The center of gravity can be seen in pink shown CS on the picture above. It is clear that the position and orientation of center of mass will be changed during operation because we have moving joint which change the mass propagation during time.

It is clear that the inertia tensor taken at center of mass aligned with output CS which here is Adjoin_CS1_link1, is a diagonal matrix. because center of gravity is located at the point which the object is symmetrical.

As I explained before, we consider two ellipsoids so we have to calculate another tensor for moment of inertia. This tensor is diagonal one as well. As the Coordinate system is aligned to the symmetrical configuration of our body and taken at the point which is at center of mass.

The second part of the actuator is shown above. It is the third ellipsoid.

The last ellipsoid is the link2. As you can see the tensor in every ellipsoid is diagonal. So, it will be easy to confirm the results even by hand calculation without using Mass Prop. tool. For this purpose use the table of moment of inertia tensor on the wiki page: http://en.wikipedia.org/wiki/List_of_moment_of_inertia_tensors

The resulting Mass Prop. can be summarized in a table (the measurement values are in SI standard system so we have KG and Meter. This is different from the picture dimensions).

### Extracted Data from Mass Prop. Window

 Extracted data from Mass Prop. Window Link 1 - Ellipsoid 1 Output  coordinate System: AdJoin_CS1_link1Mass = 8.397 kilogramsCenter of mass: ( meters ) X = 0.000 Y = 0.000 Z = -0.198Principal axes of inertia and principal moments of inertia: ( kilograms * square meters )Taken at the center of mass.  Ix = (0.000, 0.000, 1.000)    Px = 0.011  Iy = (0.000, -1.000, 0.000)    Py = 0.116  Iz = (1.000, 0.000, 0.000)    Pz = 0.116Moments of inertia: ( kilograms * square meters )Taken at the center of mass and aligned with the output coordinate system. Lxx = 0.116 Lxy = 0.000 Lxz = 0.000 Lyx = 0.000 Lyy = 0.116 Lyz = 0.000 Lzx = 0.000 Lzy = 0.000 Lzz = 0.011Moments of inertia: ( kilograms * square meters )Taken at the output coordinate system. Ixx = 0.447 Ixy = 0.000 Ixz = 0.000 Iyx = 0.000 Iyy = 0.447 Iyz = 0.000 Izx = 0.000 Izy = 0.000 Izz = 0.011 Actuator part 1 - Ellipsoid 2 Output  coordinate System: AdJoin_CS1_act1Mass = 3.142 kilogramsCenter of mass: ( meters ) X = 0.000 Y = 0.000 Z = -0.025Principal axes of inertia and principal moments of inertia: ( kilograms * square meters )Taken at the center of mass.  Ix = (1.000, 0.000, 0.000)    Px = 0.003  Iy = (0.000, 1.000, 0.000)    Py = 0.003  Iz = (0.000, 0.000, 1.000)    Pz = 0.004Moments of inertia: ( kilograms * square meters )Taken at the center of mass and aligned with the output coordinate system. Lxx = 0.003 Lxy = 0.000 Lxz = 0.000 Lyx = 0.000 Lyy = 0.003 Lyz = 0.000 Lzx = 0.000 Lzy = 0.000 Lzz = 0.004Moments of inertia: ( kilograms * square meters )Taken at the output coordinate system. Ixx = 0.005 Ixy = 0.000 Ixz = -0.000 Iyx = 0.000 Iyy = 0.005 Iyz = -0.000 Izx = -0.000 Izy = -0.000 Izz = 0.004 Actuator part 2 - Ellipsoid 3 Output Coordinate System: AdJoin_CS1_act2Mass = 6.283 kilogramsCenter of mass: ( meters ) X = -0.001 Y = -0.000 Z = -0.050Principal axes of inertia and principal moments of inertia: ( kilograms * square meters )Taken at the center of mass.  Ix = (0.000, 0.000, 1.000)    Px = 0.008  Iy = (0.000, -1.000, 0.000)    Py = 0.009  Iz = (1.000, 0.000, 0.000)    Pz = 0.009Moments of inertia: ( kilograms * square meters )Taken at the center of mass and aligned with the output coordinate system. Lxx = 0.009 Lxy = 0.000 Lxz = 0.000 Lyx = 0.000 Lyy = 0.009 Lyz = 0.000 Lzx = 0.000 Lzy = 0.000 Lzz = 0.008Moments of inertia: ( kilograms * square meters )Taken at the output coordinate system. Ixx = 0.025 Ixy = 0.000 Ixz = 0.000 Iyx = 0.000 Iyy = 0.025 Iyz = 0.000 Izx = 0.000 Izy = 0.000 Izz = 0.008 Link 2 - Ellipsoid 4 Output  coordinate System: AdJoin_CS1_link2Mass = 8.397 kilogramsCenter of mass: ( meters ) X = 0.000 Y = -0.202 Z = 0.000Principal axes of inertia and principal moments of inertia: ( kilograms * square meters )Taken at the center of mass.  Ix = (0.000, 1.000, 0.000)    Px = 0.011  Iy = (0.000, 0.000, 1.000)    Py = 0.116  Iz = (1.000, 0.000, 0.000)    Pz = 0.116Moments of inertia: ( kilograms * square meters )Taken at the center of mass and aligned with the output coordinate system. Lxx = 0.116 Lxy = 0.000 Lxz = 0.000 Lyx = 0.000 Lyy = 0.011 Lyz = 0.000 Lzx = 0.000 Lzy = 0.000 Lzz = 0.116Moments of inertia: ( kilograms * square meters )Taken at the output coordinate system. Ixx = 0.457 Ixy = 0.000 Ixz = 0.000 Iyx = 0.000 Iyy = 0.011 Iyz = 0.000 Izx = 0.000 Izy = 0.000 Izz = 0.457

## Simulation in Matlab by Extracted Data

How can we do the simulation by Matlab for this structure consists of two rigid bodies?

At first it is necessary to get introduced to Matlab simulation toolbox for robot dynamics simulation. The name of this toolbox is SimMechanics.
"SimMechanics software is a block diagram modeling environment for the engineering design and simulation of rigid multibody machines and their motions, using the standard Newtonian dynamics of forces and torques."

We are going to use this software for simulation a simple example which has been designed in previous section by Solidworks.
I recommend studying the User Guide () of this software for more information. This toolbox is powerful and easy to use.
Even though Matlab toolbox is one of the good options. There are different commercial and non-commercial (open source) softwares for dynamics simulation.
I think it would be useful to know the name of these software. The implementation of robot dynamics is similar in different softwares.

• Commercial softwares:
• . Dymola/Modelica
• . 20-sim
• . Matlab SimMechanics toolbox
• Open source:
• . ODE: Open Dynamics Engine.
• . OpenRAVE: Open Robotics Automation Virtual Environment.
I do the simulation step by step.
At first lets consider the gravity force direction. It is necessary for simulation in Matlab SimMechanics.
We consider gravity force direction along X direction of the World CS in our model.
This vector has shown in the below picture, also the fixed point of the link1 has shown on the right hand side of the picture in gray.

At first writing a m-file is necessary to ease the implementation in the simulink toolbox.
You can download m-file and model in simulink from the zipped folder (matlab_model.zip) as an attachments of this page. Also Solidworks files are in a zipped folder (solidworks_model.zip).

The resulting model is similar to the following picture.

For more clarification I add another demonstration of CSs in our model.
Look at the position of adjoining CSs. During the definition. We always reference other CSs of the body (CG and CS2) to CS1. So, the calculation is easier. An the CS1s are always aligned with World CS.
Look at the picture below which is one of the setting for the body link1. The important data is circled in red.
The corresponding M-file is shown in below. As you can see we have to calculate the CG and CS2 of our kinematic chain in M-file. The CG directly has been calculated by Solidworks. The calculation of CS2 is easy just think about the kinematic configuration of the rigid bodies and the connection point.
Always primitive-body is the same location and orientation of CS2_successive-body.
Moreover, we have to use Weld-joints in order to connect every body to another body. So in the above model you can see for connecting body to body we have to use a weld. Also Ground is considered as fixed body without any specification. So, it is necessary to use a weld for connecting body to the Ground.

I recommend to look carefully in the model and M-file and compare the data to the data extracted from Solidworks and body length and radius.

clear all;
close all;
%--------------------------------------------------
% link1 specifications:
Mlink1 = 8.397% kilograms
%Center of mass: ( meters )
%X = 0.000
%Y = 0.000
%Z = -0.198
 cgxl1=0
 cgyl1=0
 cgzl1=-0.198

 c2xl1=0
 c2yl1=0
 c2zl1=-0.40 % distance from CS1_link1 to the point at CS1_act1 which is connecting point point CS2_link1

%Moments of inertia: ( kilograms * square meters )
%Taken at the center of mass and aligned with the output coordinate system.
% Lxx = 0.116 Lxy = 0.000 Lxz = 0.000
% Lyx = 0.000 Lyy = 0.116 Lyz = 0.000
% Lzx = 0.000 Lzy = 0.000 Lzz = 0.011
Ilink1=[0.116 0 0 ;0 .116 0; 0 0 0.011]

%---------------------------------------------------

% actrator part1 specifications:

Mact1 = 3.142 %kilograms

%Center of mass: ( meters )
% X = 0.000
% Y = 0.000
% Z = -0.025
 cgxa1=0
 cgya1=0
 cgza1=-0.025

 c2xa1=0
 c2ya1=0
 c2za1=-0.05 % distance from CS1_act1 to the point at CS1_act2 which is connecting point CS2_act1

%Moments of inertia: ( kilograms * square meters )
%Taken at the center of mass and aligned with the output coordinate system.
% Lxx = 0.003 Lxy = 0.000 Lxz = 0.000
% Lyx = 0.000 Lyy = 0.003 Lyz = 0.000
% Lzx = 0.000 Lzy = 0.000 Lzz = 0.004
Iact1=[0.003 0 0 ;0 .003 0; 0 0 0.004]
%---------------------------------------------------

% actrator part2 specifications:

Mact2 = 6.283 %kilograms

%Center of mass: ( meters )
% X = -0.001
% Y = -0.000
% Z = -0.050
cgxa2=-0.001 % it must be zero; here because of error in alighnemt we have 1 milimeter error; this is ignorable.
cgya2=0
cgza2=-0.050

c2xa2=-.001
c2ya2=0
c2za2=-0.10 % distance from CS1_act2 to the point at CS1_link2 which is connecting point CS2_act2

%Moments of inertia: ( kilograms * square meters )
%Taken at the center of mass and aligned with the output coordinate system.
% Lxx = 0.009 Lxy = 0.000 Lxz = 0.000
% Lyx = 0.000 Lyy = 0.009 Lyz = 0.000
% Lzx = 0.000 Lzy = 0.000 Lzz = 0.008
Iact2=[0.009 0 0 ;0 .009 0; 0 0 0.008]
%--------------------------------------------------
% link2 specifications:
Mlink2 = 8.397 %kilograms

%Center of mass: ( meters )
% X = 0.000
% Y = -0.202
% Z = 0.000
cgxl2=0
cgyl2=-0.202
cgzl2=0

% there is no connection after link two so defining CS2_link2 is not
% essential but we define for better understanding
c2xl2=0
c2yl2=-0.4% distance from CS1_link2 to the point at CS1_NEXT BODY which is connecting point CS2_link2
c2zl2=0
%Moments of inertia: ( kilograms * square meters )
%Taken at the center of mass and aligned with the output coordinate system.
% Lxx = 0.116 Lxy = 0.000 Lxz = 0.000
% Lyx = 0.000 Lyy = 0.011 Lyz = 0.000
% Lzx = 0.000 Lzy = 0.000 Lzz = 0.116
Ilink2=[0.116 0 0 ;0 .011 0; 0 0 0.116]