Calculate the Center of Gravity of a PHX
Calculate the Center of Gravity of a PHX
I have a complex structure with multiple Geoms and Joints in a PHX file. I'd like to calculate the position of the center of gravity for entire component at any given position in space (XYZ).
Is this possible?
Thanks,
Travis
Is this possible?
Thanks,
Travis
Re: Calculate the Center of Gravity of a PHX
Hi travis,
Well, it is not possible directly.
If you are using 'auto' rigid bodies, the inertia matrix is computed automatically, per body. So, the body position is exactly the inertia matrix position. But, today, it is not possible to retrieve the entire matrix ...
If you are interested in retrieve the body's inertia matrix values, please say me : i will add this feature in TODO list.
Because you are using joint, you will have to combine inertia matrix of each connected bodies in order to get the total matrix.
Well, it is not possible directly.
If you are using 'auto' rigid bodies, the inertia matrix is computed automatically, per body. So, the body position is exactly the inertia matrix position. But, today, it is not possible to retrieve the entire matrix ...
If you are interested in retrieve the body's inertia matrix values, please say me : i will add this feature in TODO list.
Because you are using joint, you will have to combine inertia matrix of each connected bodies in order to get the total matrix.
LR
Re: Calculate the Center of Gravity of a PHX
LR,
Thanks for the quick reply and building an awesome modeling product!
To confirm, if I have two Geoms that each weight 1kg and the position of Geom1 is 1, 0, 0 and the position of Geom2 is 1, 0, 0, then the center of gravity would be 0, 0, 0. Is that correct?
Any simulation involving balance requires a calculation of the center of gravity of any moving part (i.e. an arm or leg) and usually those parts are made up of multiple geoms. So, I think it would be a very helpful feature to be able to calculate the center of gravity for a group of Geoms.
BTW, where can I find your roadmap for the product and the list of all future enhancements? I'd like to see what features to expect.
Thanks again!
Thanks for the quick reply and building an awesome modeling product!
To confirm, if I have two Geoms that each weight 1kg and the position of Geom1 is 1, 0, 0 and the position of Geom2 is 1, 0, 0, then the center of gravity would be 0, 0, 0. Is that correct?
Any simulation involving balance requires a calculation of the center of gravity of any moving part (i.e. an arm or leg) and usually those parts are made up of multiple geoms. So, I think it would be a very helpful feature to be able to calculate the center of gravity for a group of Geoms.
BTW, where can I find your roadmap for the product and the list of all future enhancements? I'd like to see what features to expect.
Thanks again!
Re: Calculate the Center of Gravity of a PHX
The calculation of the COG of multiple objects looks pretty straightforward (http://www.wikihow.com/CalculateCenterofGravity).
However, I could not find in the documentation where to programmatically get the mass of a Geom. I see were to set it in the editor, but not in the MODA namespace.
What function can I use to get the mass of a Geom?
However, I could not find in the documentation where to programmatically get the mass of a Geom. I see were to set it in the editor, but not in the MODA namespace.
What function can I use to get the mass of a Geom?
Re: Calculate the Center of Gravity of a PHX
hi,
Is it ok for you ?
Yes it is correct. The inertia position should be 0,0,0, the other values are computer according to geometry type. The inertia matrix is not the same if there is a box at 1,0,0 and a big sphere at 1,0,0 or if you have 2 boxes.To confirm, if I have two Geoms that each weight 1kg and the position of Geom1 is 1, 0, 0 and the position of Geom2 is 1, 0, 0, then the center of gravity would be 0, 0, 0. Is that correct?
It is the case ! the inertia matrix of a body is computed according to its geometries type, mass, length. Today you cannot retrieve it by using MODA but this matrix is available in the simulator. So it is not complex for us to maque this matrix 'readable' from MODA.So, I think it would be a very helpful feature to be able to calculate the center of gravity for a group of Geoms.
Well, i add today the "ModaCPP::GeomBody::GetInertiaMatrix()" in TODO list. I thing it will be available for the end of the week (in beta download, i will contact you when ready).BTW, where can I find your roadmap for the product and the list of all future enhancements? I'd like to see what features to expect.
Is it ok for you ?
LR

 Site Admin
 Posts: 95
 Joined: Wed Feb 07, 2007 11:10 am
 Location: Montpellier  FR
Re: Calculate the Center of Gravity of a PHX
Hi,
Can you please send an email to support at anykode dot com about this topic.
LR will sendback a link to download the update (within the next 2 days) . Please say in this email if you are using Marilou X86 or X64.
The update allows to get the Inertia values of a specified rigid body: Mass, Kinematic mode, Center offset/Body position, Tensor values.
Thanks
Can you please send an email to support at anykode dot com about this topic.
LR will sendback a link to download the update (within the next 2 days) . Please say in this email if you are using Marilou X86 or X64.
The update allows to get the Inertia values of a specified rigid body: Mass, Kinematic mode, Center offset/Body position, Tensor values.
Thanks
Re: Calculate the Center of Gravity of a PHX
Hi!
I 'm trying to calculate the CG of a complex body too.
Thanks,
Martin.
I 'm trying to calculate the CG of a complex body too.
Is ModaCPP::GeomBody::GetInertiaMatrix() available now and what kind of data it retrives?Well, i add today the "ModaCPP::GeomBody::GetInertiaMatrix()" in TODO list. I thing it will be available for the end of the week (in beta download, i will contact you when ready).
How i can use this function to retrieve the mass or the centre offset for example?.The update allows to get the Inertia values of a specified rigid body: Mass, Kinematic mode, Center offset/Body position, Tensor values.
Thanks,
Martin.
Re: Calculate the Center of Gravity of a PHX
Hi,
You have a sample in the documentation: http://doc.anykode.com/ModaCPP__GeomBod ... tia__.html
The inertia Matrix par of the returned structure is computed by ODE: it is an accumulation of body's geoms inertia type and masses (see ODE doc for more details).
Cheers
You have a sample in the documentation: http://doc.anykode.com/ModaCPP__GeomBod ... tia__.html
The inertia Matrix par of the returned structure is computed by ODE: it is an accumulation of body's geoms inertia type and masses (see ODE doc for more details).
Cheers
LR
Re: Calculate the Center of Gravity of a PHX
Hi! thanks for reply.
I have some questions about the values it retrieves. I will take an example to explain myself better. i have a Sphere of 50 kg , radius 5 m and positioned at :
0,0 ; 5,0; 0,0 and Inerty type: Auto.
The fuction retrives Centre, the position of the Centre of Mass of a geometry , in the example the CM must be in 0,0;5,0;0;0 however it retrives 0;0; 0,0; 0,0 and this is not true...what kind of reference Moda takes for calculate the CM? Between wich points is it calculated? I try to change the geometry trying a box but the Centre is still : 0;0; 0,0; 0,0 no matter its mass or geometry its always the same.
I really don't understand the meaning of the inetertia matrix , the fuction retrives 3 vectors in this case :
0,036 ; 0,0; 0,0
0,0 ; 0,036; 0,0
0,0 ; 0,0; 0,036
What mean this values ?
Other question is: How to calculate the CM of a complex body wich rigid bodies has more than one geometry and are conected by joints? I have read that LR said.
Sorry for this so much extended reply, i hope someone could help me, I will be glad .
Thanks,
Martin.
I have some questions about the values it retrieves. I will take an example to explain myself better. i have a Sphere of 50 kg , radius 5 m and positioned at :
0,0 ; 5,0; 0,0 and Inerty type: Auto.
The fuction retrives Centre, the position of the Centre of Mass of a geometry , in the example the CM must be in 0,0;5,0;0;0 however it retrives 0;0; 0,0; 0,0 and this is not true...what kind of reference Moda takes for calculate the CM? Between wich points is it calculated? I try to change the geometry trying a box but the Centre is still : 0;0; 0,0; 0,0 no matter its mass or geometry its always the same.
I really don't understand the meaning of the inetertia matrix , the fuction retrives 3 vectors in this case :
0,036 ; 0,0; 0,0
0,0 ; 0,036; 0,0
0,0 ; 0,0; 0,036
What mean this values ?
Other question is: How to calculate the CM of a complex body wich rigid bodies has more than one geometry and are conected by joints? I have read that LR said.
How can do this?Because you are using joint, you will have to combine inertia matrix of each connected bodies in order to get the total matrix.
Sorry for this so much extended reply, i hope someone could help me, I will be glad .
Thanks,
Martin.
Re: Calculate the Center of Gravity of a PHX
Hi,
The CM you retrieves is relative to the parent of the geometry: its rigid body. When the RB is in auto mode, the sphere is centered on the RB. So your CM is (0,0,0). If you combine several geoms, the center will probably not be (0,0,0).
The CM you retrieves is relative to the parent of the geometry: its rigid body. When the RB is in auto mode, the sphere is centered on the RB. So your CM is (0,0,0). If you combine several geoms, the center will probably not be (0,0,0).
You should refer to ODE documentation, mass.cpp file. For exemple for the sphere:I really don't understand the meaning of the inetertia matrix , the fuction retrives 3 vectors in this case :
0,036 ; 0,0; 0,0
0,0 ; 0,036; 0,0
0,0 ; 0,0; 0,036
What mean this values ?
Code: Select all
void dMassSetSphere (dMass *m, dReal density, dReal radius)
{
dMassSetSphereTotal (m, (dReal) ((REAL(4.0)/REAL(3.0)) * M_PI *
radius*radius*radius * density), radius);
}
void dMassSetSphereTotal (dMass *m, dReal total_mass, dReal radius)
{
dAASSERT (m);
dMassSetZero (m);
m>mass = total_mass;
dReal II = REAL(0.4) * total_mass * radius*radius;
m>_I(0,0) = II;
m>_I(1,1) = II;
m>_I(2,2) = II;
}
CM of a joints connected bodies is a complex stuff ... you should retrieve CM of each body and combine them according to joints orientation / angle. Take a look at ODE functions dMassAdd, dMassTranslate and dMassRotate : we are using those functions to create 'auto' bodies CM.Other question is: How to calculate the CM of a complex body wich rigid bodies has more than one geometry and are conected by joints? I have read that LR said.
LR
Re: Calculate the Center of Gravity of a PHX
Hi !
Thanks for the replay, i really don't understand how i can make a reference beteween the origin of World, it being (0;0;0), and the CM of my rigid bodie ( complex or not). For example, i have a humanoide with joints. I added the CM of every part in order to calculate the CM of the whole body. However, this function retrieves the same vector (x;y;z) wherever humanoide's position is. How can i refer this CM to the origin of the world? and Is this value real?.
The ecuation i used was:
Summation of (M*P) = m1*p1 + m2*p2 + ... + mn*pn
Final position in X is: XF=( m1*p1 + m2*p2 + ... + mn*pn)/M
Final position in Y is: =
Final position in Z is: =
In my code is (with less part to make it easier):
M= (float)((InertiaValues1.Mass)+(InertiaValues2.Mass)+(InertiaValues3.Mass));
XF =((InertiaValues1.InertiaMatrix[1].x)+(InertiaValues2.InertiaMatrix[1].x)+(InertiaValues3.InertiaMatrix[1].x)) /M;
YF= ((InertiaValues1.InertiaMatrix[2].y)+(InertiaValues2.InertiaMatrix[2].y)+(InertiaValues3.InertiaMatrix[2].y)) /M;
ZF= ((InertiaValues1.InertiaMatrix[3].z)+(InertiaValues2.InertiaMatrix[3].z)+(InertiaValues3.InertiaMatrix[3].z)) /M;
Note: i have use the method "Inertia Matrix" believing that it returns a matrix of three vectors which has 3 float positions each one, one of this vectors is supposed to retrive the CM. How ever, i really don´t know what that vectors refers to so i added them aleatory (the position which has a value, for example: the inertia matrix of the sphere). In this case, the first component of the first vector for X , then the second component of the second vector for Y and the same for Z. I did so because the method "Centre" always retrieves (0;0;0) no matter the body position or it's compositions of geometries.
Thanks,
Martin.
Thanks for the replay, i really don't understand how i can make a reference beteween the origin of World, it being (0;0;0), and the CM of my rigid bodie ( complex or not). For example, i have a humanoide with joints. I added the CM of every part in order to calculate the CM of the whole body. However, this function retrieves the same vector (x;y;z) wherever humanoide's position is. How can i refer this CM to the origin of the world? and Is this value real?.
The ecuation i used was:
Summation of (M*P) = m1*p1 + m2*p2 + ... + mn*pn
Final position in X is: XF=( m1*p1 + m2*p2 + ... + mn*pn)/M
Final position in Y is: =
Final position in Z is: =
In my code is (with less part to make it easier):
M= (float)((InertiaValues1.Mass)+(InertiaValues2.Mass)+(InertiaValues3.Mass));
XF =((InertiaValues1.InertiaMatrix[1].x)+(InertiaValues2.InertiaMatrix[1].x)+(InertiaValues3.InertiaMatrix[1].x)) /M;
YF= ((InertiaValues1.InertiaMatrix[2].y)+(InertiaValues2.InertiaMatrix[2].y)+(InertiaValues3.InertiaMatrix[2].y)) /M;
ZF= ((InertiaValues1.InertiaMatrix[3].z)+(InertiaValues2.InertiaMatrix[3].z)+(InertiaValues3.InertiaMatrix[3].z)) /M;
Note: i have use the method "Inertia Matrix" believing that it returns a matrix of three vectors which has 3 float positions each one, one of this vectors is supposed to retrive the CM. How ever, i really don´t know what that vectors refers to so i added them aleatory (the position which has a value, for example: the inertia matrix of the sphere). In this case, the first component of the first vector for X , then the second component of the second vector for Y and the same for Z. I did so because the method "Centre" always retrieves (0;0;0) no matter the body position or it's compositions of geometries.
Thanks,
Martin.
Re: Calculate the Center of Gravity of a PHX
The inertia matrix is not a position/orientation matrix. As explained before, this is the components of the inertia:How can i refer this CM to the origin of the world?
 the offset from the body's world position = (0,0,0) if your CM is located exactly at the body's absolute position
 the 3*3 components of the inertia matrix
Your body location in the world can be retrieved by GetMatrixAbsolute.
Read the post here before The inertia is depending of the geometry(ies) types/masses/and offsetsi really don´t know what that vectors refers to so i added them aleatory
Code: Select all
You should refer to ODE documentation, mass.cpp file. For exemple for the sphere:
Code: Select all
void dMassSetSphere (dMass *m, dReal density, dReal radius)
{
dMassSetSphereTotal (m, (dReal) ((REAL(4.0)/REAL(3.0)) * M_PI *
radius*radius*radius * density), radius);
}
void dMassSetSphereTotal (dMass *m, dReal total_mass, dReal radius)
{
dAASSERT (m);
dMassSetZero (m);
m>mass = total_mass;
dReal II = REAL(0.4) * total_mass * radius*radius;
m>_I(0,0) = II;
m>_I(1,1) = II;
m>_I(2,2) = II;
}
LR