Page 1 of 2

Force value issue

Posted: Thu Mar 11, 2010 2:29 am
by CocoaGeek
Hello,

I'm running into a bit of a weird issue tonight. I'm trying to lift a body from a surface (static body) by applying a force to it.

Since I'm using real-world value (and SI units), I'm expecting the value for the force (in Newton) to need to be greater than Mass * Gravity in order to cancel the action of gravity and lift the body. However, what I'm seeing is that I need to multiply the force by 4, for it to have the expected effect.

The same issue manifest it-self if I set the body high above the surface. The body will only stay stationary if the lift force is multiplied by 4.

Any idea of what could be wrong? I'm probably doing something stupid, but I can't seems to see what exactly could cause this ... :oops:

Thanks in advance.

Re: Force value issue

Posted: Fri Mar 12, 2010 9:31 am
by CocoaGeek
Hmmm ... Anyone else using real world values?

Re: Force value issue

Posted: Fri Mar 12, 2010 10:43 pm
by mobilebros
I have not had this issue, I'm almost positive that to cancel gravity I've just done an equal and opposing force of gravity *mass..... could it have something to with where you applied the force on the body, I've always done it on the center of gravity.... or perhaps your calculated moment is wrong.... I'm just stabbing in the dark i'm in no way positive if that would even affect anything having to do with this issue.

Re: Force value issue

Posted: Sat Mar 13, 2010 12:48 am
by CocoaGeek
Thanks for the reply :) I have tried to apply the force directly on the center of gravity (it was applied with a Y offset) and also changed the inertia value of the one of the disc of the same weight, but no change whatsoever :cry:

Could it be that I have expressed the gravity incorrectly? I specified it in m/s (e.g (0.0f,-9.8f) )

Re: Force value issue

Posted: Mon Mar 15, 2010 4:10 pm
by slembcke
I forgot my Macbook's power supply at the place we do contracting at so I can't really try anything out right now, but it should work just fine...

The integration just calculates the acceleration like so:

Code: Select all

cpvadd(gravity, cpvmult(body->f, body->m_inv)
So if g=-f/m, then f = -g*m. Not exactly sure why that wouldn't be working.

Re: Force value issue

Posted: Tue Mar 16, 2010 10:20 am
by CocoaGeek
Thanks Scott, I can wait a few days until you get your power supply back ;-)

Re: Force value issue

Posted: Tue Mar 16, 2010 2:16 pm
by slembcke
The following works for me:

Code: Select all

	ballBody->f = cpvmult(space->gravity, -ballBody->m);
Are you sure you aren't changing the gravity or mass after setting the force?

Re: Force value issue

Posted: Tue Mar 16, 2010 5:51 pm
by CocoaGeek
Yeah ... The only think I do, and don't think it's an issue, is to reset all the forces applied to all bodies after each time step. Could that be the issue? :oops:

Re: Force value issue

Posted: Tue Mar 16, 2010 6:09 pm
by slembcke
No, that should be fine.

You should check some of the values in cpBodyUpdateVelocity() in the debugger. The following should evaluate to zero unless something is very wrong:
cpvadd(gravity, cpvmult(body->f, body->m_inv)

Re: Force value issue

Posted: Tue Mar 16, 2010 6:27 pm
by CocoaGeek
Will do, thanks for the suggestion(s).