[ODE] Need help with hinge and non-uniformly distributed mass
Keith Johnston
kjohnston at pinolisoftware.com
Mon Jun 2 18:04:02 2003
This is a multi-part message in MIME format.
------=_NextPart_000_0001_01C32941.C8EB6930
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
I'm hoping someone can spot what I'm doing wrong here. I want to have a
sphere with non-uniform mass rotating around an axis going throught the
center of the sphere. I've modified test_boxstack.cpp to try this out,
and no luck.
The sphere in the code sample below should start off rotating
immediately - due to its displaced mass, but instead it doesn't move at
all!
If I remove the hinge, the sphere rolls around on the floor as if its
mass was distributed unevenly, which I would expect. So why does it not
rotate unevenly with the hinge in place?
Thanks,
Keith
else if (cmd == 's') {
sides[0] *= 0.5;
dMassSetSphere (&m,DENSITY,sides[0]);
obj[i].geom[0] = dCreateSphere (space,sides[0]);
dMass m2;
dMassSetSphere (&m2,DENSITY*3,sides[0]);
dMassTranslate (&m2,0,5,0);
dMassAdd (&m,&m2);
printf ("Center of mass at: %f,%f,%f\n",m.c[0],m.c[1],m.c[2]);
dGeomSetPosition (obj[i].geom[0], -m.c[0], -m.c[1], -m.c[2]);
dMassTranslate (&m,-m.c[0],-m.c[1],-m.c[2]);
dJointID mHingeJoint = dJointCreateHinge(world,0);
dJointAttach(mHingeJoint,0,obj[i].body);
const dReal* pos = dBodyGetPosition(obj[i].body);
dJointSetHingeAnchor(mHingeJoint,pos[0],pos[1],pos[2]);
printf ("Creating hinge at: %f,%f,%f\n",pos[0],pos[1],pos[2]);
dJointSetHingeAxis(mHingeJoint,1,0,0);
}
------=_NextPart_000_0001_01C32941.C8EB6930
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<TITLE>Message</TITLE>
<META content=3D"MSHTML 5.00.3502.5390" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2> </FONT>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D211241820-01062003>I'm =
hoping someone=20
can spot what I'm doing wrong here. I want to have a sphere with=20
non-uniform mass rotating around an axis going throught the center of =
the=20
sphere. I've modified test_boxstack.cpp to try this out, and no=20
luck. </SPAN></FONT></DIV>
<DIV><SPAN class=3D211241820-01062003></SPAN><FONT face=3DArial=20
size=3D2> </FONT></DIV>
<DIV><FONT size=3D2><FONT face=3DArial><SPAN =
class=3D211241820-01062003>Th<SPAN=20
class=3D993475700-03062003>e</SPAN> sphere <SPAN=20
class=3D993475700-03062003>in </SPAN><SPAN =
class=3D993475700-03062003>the code=20
sample below </SPAN>should <SPAN class=3D993475700-03062003>start =
off=20
rotating immediately - due to its displaced mass</SPAN>, but instead=20
it <SPAN class=3D993475700-03062003>doesn't move at=20
all!</SPAN></SPAN></FONT></FONT></DIV>
<DIV><SPAN class=3D211241820-01062003></SPAN> </DIV>
<DIV><FONT size=3D2><FONT face=3DArial><SPAN =
class=3D211241820-01062003>If I remove=20
the hinge, the sphere rolls around on the floor as if its mass was =
distributed=20
unevenly, which I would expect. So why does it not rotate unevenly =
with=20
the hinge in place?</SPAN></FONT></FONT></DIV>
<DIV><SPAN class=3D211241820-01062003></SPAN><FONT face=3DArial=20
size=3D2> </FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D211241820-01062003>Thanks,</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D211241820-01062003>Keith</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> </FONT></DIV><FONT =
face=3DArial>
<DIV><FONT size=3D2>else if (cmd =3D=3D 's') =
{<BR> sides[0] *=3D=20
0.5;<BR> dMassSetSphere=20
(&m,DENSITY,sides[0]);<BR> obj[i].geom[0] =3D =
dCreateSphere=20
(space,sides[0]);</FONT></FONT></DIV></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> dMass=20
m2;<BR> dMassSetSphere=20
(&m2,DENSITY*3,sides[0]);<BR> dMassTranslate=20
(&m2,0,5,0);<BR> dMassAdd =
(&m,&m2);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> printf ("Center of =
mass at:=20
%f,%f,%f\n",m.c[0],m.c[1],m.c[2]);<BR> <BR> &=
nbsp;dGeomSetPosition=20
(obj[i].geom[0], -m.c[0], -m.c[1], =
-m.c[2]);<BR> dMassTranslate=20
(&m,-m.c[0],-m.c[1],-m.c[2]);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> dJointID mHingeJoint =
=3D=20
dJointCreateHinge(world,0); <BR> dJointAttach=
(mHingeJoint,0,obj[i].body);<BR> const=20
dReal* pos =3D=20
dBodyGetPosition(obj[i].body);<BR> dJointSetHingeAnchor(=
mHingeJoint,pos[0],pos[1],pos[2]);<BR> printf=20
("Creating hinge at:=20
%f,%f,%f\n",pos[0],pos[1],pos[2]);<BR> dJointSetHingeAxi=
s(mHingeJoint,1,0,0);<BR> <BR> &n=
bsp;}</FONT></DIV></BODY></HTML>
------=_NextPart_000_0001_01C32941.C8EB6930--