Trouble with wheels

Topics: Developer Forum, Project Management Forum, User Forum
Sep 10, 2009 at 10:28 AM

Hey,

First off - let me say how awesome I have found Farseer. None of the other engines I have tried to work with have been so easy to work with and get results. Thanks : )

Im still in the learning stage though and as such I have a question i hope you guys can answer. What im trying to do (for now) is simply to get a wheel to rotate when a button is held, such that it will move a long the ground and roll up and down hills. I have created the wheel the same way as done in the advanced samples #6 - but when I apply the AngularImpulse the wheel seems to fly off the surface and rotate strangely in my air whilst moving forward.

Here are the stats for my wheel:

Radius = 20;

Mass = 20;

FrictionCoefficient = 1.0f;

AngularImpulse applied = 250f;

What im trying to do in the end is have a car that can accelerate fast, but not achieve a very large top speed? Any ideas? : /

Coordinator
Sep 10, 2009 at 12:36 PM

First of all you must remember that circles are acutally not circles, they are an approximation of a circle. They will be uneven in the surface and thus not behave like a real circle. As for your problem, you apply a huge impulse to the wheel and that will cause an explosion of force. You should try working with force instead of impulse for car wheels; force is a lot more stable because it gets applied over time instead of all at the same time.

Sep 10, 2009 at 3:38 PM

Thanks for your quick answer : )

Okay i tried changing it to ApplyForce(new Vector(100,0)) - its still very slow starting and lifts of off the ground : /

My code for generating the wheel is: 

 

            body = BodyFactory.Instance.CreateCircleBody(radius, 20f);
            geometry = GeomFactory.Instance.CreateCircleGeom(body, radius, 32, 0f);

 

 

body = BodyFactory.Instance.CreateCircleBody(radius, 20f);
geometry = GeomFactory.Instance.CreateCircleGeom(body, radius, 32, 0f);

Im taking 32 as how many points make up the circle? I have seen others get better away with this, so there must be something im completely mistunderstanding. How is it possible to set a maximum velocity for the rolling wheel? Hope you can help :)

 

 

 

Sep 10, 2009 at 3:59 PM

An easy way to set a max speed (or rotation) to an object is to increase the LinearDragCoefficient or the RotationalDragCoefficient to slow down movements or rotation.  If this value is very high, then you'll need to apply much more force, but it essentially sets a maximum speed/rotation speed.

Sep 10, 2009 at 4:19 PM

Okay ye I get how that works... but as off right now the ball will only roll really slow and then does the loop thing. Very strange : / Just wanted it to rol lalong the ground hmm

Coordinator
Sep 10, 2009 at 10:28 PM

That is usually caused by the approximation of circles. It its an edge and bounces a little and if your angular velocity is high, the bouncing will be more intense. You need to experiment with the number of vertices that makes up the wheel (32 in your case) or develop other means of getting around this. (implementing real circles or use rays as wheels as examples)