Strange Behavior of dJointGetFeedback

82 views
Skip to first unread message

Peacemoon

unread,
Sep 9, 2008, 8:25:06 AM9/9/08
to ode-users
Hello,
i have a strange behavior of dJointGetFeedback.
I have in my world 2 objects, a Sphere (gAvatar) and a Box (gWall1).
gAvatar is dynamics and gWall1 is static.
When i set the Box bigger then the Sphere and use these codes to read
the Force between them when they collide, i have the right answer.
That means, i have o1 == gAvatar and o2 == gWall1 and the force that
applies on gAvatar <> 0 and that on gWall1 = 0
if (o1 == gAvatar || o2 == gAvatar)
{
if (o1 == gWall1 || o2 == gWall1){
joint2 = dJointCreateContact (world,contactgroup,contact+i);
dJointAttach (joint2,dGeomGetBody(o1),dGeomGetBody(o2));
dJointSetFeedback(joint2,p_feedbackJoint2);
p_feedbackJoint2 = dJointGetFeedback(joint2);
if( o1 == gAvatar){
printf("1 %e %e %e ",-feedbackJoint2.f1[0],-feedbackJoint2.f1[1],-
feedbackJoint2.f1[2]);
printf("%e %e %e\n",-feedbackJoint2.t1[0],-feedbackJoint2.t1[1],-
feedbackJoint2.t1[2]);
}
else if( o2 == gAvatar){
printf("2 %e %e %e ",-feedbackJoint2.f2[0],-feedbackJoint2.f2[1],-
feedbackJoint2.f2[2]);
printf("%e %e %e\n",-feedbackJoint2.t2[0],-feedbackJoint2.t2[1],-
feedbackJoint2.t2[2]);
}
}
}

but when i set the Box smaller and use the same code, i have another
result, o1 == gWall1 and o2 == gAvatar, and the force, that applies on
gAvatar is zero, and that on gWall1 <> 0.
This strange error makes my code false. So can any help me find out
where i did wrong?

Thanks
An

Daniel K. O.

unread,
Sep 9, 2008, 4:04:31 PM9/9/08
to ode-...@googlegroups.com
Peacemoon escreveu:

> joint2 = dJointCreateContact (world,contactgroup,contact+i);
> dJointAttach (joint2,dGeomGetBody(o1),dGeomGetBody(o2));
> dJointSetFeedback(joint2,p_feedbackJoint2);

Where was p_feedbackJoint2 defined? Where does it point to?


> p_feedbackJoint2 = dJointGetFeedback(joint2);

This call is useless.


> if( o1 == gAvatar){
> printf("1 %e %e %e ",-feedbackJoint2.f1[0],-feedbackJoint2.f1[1],-
> feedbackJoint2.f1[2]);

Now you are using feedbackJoint2, not p_feedbackJoint2.

Worse yet, no step was performed, so the joints didn't have the chance
to work yet. So you are just reading uninitialized value (or, likely,
the value computed from the last step).

--
Daniel K. O.
"The only way to succeed is to build success yourself"

Peacemoon

unread,
Sep 11, 2008, 3:54:41 AM9/11/08
to ode-users
Hello,
i just copied a small part of my code because my code is very long,
p_feedbackJoint2 is defined like this:

dJointID joint2;
static dJointFeedback feedbackJoint2;
static dJointFeedback *p_feedbackJoint2= &feedbackJoint2;

And here is the main part of my simmLoop function

dBodySetLinearVel(bAvatar,Vel_human_man[0],Vel_human_man[1],Vel_human_man[2]);
dBodySetAngularVel(bAvatar,0,0,0);

dSpaceCollide (space,0,&nearCallback);
dWorldStep (world, SIMSTEP);
dJointGroupEmpty(contactgroup);

And the nearcallback function is in the first post.
Reply all
Reply to author
Forward
0 new messages