This project has moved and is read-only. For the latest updates, please go here.

Difficulty with RevoluteJoint MotorSpeed

Topics: Developer Forum
Mar 18, 2013 at 5:38 AM
Edited Mar 18, 2013 at 5:45 AM

I'm using a RevoluteJoint with the motor enabled to power the backwheel of a motorcycle. The problem I'm having is that I would like my motorcycle to go faster. No matter what I set my MotorSpeed to, I can't seem to get a speed (as tested via RevoluteJoint.JointSpeed) faster than 50. I did some Box2d searching and now understand that MotorSpeed is a "target" and whether or not it reaches the target is dependent upon the MaxMotorTorque. However, even significantly increasing the MaxMotorTorque does not yield a speed faster than 50 (and increasing the MaxMotorTorque in this way makes the motorcycle undriveable -- just flips immediately). I even tried testing with the backwheel off the ground (just pinned the bike in the air with a FixedRevoluteJoint) and it still seems as though I'm hitting a speed ceiling at around 50.

What am I missing? I started with the car sample in farseer so my motorcycle is modeled in a similar way. Any tips for how I can make a faster vehicle?

Many thanks,

Edit: okay, I can see that if I really up the MotorTorque (I set it to 1000), I can get speeds close to 100. The problem is I need my motor torque to be around 2 to keep the bike from flipping immediately. Any tips or tricks? Do I need to scale the motor torque with the JointSpeed to get a faster speed without flipping the bike? Is there a way to divorce motortorque from motorspeed? Thanks again, Mike.
Mar 19, 2013 at 4:00 AM
Well I eventually figured out the problem (sort of). Turns out it was my timestep (apparently a very common issue for this sort of oddness: I'm updating at 30fps so I was passing 1/30 into my world.step. Turns out this was not enough to ever reach the target MotorSpeed (I'd be lying if I said I totally understood why). At any rate, now I call world.step twice each frame with 1/60 and viola!, I can now reach the desired MotorSpeed. Unfortunately it makes my entire simulation behave a little differently/faster, so I need to do some more tweaking.

Anyway, thought I'd post in case anyone else runs into the same problem.