From: Joschka B. <jos...@am...> - 2008-02-17 04:38:20
|
Hi again, On Feb 16, 2008, at 6:29 PM, Joschka Boedecker wrote: > On Feb 16, 2008, at 8:28 AM, Sander van Dijk wrote: > >> [...] The solution I think would be to translate the body to >> the center of mass (as also done in the official ODE examples ), > > Should be the other way round, but I guess that's what you meant ;-) > Translate the masses so that the center of the composite mass > coincides with the body's origin. > > One thing I realize is that this seems to be quite a constraint when > it comes to realism of the simulation. If you think of an example like > a table made up of five bodies: a flat surface on the top, and four > legs, e.g. > > pos_top = (0,0,0)', pos_leg_1 = (-1,-1,-0.5)', pos_leg_2 = > (1,-1,-0.5)', pos_leg_3 = (1,1,-0.5)', pos_leg_4 = (-1,1,-0.5)' > > and > > mass_top = 0.3, mass_leg_[1,2,3,4] = 0.1 > > and you assume point masses (which is the default in ODE, IIRC), you > calculate the COM as: > > COM = (pos_top * mass_top + sum_{i=1}^{4} pos_leg_i * mass_leg_i) / > (mass_top + sum_{i=1}^{4} mass_leg_i) %%% Latex like notation... > > Which is the sum of all the positions weighted by their masses divided > by the total mass. For this example, you'll get a COM at about > (0,0,-0.286), so we need to subtract -0.286 from the z-coordinate of > each of the leg masses in order to fulfill the ODE constraint. We also need to translate the top mass, of course, otherwise the COM won't be at (0,0,0). > However, you probably don't want to change the position of the > geometries, since then you get a different shape from what you > intended. So the collision shape will be correct, but leg masses will > be slightly higher than intended. Actually, I'm thinking now the solution would be to translate all the masses and the geometries (like in the ODE example in the Wiki) in order to satisfy the ODE constraint of having the COM of the body at (0,0,0), then assign the composite mass to the body, but then place the body at the position we intended + the original COM offset ( (0,0,-0.286) in the above example). This way, the masses and the geometries are in the right position, only the body's origin is a little displaced. Like Sander pointed out, in this case, we need to adjust the joint anchors. > >> but I suspect this messes up joint placement.. > > It shouldn't be a problem, since you only move the masses, not the > body. You're right, see above. Cheers, Joschka |