Loss of apply force.

Topics: Developer Forum, Project Management Forum, User Forum
Nov 12, 2012 at 4:22 AM

Hi.

I have a problem at apply force.

 

I applied force a value that calulated by newton 2nd theory.

F = ma

but result was not exactly.

Maybe occur some loss.

 

My case is like below.

Gravity is Zero.

Force is about (0, -0.0064)

Mass is about 0.00125

Velocty is (0, 0)

Friction is Zero

 

After World.Step(), expacted velocity is about (0, -5.12)

(because of newton theory, a = F / m)

but result was about (0, -4.25).

 

I think, some force is lossed.

How do I fix it?

Thanks. :)

Coordinator
Nov 12, 2012 at 11:50 AM

There is also damping involved. Take a look at angular and linear damping on the body.

Nov 12, 2012 at 12:05 PM
Genbox wrote:

There is also damping involved. Take a look at angular and linear damping on the body.


Thanks for answer.

but got same result.

Inertia was zero, too.

Nov 12, 2012 at 6:08 PM
Edited Nov 12, 2012 at 6:09 PM

Expected velocity will depend on the time step. Your -5.12 is an arbitrary number without time. Incidentally it's equal to the acceleration that this constant force can produce on this body in the absence of other forces.

Anyways the solver applies a constant force F over the time step passed to World.Step(dt) to produce a new position/rotation and velocity for the body after dt has elapsed. Energy is not exactly conserved due to errors in the integration but in general the smaller the time step the better the result. So it's sort of advisable to take 10 steps of 0.1s instead of one step of 1s. Errors will accumulate with bigger steps.

Nov 13, 2012 at 1:44 AM
Edited Nov 13, 2012 at 1:48 AM
jerrysb wrote:

Expected velocity will depend on the time step. Your -5.12 is an arbitrary number without time. Incidentally it's equal to the acceleration that this constant force can produce on this body in the absence of other forces.

Anyways the solver applies a constant force F over the time step passed to World.Step(dt) to produce a new position/rotation and velocity for the body after dt has elapsed. Energy is not exactly conserved due to errors in the integration but in general the smaller the time step the better the result. So it's sort of advisable to take 10 steps of 0.1s instead of one step of 1s. Errors will accumulate with bigger steps.


Thanks.

 

I gave this force in just one step that time was gameTime.ElapsedGameTime.TotalMilliseconds.

so I don't think this time is too big to make errors.

And loss was too large to call just error that prox. 20% lossed.

 

so I guess, I missed some points of time that you remind me or something.

Nov 13, 2012 at 4:33 PM
Edited Nov 13, 2012 at 4:34 PM

Hmm... I don't know if that's the issue but World.Step() works with seconds and you gave it milliseconds which would be 1000 times bigger that what it expects :) That would definitely qualify as a "large time step". You should give it gameTime.ElapsedGameTime.TotalMilliseconds*0.001f as a step.

Try this code:

using FarseerPhysics.Dynamics;
using FarseerPhysics.Factories;
using FarseerPhysics.TestBed.Framework;
using Microsoft.Xna.Framework;

namespace FarseerPhysics.TestBed.Tests {
	public class FMATest:Test {
		private FMATest() {
			World.Gravity = Vector2.Zero;
			//Mass is 0.00125
			//Stationary body with no forces acting on it and nothing else in the world
			Body testBody = BodyFactory.CreateRectangle(World, 0.025f, 0.05f, 1f);
			testBody.BodyType = BodyType.Dynamic;
			testBody.ApplyForce(new Vector2(0, -0.0064f));
			const float timeStep = 1 / 60f;
			World.Step(timeStep);
		}
		internal static Test Create() {
			return new FMATest();
		}
	}
}

Put breakpoints or print the velocity after World.Step(). It works fine for me for steps until about 0.6s. Above that the error gets bigger. For very large steps like 1000s the error is huge (lost of energy?).

Nov 14, 2012 at 1:31 AM
Edited Nov 14, 2012 at 1:37 AM

It always loss about 20%, so I product 1.2 to force for adjustment.

 

I tried to some test with several mass or force and appling that value, finally almost work fine.

and got a result, that value no relate with force or mass.

so I'm sure, 20% of force was lossed in somewhere, but I don't know exactly where.

 

I'm using version 3.3.

Thanks.