So my idea is to create a fully spool/welded differential through a script (mostly at learning purpose).
Right now in the racer docs we have this code:
This differential uses speed difference to apply a torque coeficient, good for some balance between the powered wheels. But you cant actually get a fully locked (spool/welded) differential with this method.
Now from my learning I understand that angular velocity and torque are a totally different characters in this case and are not related as I thought at first.
Previously I thought that when both wheels have the same torque, they spinn equally but I was wrong.
I learned that only a open differential has torque equal on both wheels and tottally different angular velocity's on each wheel.
So in my theory a spool/welded differential will have equal angular velocity's and different torques on the wheels.
So here comes my equation how I think a spool differential would look in code:
and my input to the wheels should ideally be like this:
As you can see my idea is to transfer torque from one side to the other via speed difference ratio.
My question is, is this the right approach?
Or does anyone have a better idea?
Right now in the racer docs we have this code:
Code:
/*
* Viscous Differential
*/
#include "racer.oxs"
float OnDifferential(int diffIndex)
{
const float coeff=2000.0;
float v1,v2;
float torque;
// Velocities of the wheels (rad/s)
v1=GetSystemFloat("car0.wheel2.rotvel");
v2=GetSystemFloat("car0.wheel3.rotvel");
// Push towards equal velocities
torque=-coeff*(v2-v1);
return torque;
}
This differential uses speed difference to apply a torque coeficient, good for some balance between the powered wheels. But you cant actually get a fully locked (spool/welded) differential with this method.
Now from my learning I understand that angular velocity and torque are a totally different characters in this case and are not related as I thought at first.
Previously I thought that when both wheels have the same torque, they spinn equally but I was wrong.
I learned that only a open differential has torque equal on both wheels and tottally different angular velocity's on each wheel.
So in my theory a spool/welded differential will have equal angular velocity's and different torques on the wheels.
So here comes my equation how I think a spool differential would look in code:
Code:
// ratio of velocity difference
float velocityRatio=0.5f;
// Velocities of the wheels (rad/s)
leftSpeed=GetSystemFloat("car0.wheel2.rotvel");
rightSpeed=GetSystemFloat("car0.wheel3.rotvel");
if ( velocityRatio>0.5f)
velocityRatio = (leftSpeed/rightSpeed)/2;
else
velocityRatio = (rightSpeed/leftSpeed)/2;
and my input to the wheels should ideally be like this:
Code:
// torqueInput is suposed to be the final torque ((tEngine)*gearRatio*finalDriveRatio)
leftTorque=(torqueInput * (1-velociotyRatio)) ;
rightTorque=(torqueInput * velociotyRatio) ;
//instead of
//leftTorque=(torqueInput * 0.5f) ;
//rightTorque=(torqueInput * 0.5f) ;
As you can see my idea is to transfer torque from one side to the other via speed difference ratio.
My question is, is this the right approach?
Or does anyone have a better idea?