[ODE] problems with amotor

Jason Mallios jmallios at cs.brown.edu
Mon May 9 14:58:58 MST 2005


I think you need to know the rotational offset of the two bodyParts
initially, i.e. when their AMotorAngles at each axes are zero.  Pick a
default pose and store the relative rotational offset:

R0 = Rb1.transpose * Rb2

where Rb1 is the rotation of one body and Rb2 is the rotation of the
other.

I think if you compute the relative rotational offset of the two bodies at
any time step, you should be able to get the column vectors of each like
you're doing below to represent the axes.

Then for each pair of axes you should be able to use atan2 (although I'm
not sure how) to find their relative angles based on their absolute angles
with some axis.  I'll do a search on this later and try to figure it out,
but if anyone else knows, that'd be great.


On Mon, 9 May 2005 jnilson_99 at yahoo.com wrote:

> "It depends what you want to do"
>
> give a ball/socket with an amotor connecting them, i
> want to find the angle between each respective axis.
> this angle will then be sent to dJointSetAMotorAngle.
> the code below doesn't work because the
> angle(x,y,zAngleDiff )doesn't reflect the direction.
>
> const dReal* R1 =
> dBodyGetRotation(bodyParts[BODY_TYPE_TORSO]->bodyID);
> const dReal* R2 =
> dBodyGetRotation(bodyParts[BODY_TYPE_LEFT_UPPER_ARM]->bodyID);
> dVector3 xa1 = {R1[0],R1[4],R1[8]};
> dVector3 xa2 = {R2[0],R2[4],R2[8]};
> dVector3 ya1 = {R1[1],R1[5],R1[9]};
> dVector3 ya2 = {R2[1],R2[5],R2[9]};
> dVector3 za1 = {R1[2],R1[6],R1[10]};
> dVector3 za2 = {R2[2],R2[6],R2[10]};
>
> dNormalize3 (xa1);
> dNormalize3 (xa2);
> dNormalize3 (ya1);
> dNormalize3 (ya2);
> dNormalize3 (za1);
> dNormalize3 (za2);
>
> dReal xDotAngle = dDOT(xa1,xa2);
> dReal yDotAngle = dDOT(ya1,ya2);
> dReal zDotAngle = dDOT(za1,za2);
>
> dReal xAngleDiff = acos(xDotAngle);
> dReal yAngleDiff = acos(yDotAngle);
> dReal zAngleDiff = acos(zDotAngle);
>
> dJointSetAMotorAngle(joints[JOINT_TYPE_LEFT_SHOULDER]->constraintID,0,xAngleDiff);
> dJointSetAMotorAngle(joints[JOINT_TYPE_LEFT_SHOULDER]->constraintID,1,yAngleDiff);
> dJointSetAMotorAngle(joints[JOINT_TYPE_LEFT_SHOULDER]->constraintID,2,zAngleDiff);
> --- Jason Mallios <jmallios at cs.brown.edu> wrote:
> > The problem is the dot produces a positive for an
> > acute angle and a
> > negative for an obtuse, so you can't necessarily
> > tell which direction the
> > bodies are rotationally offset.
> >
> > It depends what you want to do, but a double cross
> > product can give you
> > axes with directional meaning.
> >
> > On Mon, 9 May 2005 jnilson_99 at yahoo.com wrote:
> >
> > >
> > > "or by
> > > crossing two such axes; one from each body (for
> > two
> > > bodies)."
> > >
> > > do you have any sample code you could show to
> > > demonstrate how you're doing this?
> > >
> > > also, i thought only the dot product provided the
> > > angle between two vectors and the cross product
> > > creates a vector perpendicular to the two vectors
> > > (each axis of the two bodies being compared)?
> > >
> > > thanks,
> > >
> > > john
> > > --- Jon Watte <hplus-ode at mindcontrol.org> wrote:
> > > >
> > > > > Specifically, the manual seems to suggest you
> > have
> > > > to calculate the axes
> > > > > angles yourself every time step.  Is that
> > true?
> > > >
> > > > Yes, that is true. It's not all that hard,
> > really --
> > > > you can usually pull
> > > > the axes out of the rotation matrix directly
> > (for a
> > > > single body) or by
> > > > crossing two such axes; one from each body (for
> > two
> > > > bodies).
> > > >
> > > > I've used Amotors in user mode to stabilize a
> > > > hovercraft, and it worked
> > > > OK. "OK" here means "according to
> > documentation."
> > > >
> > > > Cheers,
> > > >
> > > > 			/ h+
> > > >
> > > >
> > > > _______________________________________________
> > > > ODE mailing list
> > > > ODE at q12.org
> > > > http://q12.org/mailman/listinfo/ode
> > > >
> > >
> > _______________________________________________
> > ODE mailing list
> > ODE at q12.org
> > http://q12.org/mailman/listinfo/ode
> >
>


More information about the ODE mailing list