forked from speed-dreams/speed-dreams-code
Re #172: calculate torque for force feedback in simuv4
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6408 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 21396fe2876b12b315df7d62e0c0ddd08918047d Former-commit-id: 38da0a36af94f235b9e62bafb40fc6dabbb74818
This commit is contained in:
parent
29564c2b19
commit
edd58d709b
4 changed files with 20 additions and 4 deletions
|
@ -432,7 +432,8 @@ typedef struct
|
|||
tCollisionState collision_state; /**< collision state ; Simu V3 only */
|
||||
tMemPoolCar memoryPool;
|
||||
tdble driveSkill; /**< Skill level for robots: 0.0 means as fast as possible; 10.0 means at a slower speed so players can easier win */
|
||||
tdble steerTq; /**< torque on steering wheel for force feedback */
|
||||
tdble steerTqCenter; /**< torques on steering wheel for force feedback, this is the centering torque, linear with steering angle */
|
||||
tdble steerTqAlign; /**< force feedback torque: tire aligning torque from magic formula */
|
||||
tDashboardItem dashboardInstant[NR_DI_INSTANT];
|
||||
int dashboardInstantNb; /* number and list of immediately changing items in dashboard */
|
||||
tDashboardItem dashboardRequest[NR_DI_REQUEST];
|
||||
|
@ -470,7 +471,9 @@ typedef struct
|
|||
#define _smoke priv.smoke
|
||||
#define _normal priv.normal
|
||||
#define _coll2Pos priv.collpos
|
||||
#define _steerTq priv.steerTq
|
||||
|
||||
#define _steerTqCenter priv.steerTqCenter
|
||||
#define _steerTqAlign priv.steerTqAlign
|
||||
|
||||
#define _newTrackMemPool priv.memoryPool.newTrack
|
||||
#define _newRaceMemPool priv.memoryPool.newRace
|
||||
|
|
|
@ -546,7 +546,9 @@ SimUpdate(tSituation *s, double deltaTime)
|
|||
carElt->_fuel = car->fuel;
|
||||
carElt->priv.collision |= car->collision;
|
||||
carElt->_dammage = car->dammage;
|
||||
carElt->_steerTq = -car->ctrl->steer; /*TODO: torque from Pacejka*/
|
||||
carElt->_steerTqCenter = -car->ctrl->steer;
|
||||
carElt->_steerTqAlign = car->wheel[FRNT_RGT].torqueAlign + car->wheel[FRNT_LFT].torqueAlign;
|
||||
printf("Center=%g Align=%g\n",carElt->_steerTqCenter,carElt->_steerTqAlign);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -671,6 +673,8 @@ SimUpdateSingleCar(int index, double deltaTime,tSituation *s)
|
|||
carElt->_fuel = car->fuel;
|
||||
carElt->priv.collision |= car->collision;
|
||||
carElt->_dammage = car->dammage;
|
||||
carElt->_steerTq = -car->ctrl->steer; /*TODO: torque from Pacejka*/
|
||||
carElt->_steerTqCenter = -car->ctrl->steer;
|
||||
carElt->_steerTqAlign = car->wheel[FRNT_RGT].torqueAlign + car->wheel[FRNT_LFT].torqueAlign;
|
||||
printf("Center=%g Align=%g\n",carElt->_steerTqCenter,carElt->_steerTqAlign);
|
||||
}
|
||||
|
||||
|
|
|
@ -408,6 +408,14 @@ void SimWheelUpdateForce(tCar *car, int index)
|
|||
}
|
||||
|
||||
F *= wheel->forces.z * mu * wheel->trkPos.seg->surface->kFriction; /* coeff */
|
||||
|
||||
/* force feedback torque */
|
||||
if (s > 0.000001f) {
|
||||
//version A: same magic formula as or force
|
||||
//wheel->torqueAlign = 0.025 * F * sy / (s * (1.0f + stmp * simSkidFactor[car->carElt->_skillLevel]));
|
||||
//version B: quicker torque decrease by setting mfE = 0 for torque
|
||||
wheel->torqueAlign = 0.025 * wheel->forces.z * mu * wheel->trkPos.seg->surface->kFriction * sin(wheel->mfC * atan(Bx )) * sy / s;
|
||||
} else wheel->torqueAlign = 0.0f;
|
||||
|
||||
// For debugging weather simultation on some tracks
|
||||
#ifdef SD_DEBUG
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef struct
|
|||
/* dynamic */
|
||||
t3Dd forces; /* forces acting on car */
|
||||
t3Dd torques; /* torques acting on car (gyroscopic forces) */
|
||||
tdble torqueAlign; /* torque for force feedback from magic formula */
|
||||
tdble rollRes; /* Rolling Resistance (summed over the car) */
|
||||
tdble rideHeight; /* height of the bottom of the car */
|
||||
tdble zRoad; /* z of the road */
|
||||
|
|
Loading…
Reference in a new issue