Force problem

Post Reply
tjloughl
Posts: 23
Joined: Wed Oct 03, 2007 4:03 am

Force problem

Post by tjloughl »

Hello
I am trying to take a body of mine and counter the force of gravity just to make it sit there. The point is not to shut off gravity but to simulate buoyancy forces.
What I am doing is setting the gravity to -10acceleration, with my body mass set to 7.5 (gives a -75 force for the body). Now, I take that force and negate it (0.0,0.0,75), and apply it to the body applyCentralForce((0.0,0.0,75)). I am calling this each frame. The problem is that the applied force doesn't cancel the gravity force, it actually overcomes it, so my body starts to fly quickly upwards.
An even weirder occurence is that if, instead of the 75N, I apply a 7.5N force upward, it seems to cancel the gravity. Why would this 7.5 force, which is my mass in N form, cancel gravity?
Thanks for your help
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Force problem

Post by Erwin Coumans »

tjloughl wrote:Hello
I am trying to take a body of mine and counter the force of gravity just to make it sit there. The point is not to shut off gravity but to simulate buoyancy forces.
What I am doing is setting the gravity to -10acceleration, with my body mass set to 7.5 (gives a -75 force for the body). Now, I take that force and negate it (0.0,0.0,75), and apply it to the body applyCentralForce((0.0,0.0,75)). I am calling this each frame. The problem is that the applied force doesn't cancel the gravity force, it actually overcomes it, so my body starts to fly quickly upwards.
An even weirder occurence is that if, instead of the 75N, I apply a 7.5N force upward, it seems to cancel the gravity. Why would this 7.5 force, which is my mass in N form, cancel gravity?
Thanks for your help
To cancel the gravity force (0,0,-10), you just can apply an equal but opposite counter force (0,0,+10).
Gravity is a force, not acceleration. F = m * a, so acceleration = Fg/mass
Given mass in kilogram, time in seconds, force is in kg*m/s^2, which is 1N

Alternatively, you can cancel out the gravity per-body, by calling rigidbody->setGravity(0,0,0), _after_ you added the body to the dynamics world.

Hope this helps,
Erwin
tjloughl
Posts: 23
Joined: Wed Oct 03, 2007 4:03 am

Re: Force problem

Post by tjloughl »

hello
Thanks for the reply.
I was doing what you say, by applying a force equal and opposite to the gravity. The problem I found is framerate. The physics for each object, applying the counter force, was being called more than the physics updates were being called, so the counterforce was being applied more than the gravity force.
I had to decouple the physics and the frame rate, along with the update rate for the objects.
tjloughl
Posts: 23
Joined: Wed Oct 03, 2007 4:03 am

Re: Force problem

Post by tjloughl »

Now I am having another problem. Normal gravity is applied to my body, and I use a counter-force, a buoyancy force, to counter gravity. Gravity force is -75N, and my buoyancy force is 60N, leaving a net of -15N. -15N seems that it would be enough to drop sort of quickly (-2 acceleration for a 7.5kg body?), but my body falls very very slowly. But if I apply a smaller force, say 49N (diff of -26N), the body falls very very quickly. There seems to be a threshold of force, meaning, the body isn't getting gravity applied until the difference of gravity and buoyancy is beyond a certain threshold. It falls at the same very slow rate until the difference is large, then it just jumps to falling quickly, theres no in-between.

BUT, the interesting thing is that if I apply a forward force to the body, all of a sudden the body starts to fall again, as if it was deactivated and now it is activated. I checked the activation and the body stays active, it never deactivates.
Any ideas?
Thank you very much
tjloughl
Posts: 23
Joined: Wed Oct 03, 2007 4:03 am

Re: Force problem

Post by tjloughl »

i am noticing that with accelerations that are low (like 2m/s^2) the object doesn't move at all. I am giving a 10kg body a (0.0,0.0,-2.0) gravity acceleration and it doesn't move. This is making it hard to apply buoyancy forces because they are generally low. Thank you
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Force problem

Post by Erwin Coumans »

Can you try any of the following, and see if that helps?

- disable/comment out EXPERIMENTAL_JITTER_REMOVAL in Bullet/src/BulletDynamics/Dynamics/btRigidBody.cpp
- disable/comment out FORCE_VELOCITY_DAMPING in btRigidBody.cpp
set the angular damping to zero:
rigidbody->setDamping(0.f,0.f);

Hope this helps,
Erwin
tjloughl
Posts: 23
Joined: Wed Oct 03, 2007 4:03 am

Re: Force problem

Post by tjloughl »

hey thanks. I removed just the jitter and problem solved! It works awesome now
Post Reply