[ODE] Relative transformation of composite objects

Shamyl Zakariya zakariya at earthlink.net
Fri Jun 6 12:15:02 2003


Hi,
I'm working on a situation where composite objects are necessary to 
make complex structures that are of one body. As per recommendations 
I've read on this list, I've used test_boxstack to figure out in 
general how to implement them, and as such it works, just fine.

Now, the question I have has to do with coordinate-system-relative 
positioning. I've discovered that if I take an object and attach it to 
a parent (for convenience let's call the primary body parent, and the 
attached geom child) via a dGeomTransformSetGeom, it inherits the 
parent's position and rotation (which makes sense). The trouble is, 
this makes it very hard to pick a position and rotation for the object, 
since frankly, it's not very easy to guess at 
coordinate-system-relative positions and rotations in my head, since 
I'm not a calculator.

Ideally, there's be some way of saying "convert global 
position/orientation to the coordinate system of body X" -- in reading 
test_boxstack I looked at the drawing code and found a transformation 
that looks at least relevant, as it seems to be taking the relative 
coordinates of the child and applying them to the coordinate system of 
the parent to get world coordinates. This seems to be the inverse of 
what I need.

   else if (type == dGeomTransformClass) {
     dGeomID g2 = dGeomTransformGetGeom (g);
     const dReal *pos2 = dGeomGetPosition (g2);
     const dReal *R2 = dGeomGetRotation (g2);
     dVector3 actual_pos;
     dMatrix3 actual_R;
     dMULTIPLY0_331 (actual_pos,R,pos2);
     actual_pos[0] += pos[0];
     actual_pos[1] += pos[1];
     actual_pos[2] += pos[2];
     dMULTIPLY0_333 (actual_R,R,R2);
     drawGeom (g2,actual_pos,actual_R,0);
   }

Nonetheless, this looks more or less like magic to me, since I'm not 
certain what dMULTIPLY0_331 *does*.

Any help, or pointers, would be greatly appreciated.

BTW, I answered my own question, posted a couple weeks ago, about how 
to get feedback on a joint. Since I couldn't make it work, I instead 
made a system wherein a "pinion" body sits between the servo motor 
joint and the parent body. Between the pinion and the parent lies a 
joint with a springy CFM, and I just take the angle on that joint to 
measure torque. It works beautifully, and has the advantage of more 
closely modeling how my real world torque sensor works!

Shamyl Zakariya
   "this is, after all, one of those movies where people spend a great
   deal of time looking at things and pointing."
	From a review of _Fantastic Voyage_