# [ODE] Has anybody had any luck with dJointSetAMotorAngle?

Andrew Schroeder schroe2a at gmail.com
Fri Jan 28 08:34:21 MST 2005

```In browsing the mailings I see that you seem to have figured out
exaclty how to do what I've been trying (and failing) to do.  I want
to have an aMotor that keeps a body upright like you talk about below,
but I have some questions you can probably answer.

When you say:
> each frame I calculate the angular difference between the
cylinder's local x, y
> and z axes and the global x, y and z axes
How do you do that? I tried a few things but I have problems with
gimbal lock and other issues.

Also, you say:
> The differences I find between each (axis?) I set as new AMotor angles for the > corresponding AMotor axes.
Does this mean you call setAMotorAngle again now with the newly
rotated angle? If so, how does that serve to keep the cylinder upright
as now ODE since all that call does is tell ode what the angle is?  I
have been trying to use atan of the dot product to find the angle, and
then setting the desired velocity of the motor to stand it upright but
I'm having all kinds of problems with that.  Would you mind sharing
more details on your appoach to this?

Thanks,
Andy

On Mon, 24 Jan 2005 16:16:25 +0000, Patrick McColgan
<patrick at torcinteractive.com> wrote:
> I finally (hopefully) have AMotors working the way I want so here's my
> take on it:
>
> setAMotorAngle is exclusively for User mode meaning that you are
> completely responsible for updating the motor, as far as I can see you
> aren't telling the amotor what the angle should be; you're informing it
> of what it is.
>
> I use an AMotor to stand a cylinder upright, normally the cylinder lies
> along the z axis so what I do is first rotate the cylinder 90 degrees
> about its local x axis and position it's bottom end on a surface.  Then
> I set up the AMotor, I use 3 axis set as a unit vector along the global
> x, y and z axis.  Then I call setAMotorAngle to initialise all the axis
> to zero degrees, so in spite of ODE knowing that I have rotated the body
> I have told the amotor that this upright cylinder is unrotated initially
> with respect to the amotor.  Then each frame I calculate the angular
> difference between the cylinder's local x, y and z axes and the global
> x, y and z axes (as I use the internal rotational matrix of the body I
> have to account for my initial rotation).  The differences I find
> between each I set as new AMotor angles for the corresponding AMotor
> axes.  And that's all I have to do, the motor maintains the cylinder
> vertically.
>
> I hope that makes sense, as I say I finally have AMotors working the way
> I want them.  But it wasn't easy.
>
> Gerritt Brownlee wrote:
>
> >
> > I am trying to set the initial conditions of my motor.  It doesn't
> > move the joint to any angle.
> >
> > If I can't get the setAMotorAngle to work I guess I will have to use
> > quaternions to set the inital conditions.
> >
> > Please respond if you got this function to work.
> >
> > Thanks
> >
> > Gerald Boone
> >
> >------------------------------------------------------------------------
> >
> >_______________________________________________
> >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
>
```