Page 1 of 1
Vehicle Simulation - Clutch, Axle Diff
Posted: Tue Aug 07, 2012 8:57 pm
by DanStory
Hi,
I'm currently just researching, physics/game engines that will best suit my idea, and what would be required to simulate the powertrain of a vehicle. Or at least the "slip-ish" of the clutch and say a limited-slip differential as well as non-slip on a locked differential. I'm not focused much on accuracy and more on that it looks/feels right (as it'll just be a game). I've been looking through the source of Bepu on codeplex looking at the Vehicle, Wheel, etc classes to get a better idea of how this physics engine works in that area.
From my overview, it isn't currently capable with bepu, but what would be the undertaking to implement something like this?
Thanks,
Daniel.
Re: Vehicle Simulation - Clutch, Axle Diff
Posted: Tue Aug 07, 2012 11:04 pm
by Norbo
I'm not very knowledgeable about the mechanics of drivetrains, so my suggestions can only go so deep. It should still be possible to accomplish something like what you want, though
The Vehicle class is designed as a very high level approximation of a vehicle- it uses ray casts for wheels and linear velocity motors to push the car along. It's still possible to accomplish the high-level feel of lower level systems by changing motor properties and graphics on the fly, though. How much fiddling this would take depends on the exact desired behavior. For example: since the wheels are actually totally separate and combining them physically isn't trivial, a locking differential could be approximated in appearance by simply clamping a free wheel to the (purely graphical) angular velocity of the other wheel. On top of that, the driving motor associated with the wheel with traction could be strengthened temporarily.
It's also possible to build a vehicle from scratch out of joints and entities. The SuspensionCarDemo in the BEPUphysicsDemos shows an example of that. It's a bit closer to reality since the wheels actually exist and are physically constrained. This could be used as a basis for further modifications. For example, while the angular motors driving each wheel are totally separate (a bit like an electric car with distributed motors), it would be possible to add another physical constraint between wheel pairs that locks their rotation to each other. Conditionally disabling or tuning that constraint should be able to produce results varying from full slip to partial/clamped slip to full locking.
Here's an example constraint that could be added to the SuspensionCarDemo (alongside the existing steeringStabilizer):
Code: Select all
var locker = new RevoluteMotor(wheel1, wheel2, Vector3.Right);
//Options:
//1) FULL LOCK
//Uncomment this section to fully lock the wheels together. The motor will seek to maintain the same rotation and correct any drift in rotation.
//This is slightly more 'locky' than merely leaving it a rigid velocity constraint with a goal of zero relative motion due to that position correction;
//a rigid velocity constraint could drift a bit under sufficient force.
//locker.Settings.Mode = MotorMode.Servomechanism;
//2) PARTIAL DAMPING LOCK
//Uncomment this section to apply a damping force on any relative angular motion between the wheels. This assumes the motor is in velocity mode, not servo mode.
//locker.Settings.VelocityMotor.Softness = .05f;
//3) PARTIAL MAXIMUM FORCE LOCK
//Uncomment this section to apply a force on any relative angular motion between the wheels.
//This is different from damping; this just applies a force up to a certain limit.
//locker.Settings.MaximumForce = 100f;
//It's also possible, but a little less natural, to use a velocity limited lock. Check the relative velocity of the wheels and, if it exceeds some value, activate the
//constraint with a target of the maximum velocity and with some maximum force.
//Care must be taken with this approach; the constraint is an equality constraint, not an inequality constraint. It will try to reach the velocity goal from either direction.
//It wouldn't be too hard (but not trivial) to modify a RevoluteMotor to create an inequality velocity constraint if this was an important feature.
//4) FULL SLIP TOGGLE
//Uncomment this to disable the constraint. You can toggle this whenever you want to conditionally use the locking constraint.
//(Not being in the space has the same effect as being inactive, but if you plan to turn it off and on frequently, it's usually more convenient/speedy to use the IsActive property.)
//locker.IsActive = false;
Space.Add(locker);
This constraint based locking has the advantage of automatically and physically transferring the strength of the formerly freely spinning motor to the traction motor. Constraint based vehicles are more expensive than the approximate Vehicle class, though. This may be an issue if you plan on simulating a whole lot of vehicles on a platform slower than a PC.
Re: Vehicle Simulation - Clutch, Axle Diff
Posted: Wed Aug 08, 2012 1:27 am
by DanStory
I appreciation your time in replying to my question.
Your suggestion to "build" the vehicle using joints, constraints, etc does sound like more of the results I'd like, even though it will create more complexity of things to go wrong and/or become more expensive to compute. For now there will only be one vehicle, the player's; and if I can get this off the ground be no more than 4 vehicles in the space.
Searching around it seems bepu is one of the preferred/best physics engines for XNA; and looking at the features it has is probably the most complete one.
I'm going to try and modify the SuspensionCarDemo and see if I can come up with what I am imagining.
Thanks again,
Daniel.