Sign in to follow this  

Contact resolution alghoritm (+ (buggy) demo)

This topic is 4839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, i need some help here on my 2D dynamics simulator. I've implemented collision detection (i only have convex polys and circle) which returns all the collision points. I also implemented impulse driven collision resolve as in Chris Hecker's paper, springs and stiff constraints (as in Witkin/Baraff). Everything works fine until i hit the moment of resting contact between the bodies. I'm using Hecker's time division algorithm to find the collision time. I've written a function to calculate the contact forces and their application points for a frame, store them and apply them to the text frame. In addition i can also cancel the tangential velocities of the objects in resting contact. The problem that i'm encountering is how to put all these together in the algorithm. Currently it works like this: - calculate forces, apply contact forces from last frame if there are any - apply constraint forces and spring forces - integrate from source config to target configuration - move objects to legal positions using the constraints - check collisions - if any objects are interpenetrating subdivide time and throw away target config - else, resolve collisions and contacts (-calculates contact forces) and switch configurations I think the problem resides in the fact that at inital resting contact when i integrate, the objects will move, penetrating each other, and the contact solution being not able to change this position only after the collision detection. This may not happen in the first frame but over several frames. How should i perform those steps to be able to integrate my contact resolution techniques? Here's the demo, read the last post for more info [Edited by - Ilici on September 15, 2004 12:38:56 AM]

Share this post


Link to post
Share on other sites
That's exactly the problem I had with my simulator... I didn't solve it so I can't be of good advice except that there is good alternatives with impulse methods (;...

However the first thought I had and wich seems to already have been implemented by researchers was to desynchronize the simulation for resting objects.

The real problem then is, when to resynchronize different objects together when new contact occurs and how long of a step should be taken by an object in contact? \: This looks highly heuristic and has strong similarities with activation/deactivation method (sleeping objects)... Wich is not an easy problem to solve efficiently (:

Download a few PDF on rigid bodies and you should find a reference to the paper that describes this approach. If I find it again browsing my collection I'll be sure to post the link here.

Edit: Grammar/spelling edition, my lack of sleep is beginning to show... (:

Share this post


Link to post
Share on other sites
I have an idea to revert the objects back to their source position before the integration occured, but only on the normal's direction. Also i would cancel the velocities in the normal's direction. I guess that i'd have to recalculate collions after this.

I think this is very similar to pushing objects apart with a stiff constraint (the way they did it in Advanced Character physics).

I'll check how this goes and if it works (the hard part) i'll post the results.

Share this post


Link to post
Share on other sites
I implemented some my contact resolving technique with moderate success. I'm basically projecting the object's using the surface normal out of the penetrating contact, and also clearing their velocities in this normal's direction. After that i apply contact forces in the directions of the normals of the points/edges the body resides on.

The force calculation isn't done properly as i'm just adding up all those forces and dividing by the number of application points so sometimes the bodies tip over when they shouldn't.

Also in the collision detection, i use accumulation vectors for the velocities so the collision impulse calculations are done with original pre-collision velocities.

A thing i could implement is bodies at rest being ignored from the update loop, so they don't mess up the time division algorithm (this is the worst part of it all). I think that using relaxation would be the better thing to do, i'm getting sick with the simulation stalling.

I uploaded a demo here. Use the arrows to scroll the world, and S and D to zoom. If you get the "UF UF UF" for long periods of time and you notice no movemenent then the simulation broke down :(. You can change the objects/constraints using the data.ini file.

Comments, ideas? Anything is welcome..

[Edited by - Ilici on September 14, 2004 3:05:09 PM]

Share this post


Link to post
Share on other sites
Quote:
Can't access it...


Copy/Paste the URL in some blank window or dl manager. It worked here.

I couldn't spot any suspect behavior exept for the ball (I suppose it's connected to springs?) wich stops quite abruptly when going first to the right, but can't much troubles to solve.

It's looking good, a bit slow here (not in rendering speed but in simulation speed) but good.

Did you try stacking some boxes? I could still run my simulation with 2 boxes but 3 would slow down too much almost on every run... \:

Share this post


Link to post
Share on other sites
Quote:
Original post by b34r
Quote:
Can't access it...


I couldn't spot any suspect behavior exept for the ball (I suppose it's connected to springs?) wich stops quite abruptly when going first to the right, but can't much troubles to solve.

It's looking good, a bit slow here (not in rendering speed but in simulation speed) but good.

Did you try stacking some boxes? I could still run my simulation with 2 boxes but 3 would slow down too much almost on every run... \:


Yes, the ball is connected to a spring from the left and string from above.

The slowness is because i'm using a fixed timestep and the framerate varies with the window size (to be fixed).

I tried stacking boxes, but when i stack more than 2 it either blows up or gets stuck. It works sometimes if the boxes have some initial velocities.

I'll keep it in the current situation for the project i'm working on as it doesn't need a user defined world (just a single experiment being simulated), but i think i'll scrap the time division thing and use a constraint based approach.

Share this post


Link to post
Share on other sites
I've also got the same problems as you did. Do you also have the assert problem from chris hecker;s code :-)

The bisection method works fine for me when things are just colliding but when they start to rest i get a huge speed drop.

Share this post


Link to post
Share on other sites
Quote:
Original post by Airo
I've also got the same problems as you did. Do you also have the assert problem from chris hecker;s code :-)



Yes i have the same problem. Instead of asserting, i just skip the frame, so instead of an assert i have a return.

Share this post


Link to post
Share on other sites
I had the plan to add seperation of objects code there and then continue.

For now however I leave it in, because it allowed me to spot quite some errors in my code. it's a huge pain and at the same time gem :)

Share this post


Link to post
Share on other sites

This topic is 4839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this