# [ODE] Power, torques and feedback

Jean-baptiste MOURET jean-baptiste.mouret at lip6.fr
Mon Sep 11 09:32:18 MST 2006

```			Hi,

This seems to be a recurring question but I cannot find any definitive
answer; as a lot of ODE users, I have to compute the energy used by my
simulated robots to move and I need some help to set up this
computation.

I am trying to use the provided feedback functions as follow:
- I use angular motors by setting the dParamVel
- Since power is Torque dot AngularVelocity, I get the torque and the
angular velocities for the two connected bodies.

This gives this code :
dJointGetFeedback (_ball);
maths::Vectorf t1(_feedback.f1[0], _feedback.f1[1], _feedback.f1[2]);
const dReal* r1 = dBodyGetAngularVel(_o1.get_body());
maths::Vectorf v1(r1[0], r1[1], r1[2]);
float e1 = t1 * v1; // * is the dot product

maths::Vectorf t2(_feedback.f2[0], _feedback.f2[1], _feedback.f2[2]);
const dReal* r2 = dBodyGetAngularVel(_o2.get_body());
maths::Vectorf v2(r2[0], r2[1], r2[2]);
float e2 = t2 * v2; // * is the dot product

_power = e1 + e2;

=> I am really not sure to do this computation in the right way, mainly
because I'm not sure to understand what is computed in the torque vector
returned by ODE. Basically, I have theses questions:
- do I have to add the two contributions ?
- do I use the good angular velocity ?
- I get negative values for _power, does it mean that the system get
some new energy?

And, of course, is it the "good way" to compute the energy ?

I understand that these questions are more physics-related than
ODE-related but I'm sure the answers will interest some other ODE users
as well.

Thanks,
--
Jean-Baptiste Mouret / Mandor
http://animatlab.lip6.fr/~mouret
tel : (+33) 6 28 35 10 49

```