Re: Patch for wheel spin velocity traction
David Savinkoff <[email protected]> Mon, 15 Jun 2015 17:16:10 -0600 (MDT)
| Newsgroups | gmane.games.torcs.general |
|---|---|
| Message-ID | <1228999636.10837338.1434410170682.JavaMail.zimbra@mailid.telus.net> |
Hi, This patch is the same as the previous, and has further fixes. Apply this patch to clean sources (not with my previous patches). This patch is an injection of natural physics, and an improvement. *** In hunk 1: stmp is removed because this line of code in hunk 3 is not needed anymore: stmp = MIN(s, 1.5f); *** In hunk 2: wrl calculation is corrected. wrl is the speed of the spinning wheel (in the direction the wheel is pointed). However, the wheel is sliding sideways due to the slip angle. Thus, the 'vector component' of wrl must derived from the slip angle. else if () code is factored out. Correct percent slip calculation for ALL conditions: sx = (vt - wrl) / (0.000001f + MAX(fabs(vt) , fabs(wrl)) ); if (fabs(sx) > 1.0) sx /= fabs(sx); The reason for this correction is because it is not physically possible to have more than 100 percent slip (The old code is correct 'only' under braking conditions). *** In hunk 3: if ((v < 2.0f) || (zforce == 0.0f)) replaces if (v < 2.0f) because skid marks are otherwise present in the air with this patch. car->carElt->_skid[index] = s; because s is correct, and never exceeds 1.0f (100% slip). removed: stmp = MIN(s, 1.5f); Magic formula uses 's' instead of 'stmp' Sincerely, David Savinkoff ----- David Savinkoff wrote: > Hi, > > I found the shocking truth that I independently derived > a formula for tire friction. The formula is: > > sx = (vt - wrl) / (MAX(fabs(vt) , fabs(wrl)) ) > > Please read page 2 of this authoritive paper: > http://bsesrv214.bse.vt.edu/Hop/Papers/Tire-Road%20Friction%20Coefficient.pdf > > TORCS and Speed Dreams need fixin' > > Sincerely, > David Savinkoff > > > ----- David Savinkoff wrote: > > ----- Bernhard Wymann wrote: > > > Hi David > > > > > > It makes in my opinion no sense in respect to the tire model, the slip > > > definition looks consistent as is for me > > > > I cannot make an argument here because I am not absolutely certain how > > the tire model interacts with 'sx = (vt - wrl) / fabs(vt)' > > > > > > > > (in your analysis there is a little glitch, vt is not the car velocity, > > > it is the wheel specific velocity, all wheels have usually at least > > > slightly different velocities). > > > > > > > I may have not have expressed myself properly when I said 'car velocity' > > I envisioned a single wheel in contact with the road where 'vt' is the > > velocity in the direction the wheel is pointed... and where 'wrl' is the > > wheel spin velocity (can only be in the direction the wheel is pointed). > > > > > > > > The proposed change would cause a discontinuity which would usually > > > lower the grip. > > > > > > > 'sx = (vt - wrl) / ( 0.000001f + MAX(fabs(vt) , fabs(wrl)) )' has an > > inflection point where the wheel is actuated to slip by > > deceleration, or slip by acceleration. > > The discontinuity is caused by the 'act' of braking or accelerating. > > > > I believe 'sx' may need three different functions to include: > > 1) braking > > 2) accelerating > > 3) wheels rotating backwards to the direction of travel. > > The formula for 'sx' is my best so far, and it seems to work ok. > > > > I visualize vt and wrl as two parallel lines showing their respective > > lengths. Where vt - wrl is the length part that differs. eg. > > _________________________ > > _____________________________________ > > > > The formula for 'sx' suggests that one wants to determine a 'normalized' > > slip value given vt, wrl, and vt-wrl. Note that the slip happens in > > several different situations. > > > > > I think a better solution for drifting is to adjust the parameters of > > > the tire model > > > > I just tried different tire pressures (other than the default 40 psi). > > I will comment on this list when I come across interesting things. > > > > *** > > Please actually try my latest patch traction2.diff on different cars > > and tracks. Drive aggressively (off-track also) or ride with Olethros 6. > > *** > > > > > , differential and suspension. If you don't mind to edit > > > the XML you can adjust as well the engine braking coefficient (instead > > > of adapting your accelerator control in your mind;-) ). > > > > > > Other opinions? > > > > > > > Others on the list... Your opinions please. > > > > Sincerely, > > David Savinkoff > > > > > > ------------------------------------------------------------------------------ > > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT > > Develop your own process in accordance with the BPMN 2 standard > > Learn Process modeling best practices with Bonita BPM through live exercises > > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ > > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF > > _______________________________________________ > > Torcs-users mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/torcs-users > ------------------------------------------------------------------------------ _______________________________________________ Torcs-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/torcs-users
wheel.cpp.diff
(text/x-patch, 1.7 KB)
--- torcs-1.3.6/src/modules/simu/simuv2/wheel.cpp 2013-08-29 06:01:32.000000000 -0700
+++ torcs-1.3.6/src/modules/simu/simuv2/wheel.cpp 2015-06-15 12:56:55.856144909 -0700
@@ -179,7 +179,7 @@
tdble waz;
tdble CosA, SinA;
tdble s, sa, sx, sy; // slip vector
- tdble stmp, F, Bx;
+ tdble F, Bx;
tdble mu;
wheel->state = 0;
@@ -226,14 +226,13 @@
}
NORM_PI_PI(sa);
- wrl = wheel->spinVel * wheel->radius;
+ wrl = wheel->spinVel * wheel->radius * fabs(cos(sa)); // wheel can slide sideways due to slip angle
+
if ((wheel->state & SIM_WH_ONAIR) != 0) {
sx = sy = 0.0f;
- } else if (v < 0.000001f) {
- sx = wrl;
- sy = 0.0f;
} else {
- sx = (vt - wrl) / fabs(vt);
+ sx = (vt - wrl) / (0.000001f + MAX(fabs(vt) , fabs(wrl)) ); // slip factor for wheel spin and wheel skid
+ if (fabs(sx) > 1.0) sx /= fabs(sx); // slip factor = 1.0 for all else (eg. forward wheel spin while sliding backwards)
sy = sin(sa);
}
@@ -243,18 +242,16 @@
{
// calculate _skid and _reaction for sound.
- if (v < 2.0f) {
+ if ((v < 2.0f) || (zforce == 0.0f)) {
car->carElt->_skid[index] = 0.0f;
} else {
- car->carElt->_skid[index] = MIN(1.0f, (s*zforce*0.0002f));
+ car->carElt->_skid[index] = s;
}
}
- stmp = MIN(s, 1.5f);
-
// MAGIC FORMULA
- Bx = wheel->mfB * stmp;
- F = sin(wheel->mfC * atan(Bx * (1.0f - wheel->mfE) + wheel->mfE * atan(Bx))) * (1.0f + stmp * simSkidFactor[car->carElt->_skillLevel]);
+ Bx = wheel->mfB * s;
+ F = sin(wheel->mfC * atan(Bx * (1.0f - wheel->mfE) + wheel->mfE * atan(Bx))) * (1.0f + s * simSkidFactor[car->carElt->_skillLevel]);
// load sensitivity
mu = wheel->mu * (wheel->lfMin + (wheel->lfMax - wheel->lfMin) * exp(wheel->lfK * zforce / wheel->opLoad));