From: Malcolm R. <mal...@cs...> - 2007-05-01 05:26:40
Attachments:
physics_test.py
|
Hi, I'm a new user of ODE, working with the PyODE interface in order to build games with PyGame. I've written a test program (attached) but it doesn't seem to work right. Basically, it involves two objects (a box and a sphere) dropping onto a floor (a plane). When they collide with the floor, they are supposed to stop. It all works fine, until I give the objects mass. Once I add the following lines: M = ode.Mass() M.setSphere(10, self.radius) self.body.setMass(M) The Circle object starts to significantly penetrate the floor, and bounce a lot. It eventually comes to rest half-embedded in the floor. If I reduce the density from 10 to 1, the problem is significantly reduced, but still there is a lot of bouncing before the objects come to rest on the surface. Can anyone explain what is going on here? Thanks, Malcolm -- "Cleanliness is not next to godliness nowadays, for cleanliness is made an essential and godliness is regarded as an offence. - G.K.Chesterton, On Lying in Bed |
From: Ethan Glasser-C. <gl...@cs...> - 2007-05-01 06:27:33
Attachments:
signature.asc
|
Your original program is kind of hypnotic, actually.. Malcolm Ryan wrote: > Can anyone explain what is going on here? To quote Chris Bainbridge, who once answered a similar plea for help from me: "Your CFM value is too high, which allows the generated contacts to be violated significantly. Try world.setCFM(1E-8)" Indeed, I put that line world.setCFM(1e-8) at line 107 of your program, and everything seems to work more as you'd expect. I don't really understand this part of ODE too well, maybe someone else can explain better what's happening. Specifically, is it true that for any given CFM, you can increase the mass of your objects, and get more sponginess in your collisions? What gives? Ethan |
From: Malcolm R. <mal...@cs...> - 2007-05-01 08:28:40
|
On 01/05/2007, at 4:27 PM, Ethan Glasser-Camp wrote: > "Your CFM value is too high, which allows the generated contacts to be > violated significantly. Try world.setCFM(1E-8)" > > Indeed, I put that line > > world.setCFM(1e-8) Yes. That seems to work. I notice also that setting CFM to zero causes a singularity. Malcolm -- "The Christian ideal has not been tried and found wanting; it has been found difficult and left untried." - G.K.Chesterton, What's Wrong With The World |
From: Chris B. <chr...@gm...> - 2007-05-01 08:38:02
|
On 01/05/07, Ethan Glasser-Camp <gl...@cs...> wrote: > To quote Chris Bainbridge, who once answered a similar plea for help > from me: > > "Your CFM value is too high, which allows the generated contacts to be > violated significantly. Try world.setCFM(1E-8)" > > Indeed, I put that line > > world.setCFM(1e-8) > > at line 107 of your program, and everything seems to work more as > you'd expect. I don't really understand this part of ODE too well, > maybe someone else can explain better what's happening. Specifically, > is it true that for any given CFM, you can increase the mass of your > objects, and get more sponginess in your collisions? What gives? Pretty much, yes. CFM just scales the force that would be applied to correct the error from a constraint. Suppose you need a force of 10N to totally correct a constraint in a single simulation step, and CFM is 0.5, then the simulator will actually apply a 5N force in that time step. Hence the error due to the constraint will be slowly corrected over several time steps, rather than in a single time step. Your observation about mass being related to sponginess is correct. Imagine two objects with mass colliding. The larger the mass, the larger the force required to correct the collision and stop the objects from penetrating. Since you only apply a proportion of this force in a single step you'll see more more overlap of the two objects as the mass increases because there is more uncorrected force in total. Hmm. Imagine being hit in the face with an iron bar - you'd expect it to penetrate further than a plastic bar. Now imagine the collision constraint like a very thin/weak force field around your head that pushes objects away. It couldn't stop the lead bar from being swung straight through your skull, but probably could stop the plastic one! ;-) See http://ode.org/ode-latest-userguide.html#sec_3_8_0 for a more detailed explanation. |
From: Ethan Glasser-C. <gl...@cs...> - 2007-05-01 17:22:40
Attachments:
signature.asc
|
Chris Bainbridge wrote: > See http://ode.org/ode-latest-userguide.html#sec_3_8_0 for a more > detailed explanation. The user guide makes a distinction between soft constraints and hard constraints. Am I understanding correctly that all ODE joints are soft constraints, just with varying degrees of softness? If you wanted hard collisions, is there some way you could scale CFM by mass, or by 1/mass or something? Does the default CFM "work best" with objects of particular mass? I think someone who uses ODE for the first time will be surprised that collisions are "soft". I'd like to edit the wiki to make it more obvious, but I haven't signed up for an account yet. Ethan |