added differential changes to simuv2 from simuv3, including the new "Locking" diff and changes to Limited Slip diffs.

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@204 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 397f80d1ac40ecd0182d792679e71feac269c2cd
Former-commit-id: fdf48ac21e0fe34a928f7d84a48ab5a58792cd62
This commit is contained in:
andrewsumner 2008-11-11 05:39:28 +00:00
parent 1cff825276
commit 48f6f3cc49
3 changed files with 41 additions and 3 deletions

View file

@ -548,6 +548,7 @@ typedef struct CarElt
#define VAL_DIFF_SPOOL "SPOOL"
#define VAL_DIFF_FREE "FREE"
#define VAL_DIFF_LIMITED_SLIP "LIMITED SLIP"
#define VAL_DIFF_LOCKING "LOCKING"
#define VAL_DIFF_VISCOUS_COUPLER "VISCOUS COUPLER"
#define VAL_TRANS_RWD "RWD"

View file

@ -43,6 +43,8 @@ SimDifferentialConfig(void *hdle, char *section, tDifferential *differential)
differential->type = DIFF_VISCOUS_COUPLER;
} else if (strcmp(type, VAL_DIFF_SPOOL) == 0) {
differential->type = DIFF_SPOOL;
} else if (strcmp(type, VAL_DIFF_LOCKING) == 0) {
differential->type = DIFF_LOCKING;
} else if (strcmp(type, VAL_DIFF_FREE) == 0) {
differential->type = DIFF_FREE;
} else {
@ -176,6 +178,36 @@ SimDifferentialUpdate(tCar *car, tDifferential *differential, int first)
break;
case DIFF_LOCKING:
// Locking differential - used to be LIMITED_SLIP
if (DrTq > differential->lockInputTq) {
updateSpool(car, differential, first);
return;
}
spdRatioMax = differential->dSlipMax - DrTq * differential->dSlipMax / differential->lockInputTq;
if (spdRatio > spdRatioMax) {
deltaSpd = (spdRatio - spdRatioMax) * fabs(spinVel0 + spinVel1) / 2.0;
if (spinVel0 > spinVel1) {
spinVel0 -= deltaSpd;
spinVel1 += deltaSpd;
} else {
spinVel0 += deltaSpd;
spinVel1 -= deltaSpd;
}
}
if (spinVel0 > spinVel1) {
DrTq1 = DrTq * (0.5 + differential->bias);
DrTq0 = DrTq * (0.5 - differential->bias);
} else {
DrTq1 = DrTq * (0.5 - differential->bias);
DrTq0 = DrTq * (0.5 + differential->bias);
}
break;
case DIFF_LIMITED_SLIP:
// Limited slip differential with:
// - Gradual frictive locking
@ -201,9 +233,13 @@ SimDifferentialUpdate(tCar *car, tDifferential *differential, int first)
float pressure = tanh(rate*(spinVel1-spinVel0));
float bias = differential->dSlipMax * 0.5f* pressure;
float open = 1.0f;// - rate;
DrTq0 = DrTq*(0.5f+bias) + spiderTq*open;
DrTq1 = DrTq*(0.5f-bias) - spiderTq*open;
float open = 1.0f - fabs(pressure);
DrTq0 = DrTq*(0.5f+bias) + spiderTq;
DrTq1 = DrTq*(0.5f-bias) - spiderTq;
DrTq0 = open*(DrTq*(0.5f) + spiderTq)
+ (1 - open)*(DrTq*(0.5f + bias));
DrTq1 = open*(DrTq*(0.5f) - spiderTq)
+ (1 - open)*(DrTq*(0.5f - bias));
}
break;

View file

@ -37,6 +37,7 @@ typedef struct
#define DIFF_FREE 2
#define DIFF_LIMITED_SLIP 3
#define DIFF_VISCOUS_COUPLER 4
#define DIFF_LOCKING 5
tdble ratio;
tdble I;
tdble efficiency;