From 9ab0a7bac71521b7a4c9f3e137e12e0c31d8c133 Mon Sep 17 00:00:00 2001 From: kakukri Date: Sun, 9 Aug 2020 23:56:00 +0000 Subject: [PATCH] Re #1070: add visual indicator for tire wear and temperature (ssggraph) git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@7166 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 61d0d2caad77b452f8798b017e51c660f7331d7c Former-commit-id: a3222233075b20f60022d851187cadfc3ab8837d --- src/interfaces/car.h | 4 +- src/modules/graphic/ssggraph/grboard.cpp | 167 ++++++++++++++++++++++- src/modules/simu/simuv4/wheel.cpp | 26 ++-- 3 files changed, 185 insertions(+), 12 deletions(-) diff --git a/src/interfaces/car.h b/src/interfaces/car.h index 4f0c2bf82..5423809b0 100644 --- a/src/interfaces/car.h +++ b/src/interfaces/car.h @@ -307,7 +307,8 @@ typedef struct { int state; /**< wheel state */ tTrackSeg *seg; /**< Track segment where the wheel is */ tdble rollRes; /**< rolling resistance, useful for sound */ - tdble temp_in, temp_mid, temp_out; + tdble temp_in, temp_mid, temp_out; /*tire temperature inside, middle and outside of tread*/ + tdble temp_opt; /*optimal tire temperature*/ tdble condition; /**< tire condition, between 0 and 1 */ tdble treadDepth; /**< tread depth, between 0 and 1 */ tdble critTreadDepth; /**< critical tread depth, when grip falls off suddenly, between 0 and treadDepth */ @@ -335,6 +336,7 @@ typedef struct { #define _tyreT_in(i) priv.wheel[i].temp_in #define _tyreT_mid(i) priv.wheel[i].temp_mid #define _tyreT_out(i) priv.wheel[i].temp_out +#define _tyreT_opt(i) priv.wheel[i].temp_opt #define _tyreCondition(i) priv.wheel[i].condition #define _tyreTreadDepth(i) priv.wheel[i].treadDepth #define _tyreCritTreadDepth(i) priv.wheel[i].critTreadDepth diff --git a/src/modules/graphic/ssggraph/grboard.cpp b/src/modules/graphic/ssggraph/grboard.cpp index 61ccf2263..d455e4276 100644 --- a/src/modules/graphic/ssggraph/grboard.cpp +++ b/src/modules/graphic/ssggraph/grboard.cpp @@ -381,9 +381,9 @@ cGrBoard::grDispGGraph() glVertex2f(XC + THNSS, YC + car_->ctrl.clutchCmd * 100.0f); glVertex2f(XC - THNSS, YC + car_->ctrl.clutchCmd * 100.0f); - // Draw the tire slip color gauges + // Draw the tire slip and the tire temperature & wear color gauges if (GFlag == 2) { - tdble s; + tdble s, height; // FR wheel s = car_->_wheelSlipNorm(0)/car_->_wheelSlipOpt(0); if (s > 1.0) { @@ -396,6 +396,47 @@ cGrBoard::grDispGGraph() glVertex2f(X1 + 50.0f, Y1 + 30.0f); glVertex2f(X1 + 50.0f, Y1 + 50.0f); glVertex2f(X1 + 40.0f, Y1 + 50.0f); + + height = 20.0f * MAX(car_->_tyreTreadDepth(0), 0.1f); + s = 10.0f*(car_->_tyreT_out(0)/car_->_tyreT_opt(0)-1.0f); + if (s >= 0.0f) { + s = MIN(1.0f, s); + glColor4f(1.0f, s, 0.0f, 0.9f); + } else { + s = MIN(1.0f, -s); + glColor4f(1.0f - s, 0.0f, s, 0.9f); + } + glVertex2f(X1 + 31.67f, Y1 + 30.0f); + glVertex2f(X1 + 35.0f, Y1 + 30.0f); + glVertex2f(X1 + 35.0f, Y1 + 30.0f+height); + glVertex2f(X1 + 31.67f, Y1 + 30.0f+height); + + s = 10.0f*(car_->_tyreT_mid(0)/car_->_tyreT_opt(0)-1.0f); + if (s >= 0.0f) { + s = MIN(1.0f, s); + glColor4f(1.0f, s, 0.0f, 0.9f); + } else { + s = MIN(1.0f, -s); + glColor4f(1.0f - s, 0.0f, s, 0.9f); + } + glVertex2f(X1 + 28.33f, Y1 + 30.0f); + glVertex2f(X1 + 31.67f, Y1 + 30.0f); + glVertex2f(X1 + 31.67f, Y1 + 30.0f+height); + glVertex2f(X1 + 28.33f, Y1 + 30.0f+height); + + s = 10.0f*(car_->_tyreT_in(0)/car_->_tyreT_opt(0)-1.0f); + if (s >= 0.0f) { + s = MIN(1.0f, s); + glColor4f(1.0f, s, 0.0f, 0.9f); + } else { + s = MIN(1.0f, -s); + glColor4f(1.0f - s, 0.0f, s, 0.9f); + } + glVertex2f(X1 + 25.0f, Y1 + 30.0f); + glVertex2f(X1 + 28.33f, Y1 + 30.0f); + glVertex2f(X1 + 28.33f, Y1 + 30.0f+height); + glVertex2f(X1 + 25.0f, Y1 + 30.0f+height); + // FL wheel s = car_->_wheelSlipNorm(1)/car_->_wheelSlipOpt(1); if (s > 1.0) { @@ -408,6 +449,47 @@ cGrBoard::grDispGGraph() glVertex2f(X1 - 40.0f, Y1 + 30.0f); glVertex2f(X1 - 40.0f, Y1 + 50.0f); glVertex2f(X1 - 50.0f, Y1 + 50.0f); + + height = 20.0f * MAX(car_->_tyreTreadDepth(1), 0.1f); + s = 10.0f*(car_->_tyreT_out(1)/car_->_tyreT_opt(1)-1.0f); + if (s >= 0.0f) { + s = MIN(1.0f, s); + glColor4f(1.0f, s, 0.0f, 0.9f); + } else { + s = MIN(1.0f, -s); + glColor4f(1.0f - s, 0.0f, s, 0.9f); + } + glVertex2f(X1 - 31.67f, Y1 + 30.0f); + glVertex2f(X1 - 35.0f, Y1 + 30.0f); + glVertex2f(X1 - 35.0f, Y1 + 30.0f+height); + glVertex2f(X1 - 31.67f, Y1 + 30.0f+height); + + s = 10.0f*(car_->_tyreT_mid(1)/car_->_tyreT_opt(1)-1.0f); + if (s >= 0.0f) { + s = MIN(1.0f, s); + glColor4f(1.0f, s, 0.0f, 0.9f); + } else { + s = MIN(1.0f, -s); + glColor4f(1.0f - s, 0.0f, s, 0.9f); + } + glVertex2f(X1 - 28.33f, Y1 + 30.0f); + glVertex2f(X1 - 31.67f, Y1 + 30.0f); + glVertex2f(X1 - 31.67f, Y1 + 30.0f+height); + glVertex2f(X1 - 28.33f, Y1 + 30.0f+height); + + s = 10.0f*(car_->_tyreT_in(1)/car_->_tyreT_opt(1)-1.0f); + if (s >= 0.0f) { + s = MIN(1.0f, s); + glColor4f(1.0f, s, 0.0f, 0.9f); + } else { + s = MIN(1.0f, -s); + glColor4f(1.0f - s, 0.0f, s, 0.9f); + } + glVertex2f(X1 - 25.0f, Y1 + 30.0f); + glVertex2f(X1 - 28.33f, Y1 + 30.0f); + glVertex2f(X1 - 28.33f, Y1 + 30.0f+height); + glVertex2f(X1 - 25.0f, Y1 + 30.0f+height); + // RR wheel s = car_->_wheelSlipNorm(2)/car_->_wheelSlipOpt(2); if (s > 1.0) { @@ -420,6 +502,47 @@ cGrBoard::grDispGGraph() glVertex2f(X1 + 50.0f, Y1 - 50.0f); glVertex2f(X1 + 50.0f, Y1 - 30.0f); glVertex2f(X1 + 40.0f, Y1 - 30.0f); + + height = 20.0f * MAX(car_->_tyreTreadDepth(2), 0.1f); + s = 10.0f*(car_->_tyreT_out(2)/car_->_tyreT_opt(2)-1.0f); + if (s >= 0.0f) { + s = MIN(1.0f, s); + glColor4f(1.0f, s, 0.0f, 0.9f); + } else { + s = MIN(1.0f, -s); + glColor4f(1.0f - s, 0.0f, s, 0.9f); + } + glVertex2f(X1 + 31.67f, Y1 - 50.0f); + glVertex2f(X1 + 35.0f, Y1 - 50.0f); + glVertex2f(X1 + 35.0f, Y1 - 50.0f+height); + glVertex2f(X1 + 31.67f, Y1 - 50.0f+height); + + s = 10.0f*(car_->_tyreT_mid(2)/car_->_tyreT_opt(2)-1.0f); + if (s >= 0.0f) { + s = MIN(1.0f, s); + glColor4f(1.0f, s, 0.0f, 0.9f); + } else { + s = MIN(1.0f, -s); + glColor4f(1.0f - s, 0.0f, s, 0.9f); + } + glVertex2f(X1 + 28.33f, Y1 - 50.0f); + glVertex2f(X1 + 31.67f, Y1 - 50.0f); + glVertex2f(X1 + 31.67f, Y1 - 50.0f+height); + glVertex2f(X1 + 28.33f, Y1 - 50.0f+height); + + s = 10.0f*(car_->_tyreT_in(2)/car_->_tyreT_opt(2)-1.0f); + if (s >= 0.0f) { + s = MIN(1.0f, s); + glColor4f(1.0f, s, 0.0f, 0.9f); + } else { + s = MIN(1.0f, -s); + glColor4f(1.0f - s, 0.0f, s, 0.9f); + } + glVertex2f(X1 + 25.0f, Y1 - 50.0f); + glVertex2f(X1 + 28.33f, Y1 - 50.0f); + glVertex2f(X1 + 28.33f, Y1 - 50.0f+height); + glVertex2f(X1 + 25.0f, Y1 - 50.0f+height); + // RL wheel s = car_->_wheelSlipNorm(3)/car_->_wheelSlipOpt(3); if (s > 1.0) { @@ -432,6 +555,46 @@ cGrBoard::grDispGGraph() glVertex2f(X1 - 40.0f, Y1 - 50.0f); glVertex2f(X1 - 40.0f, Y1 - 30.0f); glVertex2f(X1 - 50.0f, Y1 - 30.0f); + + height = 20.0f * MAX(car_->_tyreTreadDepth(3), 0.1f); + s = 10.0f*(car_->_tyreT_out(3)/car_->_tyreT_opt(3)-1.0f); + if (s >= 0.0f) { + s = MIN(1.0f, s); + glColor4f(1.0f, s, 0.0f, 0.9f); + } else { + s = MIN(1.0f, -s); + glColor4f(1.0f - s, 0.0f, s, 0.9f); + } + glVertex2f(X1 - 31.67f, Y1 - 50.0f); + glVertex2f(X1 - 35.0f, Y1 - 50.0f); + glVertex2f(X1 - 35.0f, Y1 - 50.0f+height); + glVertex2f(X1 - 31.67f, Y1 - 50.0f+height); + + s = 10.0f*(car_->_tyreT_mid(3)/car_->_tyreT_opt(3)-1.0f); + if (s >= 0.0f) { + s = MIN(1.0f, s); + glColor4f(1.0f, s, 0.0f, 0.9f); + } else { + s = MIN(1.0f, -s); + glColor4f(1.0f - s, 0.0f, s, 0.9f); + } + glVertex2f(X1 - 28.33f, Y1 - 50.0f); + glVertex2f(X1 - 31.67f, Y1 - 50.0f); + glVertex2f(X1 - 31.67f, Y1 - 50.0f+height); + glVertex2f(X1 - 28.33f, Y1 - 50.0f+height); + + s = 10.0f*(car_->_tyreT_in(3)/car_->_tyreT_opt(3)-1.0f); + if (s >= 0.0f) { + s = MIN(1.0f, s); + glColor4f(1.0f, s, 0.0f, 0.9f); + } else { + s = MIN(1.0f, -s); + glColor4f(1.0f - s, 0.0f, s, 0.9f); + } + glVertex2f(X1 - 25.0f, Y1 - 50.0f); + glVertex2f(X1 - 28.33f, Y1 - 50.0f); + glVertex2f(X1 - 28.33f, Y1 - 50.0f+height); + glVertex2f(X1 - 25.0f, Y1 - 50.0f+height); } glEnd(); diff --git a/src/modules/simu/simuv4/wheel.cpp b/src/modules/simu/simuv4/wheel.cpp index b2fc3d10d..f04e41fb0 100644 --- a/src/modules/simu/simuv4/wheel.cpp +++ b/src/modules/simu/simuv4/wheel.cpp @@ -99,12 +99,19 @@ void SimWheelConfig(tCar *car, int index) /* temperature and degradation */ wheel->Tinit = GfParmGetNum(hdle, WheelSect[index], PRM_INITTEMP, (char*)NULL, Tair); - wheel->Ttire = wheel->Tinit; wheel->treadDepth = 1.0; wheel->Topt = GfParmGetNum(hdle, WheelSect[index], PRM_OPTTEMP, (char*)NULL, 350.0f); + if (car->features & FEAT_TIRETEMPDEG) + { + wheel->Ttire = wheel->Tinit; + } + else + { + wheel->Ttire = wheel->Topt; + } tdble coldmufactor = GfParmGetNum(hdle, WheelSect[index], PRM_COLDMUFACTOR, (char*)NULL, 1.0f); coldmufactor = MIN(MAX(coldmufactor, 0.0f), 1.0f); - wheel->muTmult = (1 - coldmufactor) / ((wheel->Topt - Tair) * (wheel->Topt - Tair)); + wheel->muTmult = (1 - coldmufactor) / ((wheel->Topt - 273) * (wheel->Topt - 273)); wheel->heatingm = GfParmGetNum(hdle, WheelSect[index], PRM_HEATINGMULT, (char*)NULL, (tdble) 6e-5); wheel->aircoolm = GfParmGetNum(hdle, WheelSect[index], PRM_AIRCOOLINGMULT, (char*)NULL, (tdble) 12e-4); wheel->speedcoolm = GfParmGetNum(hdle, WheelSect[index], PRM_SPEEDCOOLINGMULT, (char*)NULL, (tdble) 0.25); @@ -136,13 +143,14 @@ void SimWheelConfig(tCar *car, int index) carElt->_brakeDiskRadius(index) = wheel->brake.radius; carElt->_wheelRadius(index) = wheel->radius; - if (car->features & FEAT_TIRETEMPDEG) - { - // Assume new wheels - carElt->_tyreCondition(index) = 1.0; - car->carElt->_tyreTreadDepth(index) = wheel->treadDepth; - car->carElt->_tyreCritTreadDepth(index) = wheel->critTreadDepth; - } + /* initialize carElt values even if tire temperature and wear feature is not enabled */ + carElt->_tyreT_opt(index) = wheel->Topt; + carElt->_tyreT_in(index) = wheel->Ttire; + carElt->_tyreT_mid(index) = wheel->Ttire; + carElt->_tyreT_out(index) = wheel->Ttire; + carElt->_tyreCondition(index) = 1.0; + carElt->_tyreTreadDepth(index) = wheel->treadDepth; + carElt->_tyreCritTreadDepth(index) = wheel->critTreadDepth; wheel->mfC = (tdble)(2.0 - asin(RFactor) * 2.0 / PI); wheel->mfB = Ca / wheel->mfC;