[ODE] RE: dBodyAddRelTorque() problems (was: OpenGL matrix conversion)

Ruud van Gaal ruud at marketgraph.nl
Sat Nov 24 06:01:01 MST 2001


Hi Norman and all,

> > 0  0 1  =>  0 -0.27  0.96    (Ruud's results)
> > 0  1 0      0  0.96  0.27
> > -1 0 0      -1 0     0
...
> Starting with the following orientation:
>
> -0.000000 0.000000 1.000000 (Norman's results)
> 0.000000 1.000000 0.000000
> -1.000000 0.000000 -0.000000
...
> I obtain after one frame the following orientation
>
> 0.000000 0.071051 0.997473
> -0.000000 0.997473 -0.071051
> -1.000000 -0.000000 0.000000

I tried to get the same result with a minimal ODE program. And to my own 
astonishment, I don't get the same results. Instead, I get (as output from the 
following program, and I did take out applying Rt instead of R in 
dBodyAddRelTorque(), which I had changed in ODE):
---
Initial matrix:
  0.00   0.00   1.00
  0.00   1.00   0.00
 -1.00   0.00   0.00
post-rel Tx=+:
  0.00  -0.02   1.00
  0.00   1.00   0.02
 -1.00   0.00   0.00
---
With this minimal source (should compile):
---
// bug_reltorque.cpp

#include <stdio.h>
#include "ode/ode.h"

static dWorldID world;
static dSpaceID space;

void mPrint(const dReal R[12],char *s)
{
  printf("%s:\n",s);
  printf("%6.2f %6.2f %6.2f\n",R[0],R[1],R[2]);
  printf("%6.2f %6.2f %6.2f\n",R[4],R[5],R[6]);
  printf("%6.2f %6.2f %6.2f\n",R[8],R[9],R[10]);
}

void BugTest()
{
  dBodyID body;
  dMatrix3 R;

  body=dBodyCreate(world);
  // Initial matrix
  R[0]=0; R[1]=0; R[2]=1; R[3]=0;
  R[4]=0; R[5]=1; R[6]=0; R[7]=0;
  R[8]=-1; R[9]=0; R[10]=0; R[11]=0;
  dBodySetRotation(body,R);
  mPrint(R,"Initial matrix");

  dBodyAddRelTorque(body,200,0,0);
  dWorldStep(world,0.01);
  mPrint(dBodyGetRotation(body),"post-rel Tx=+");
}

int main(int argc,char **argv)
{
  // create world
  world = dWorldCreate();
  space = dSpaceCreate();
  BugTest();
  dSpaceDestroy (space);
  dWorldDestroy (world);

  return 0;
}
---

Now, I've read about matrices some more, and indeed, R maps from body->world. I 
was confused I think with the fact that R represents the body's axis system in 
world coordinates (that's right, isn't it?).
But I can't explain why I *still* get wrong results here. Can you send me the 
source you used?
And if anyone else can attempt to compile and run this little program to see if 
it works?

Note I apply more torque, but I use a small timestep (0.01s) and I tried 
applying .1, 1 and 100 as the Tx torque; they didn't change the matrix enough 
so I selected 200.

Hope I get this sorted out; I was hoping to find out what my code was doing 
wrong, but at step 1 I failed to get any closer! ;-)

Thanks for any help, I'm quite stuck with this (although it all works, 
collisions/contact points and all, but just using the transposed 
dBodyAddRelTorque() function, lol). It must be in that little piece of source, 
somewhere...

Ruud




More information about the ODE mailing list