How to change from impulse forces to continuous forces ???

winspear
Posts: 77
Joined: Thu Nov 26, 2009 6:32 pm

How to change from impulse forces to continuous forces ???

Post by winspear »

Hi,
I am new to bullet physics. I have some previous experience with Nvidia physx where I have created many demos.
I created a bullet demo by initializing a "btSequentialImpulseConstraintSolver" and created a couple of primitives like sphere, cube, cylinder and cone. The problem I am having is that when I try colliding one object with another, there is an instantaneous impulse force and both objects just fly with very high velocity. I am not sure how to make bullet use a more smooth continuous collision detection technique.
I have done the same demo using physx and had no problem like this.
Any help would be greatly appreciated.

Thanks
Venkat
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: How to change from impulse forces to continuous forces ???

Post by Erwin Coumans »

What kind of demo are you trying to make? Is it a stress-test to test continuous collision detection?

Can you share the Bullet and PhysX demo source code (attached as zipfile)?
Thanks,
Erwin
winspear
Posts: 77
Joined: Thu Nov 26, 2009 6:32 pm

Re: How to change from impulse forces to continuous forces ???

Post by winspear »

Thanks for the reply Erwin. I am trying to use a VR tracker to control a physics object in the scene and do some basic collisions.
Since the VR tracker toolkit is proprietary, myself posting the code will not help.
But here is a good description of what I trying to achieve..

I am trying to control the position and orientation of a bullet physics actor in 3d space and the collide them with other dynamic and static actors in the scene.
I have this same demo working with Nvidia physx.

This is how I go about achieving it:

1. Create a spring-damper model and attach one of the bullet actors to the VR tracker tool. Using the spring-damper model, I create a virtual force which I apply to the object that the tool is holding to move it in 3d space. Then as the bullet actor moves in 3d space it will automatically collide with other actors in the scene.

Here is an excerpt of how I compute the forces:

1. Create a virtual spring mass model and critically damp it.
2. Get the bullet transform for the object.
3. Get the linear velocity for the object from bullet.
4. Get the position of the VR tool.
5. Calculate the spring-damper force

forceOnObject = K_spring*(VRToolPositionWorld-bulletposition)- B_spring*velocity;

6. This forceOnObject is then scaled and applied to the bullet actor by using

selectedActor->applyCentralForce(btVector3(forceOnObject[0], forceOnObject[1], forceOnObject[2]));

This is how I manipulate a bullet actor (for e.g a cube) on the screen. I control both the position and orientation of the object. Using bullet I am able to control the actor very easily and am able to manipulate it in 3d space without problems.

The main problem is when I try to collide the grabbed obejct (a cube) with other dynamic objects in the scene (for e.g a sphere), the sphere just gets an impulse kick from the cube and just jumps and bounces away. I tried making the sphere static, then the cube gets an impulse like kick on contact.
Now I saw another function called applyForce() which takes a vector in addition to the forces. How do I use this?
Currently I use applyCentralForce() and applyTorque() functions to set forces on the grabbed actor as mentioned above.

In Nvidia physx, i just used the functions addForce() and addtorque() to create the same effect.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: How to change from impulse forces to continuous forces ???

Post by Erwin Coumans »

If you control position and orientation directly, what is the purpose of applying forces?

You could use a kinematic object (with mass = 0) for the object that is under control. Just set its position/orientation through the motion state, no need to apply forces. See Bullet/Demos/CcdPhysicsDemo for an example of a kinematic object (enable #define USE_KINEMATIC_GROUND)

If you are causing deep penetrations, additional momentum might build up. You can enable 'split impulse' option to avoid this:

Code: Select all

btContactSolverInfo& info = dynamicsWorld->getSolverInfo();
info.m_splitImpulse = 1; //enable split impulse feature
Alternatively, you could use a btGeneric6DofConstraint with all degrees of freedom locked, and then move the reference frame.
See attached modified demo that uses it for mouse picking (make sure USE_6DOF is defined), copy the file into Bullet/Demos/OpenGL directory, and recompile all demos.

Thanks,
Erwin
You do not have the required permissions to view the files attached to this post.
winspear
Posts: 77
Joined: Thu Nov 26, 2009 6:32 pm

Re: How to change from impulse forces to continuous forces ???

Post by winspear »

Thanks for the quick reply. I will definitely give it a try.

:D
User avatar
Garibalde
Posts: 44
Joined: Fri Dec 18, 2009 6:06 pm
Location: Montreal

Re: How to change from impulse forces to continuous forces ???

Post by Garibalde »

Hi Erwin,

I dont mean to hijack the thread. but Can you please briefly explain what exactly the m_splitimpulse feature does?

Thanks
Garibalde
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: How to change from impulse forces to continuous forces ???

Post by Erwin Coumans »

Garibalde wrote:Hi Erwin,

I dont mean to hijack the thread. but Can you please briefly explain what exactly the m_splitimpulse feature does?

Thanks
Garibalde
See http://bulletphysics.org/mediawiki-1.5. ... SolverInfo

Thanks,
Erwin