Body slows down too quickly

I have a ball bouncing off a couple of walls at a reasonable speed. The ball has a density of 1.0 and radius of 0.05 or so. The walls are defined as static (density=0). The ball will bounce between the ball for a while then stop although it seemingly should have a great deal of kinetic energy remaining. Some data:

Speed from b2Vec2(0,0) to b2Vec2(0.012733,1.26057), diff = b2Vec2(-0.012733,-1.26057)
Speed from b2Vec2(0.012733,1.26057) to b2Vec2(0.0084887,-1.13451), diff = b2Vec2(0.00424435,2.39509)
Speed from b2Vec2(0.0084887,-1.13451) to b2Vec2(0.00282958,1.02106), diff = b2Vec2(0.00565912,-2.15558)
Speed from b2Vec2(0.00282958,1.02106) to b2Vec2(0.000943189,-0.918956), diff = b2Vec2(0.00188639,1.94002)
Speed from b2Vec2(0.000943189,-0.918956) to b2Vec2(0.000314397,-4.02938e-13), diff = b2Vec2(0.000628792,-0.918956)

The last line shows the Y-component dropping from -0.92 to -4e-13 (effectively stopping the ball), even though the previous step the speed change is about 0.09, and before that 0.11. Is this a known feature? Am I misunderstanding something?

The ball's restitution is 0.9, so I'd expect the change in speed to be comparable, and not drop by 0.92 suddenly.
There is a setting in b2Settings that stops dead objects if they have too low a velocity after a bound. It's important as otherwise nothing would ever go to sleep. If you've been playing around with units, it could be causing a problem.
Thanks for the response.

I thought it might be related to that, but I've not changed b2Settings.h:

const float32 b2_linearSleepTolerance = 0.01f; // 1 cm/s

..and clearly the ball is travelling much faster than this value in absolute terms.

However, a little more digging turned up this:

/// A velocity threshold for elastic collisions. Any collision with a relative linear
/// velocity below this threshold will be treated as inelastic.
const float32 b2_velocityThreshold = 1.0f; // 1 m/s

so it looks like what's happening is all of the ball's energy is being robbed by the wall - since the speed is below this threshold, the restitution value is effectively zero. What I don't understand is how an object of mass 0 can absorb all of the energy of an object with non-zero mass, unless "mass 0" really means "has effectively infinite mass."
Quote:
unless "mass 0" really means "has effectively infinite mass."

That is exactly how a body's mass is used in Box2D, though if you combine two shapes in a single body, one with mass and one without, then the body will have finite mass that is the sum of the mass of its shapes.

The "b2_velocityThreshold" is not intended to be realistic, but rather to help the simulation settle while being close enough to realistic that nobody would notice. Except you noticed. 😛 I imagine it would be safe to tweak this number for your use case.

Original thread: https://box2d.org/forum/viewtopic.php?t=1365