[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - friction of stacked boxes

friction of stacked boxes

Official forum for the .

friction of stacked boxes

Postby jzxu » Mon Aug 26, 2013 7:13 pm

Hello:

I'm trying to model a stack of boxes being pushed on a flat surface in the presence of friction and gravity. If I understand correctly, chipmunk uses the Coulomb model of friction, so the velocity of a sliding object is decelerated by a constant amount opposite the direction of travel at each simulation step. That constant amount is a function of the object's mass and friction coefficient, and the y gravity constant. Is that all correct?

This gets a little more complicated when two boxes are stacked on top of each other. My expectation is that the friction between the bottom box and the ground should be a function of the mass of the entire stack, since the boxes on top are pushing down and increasing the normal force of the bottom box against the ground. Is that also correct?

Finally, when actually simulating this scenario, I see some very strange behavior. My setup is like this: I place two boxes into the world, one on top of the other. I give them some time to settle, then apply a horizontal impulse to the bottom box. As expected, it slides slightly, with the top box also moving but not as much. The strange behavior is that after a while, the top box starts to sink into the bottom box. You can see a video of it here:

http://www.youtube.com/watch?v=I5gtDsJO7Ss

I'm running the simulation with a dt of 1e-5 and my boxes are all 1 unit in size. The boxes have friction coefficients of 1.0 and the ground has a friction coefficient of 0.1. All objects have 0 elasticity. Does anyone have any suggestions to fix this behavior?

Thanks ahead of time for your help.
jzxu
 
Posts: 7
Joined: Fri Apr 23, 2010 1:22 pm

Re: friction of stacked boxes

Postby slembcke » Tue Aug 27, 2013 8:54 am

Yup, that is basically all correct. The simplest way to put it is that the friction force is proportional to the normal force multiplied by the friction coefficient. Static friction is not simulated.

The behavior in that video is definitely weird, and I have no idea what would be causing that... Can you replicate the issue using the demo code from the Chipmunk github repo? I could probably figure out what is going on pretty quickly then.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: friction of stacked boxes

Postby jzxu » Tue Aug 27, 2013 5:32 pm

Hi slembcke:

Thanks for replying. I made a demo like you suggested, but I couldn't reproduce the sinking behavior. However, the behavior I did produce is also strange - the top box falls off the stack after the bottom box is pushed (as expected), but when it hits the ground, one corner sticks to the ground while the entire box tips back up slowly. You can see it here:

http://www.youtube.com/watch?v=PEYtZ9gikWU

Here's the code for the demo:

Bug.c
(2.29 KiB) Downloaded 326 times
jzxu
 
Posts: 7
Joined: Fri Apr 23, 2010 1:22 pm

Re: friction of stacked boxes

Postby slembcke » Wed Aug 28, 2013 1:54 am

Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: friction of stacked boxes

Postby jzxu » Wed Aug 28, 2013 2:28 am

You're absolutely right on both counts. Huge thanks for your help debugging my stupid mistakes!
jzxu
 
Posts: 7
Joined: Fri Apr 23, 2010 1:22 pm

Re: friction of stacked boxes

Postby slembcke » Wed Aug 28, 2013 2:47 am

No problem. :)
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: friction of stacked boxes

Postby jzxu » Wed Sep 04, 2013 1:14 pm

I have another quick question. If a box has two contact points with the ground, will the same frictional force be exerted twice on the box? Will this frictional force have the same magnitude as if the box had only one contact point with the ground, or will the force be spread out?

Thanks.
jzxu
 
Posts: 7
Joined: Fri Apr 23, 2010 1:22 pm

Re: friction of stacked boxes

Postby slembcke » Wed Sep 04, 2013 1:59 pm

Short answer: The friction force will get spread out, and the amount doesn't really change with multiple contact points.

Longer answer: Each contact point has it's own normal force (how tightly the surfaces press together). For an object sliding across the ground, the total normal force will be constant (or the object would sink into the ground or float away). The total friction force will be constant too since it's a percentage of that. Depending on the weight distribution of the object, different contacts might get different amounts of normal force, and different amounts of friction. They only go out of equilibrium when an object has enough friction to be tipped over.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: friction of stacked boxes

Postby jzxu » Fri Sep 06, 2013 4:34 pm

I have yet another question. Hopefully these aren't getting annoying...

Suppose I have the following setup: Three boxes A, B, and C are arranged on a flat surface so that they're right next to each other. The three boxes have different masses, call them m1, m2, m3, and different friction constants, call them f1, f2, and f3. The ground has friction 1.0. All elasticity constants are set to 0. All boxes have infinite moments of inertia so they never rotate. This setup is shown in this drawing:
drawing.png
drawing.png (2.4 KiB) Viewed 7116 times


Now I apply a constant force F to box A. My expectation is that the three boxes will move as if they are a single body with mass M = (m1 + m2 + m3). Furthermore, I would expect the total force acting on this setup to be:

F' = F - G * (f1 * m1 + f2 * m2 + f3 * m3)

where G is the gravity constant. This is just the pushing force minus the frictional force experienced by each box. The total acceleration experienced by the system should be F' / M.

I tried to replicate this setup in chipmunk, and the acceleration I measure in the simulation is close to my calculation, but still significantly different (by about 0.0002 for the values I used). I'm not using this for a game, so the small difference matters.

My question is, is the difference due to my calculation being too naive, or imperfections in the simulation? If the latter, what parameters can I tune to get the difference to be smaller?

I'm already running the simulation with collision iterations set to 100, and collision slop and bias set to 1e-7. I'm also running with a very small step duration (1e-5). Decreasing any of these parameters doesn't seem to decrease the difference between the measured acceleration and my calculation. I've also tried putting 0-length joint constraints between the boxes, but that made the situation much worse, as it seemed to build energy as the simulation progressed.

Any suggestions would be appreciated. Thanks for your help!
jzxu
 
Posts: 7
Joined: Fri Apr 23, 2010 1:22 pm

Re: friction of stacked boxes

Postby slembcke » Mon Sep 09, 2013 1:55 pm

A good question, but one that I don't exactly know the answer too. The thing to keep in mind is that Chipmunk uses an imprecise iterative solver. For a complex system with a lot of contacts and constraints, you could build and solve a giant linear system of equations, but it would be very expensive to do so. Instead, an iterative solver treats each contact and constraint independently and iterates over them several times. Each iteration should get you closer to the exact answer.

Chipmunk is primarily written for games, and games games really only require physically plausible physics. In other words, if the simulation is close enough that it looks correct, then it's good enough. So if the solver is 99.9% accurate and 20x faster than a non-iterative solver, that's an excellent compromise to make for a game engine. Not a good compromise for some non-game purposes though.

Anyway. While the quality should continue increasing with smaller timesteps and more iterations, it doesn't appear to be the case. At some point it doesn't help to do more of them. I'm not exactly sure why, but I would guess its just because the noise from the accumulated floating point error is too much to overcome.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest