Hello, I have problem with prismatic joint speed.
There I have two bodies connected with a prismatic joint, I set joint's motor speed to 0.5, and it travels distance of 0.8 in ~9s.
If i set the speed to 5.0, the movement is much faster.
Correct me if I'm wrong: the speed is expressed in m/s, and distance in m, so expected time should be near 1.6 s
With a finite max motor force, it takes some time to accelerate up to speed. This depends on many factors, including:
- the mass of the attached bodies
- the forces acting on the attached bodies
- other constraints
Box2D is tuned for meters and seconds, but it does not require a particular unit system. It uses the dimensions you provide as-is. There is no unit conversion.
OK, so I've checked everything, but problem still persist.
- I'm sure the motor reaches it's maximum speed. I've applied huge force, and connected bodies are light as a feather.
- when creating joint, in joint definition motorForce=1e+10, motorSpeed=0.5
- b2World::Step() is called every 100ms, with timestep=0.016667, iterations=6 (which is expected to give 60 iterations per second)
- I'm sure there is no friction - joint is created with collideConnected = false, moving element don't touch anything else
- dumping is turned off.
Still, moving object by 0.8 with speed 0.5 takes 9sec of simulation time.
Any ideas, suggestions? Is there something I didn't check?
My experience is that you want to run the world step exactly once per simulation step, as running more than one world step per frame leads to problems. Each step clears all accumulated forces, so all iterations after the first have no forces applied. As a result, effective forces scale inversely proportional to the number of iterations (i.e. 10 iterations make effective forces 1/10th as strong).
You can get away with this if you exclusively apply impulses instead of forces, but I definitely recommend against it. Unless your simulation logic is extremely expensive, you should run it every world step (1/60th of a second in your case). It'll make it a lot more responsive.
In addition, the continuous collision detection (CCD) functionality in the SVN builds and upcoming version 2.0 allows fast-moving objects like bullets to work correctly at surprisingly low simulation rates. My top-down frantic-arcade-action-shooter uses a SVN build of Box2D and tolerates simulation rates as low as 10Hz, but that's only because it has no gravity pulling objects together into big piles (a case giving physics engines a hard time).