Fix wheel slip calculations
This commit is contained in:
parent
b01e0f461c
commit
54dde79ad8
|
|
@ -45,21 +45,21 @@ int sounddev_tyreslip_update(SimDevice* this, SimData* simdata)
|
|||
double play = 0;
|
||||
if (this->tyre == FRONTLEFT || this->tyre == FRONTS || this->tyre == ALLFOUR)
|
||||
{
|
||||
play += simdata->wheelslip[0];
|
||||
play += (1.0 - simdata->wheelslip[0]);
|
||||
}
|
||||
if (this->tyre == FRONTRIGHT || this->tyre == FRONTS || this->tyre == ALLFOUR)
|
||||
{
|
||||
play += simdata->wheelslip[1];
|
||||
play += (1.0 - simdata->wheelslip[1]);
|
||||
}
|
||||
if (this->tyre == REARLEFT || this->tyre == REARS || this->tyre == ALLFOUR)
|
||||
{
|
||||
play += simdata->wheelslip[2];
|
||||
play += (1.0 - simdata->wheelslip[2]);
|
||||
}
|
||||
if (this->tyre == REARRIGHT || this->tyre == REARS || this->tyre == ALLFOUR)
|
||||
{
|
||||
play += simdata->wheelslip[3];
|
||||
play += (1.0 - simdata->wheelslip[3]);
|
||||
}
|
||||
if (play > 0)
|
||||
if (play > .40)
|
||||
{
|
||||
sounddevice->sounddata.curr_frequency = sounddevice->sounddata.frequency * play;
|
||||
sounddevice->sounddata.curr_duration = sounddevice->sounddata.duration;
|
||||
|
|
|
|||
|
|
@ -19,19 +19,19 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
|
|||
{
|
||||
if (usbhapticdevice->tyre == FRONTLEFT || usbhapticdevice->tyre == FRONTS || usbhapticdevice->tyre == ALLFOUR)
|
||||
{
|
||||
play += simdata->wheelslip[0];
|
||||
play += (1.0 - simdata->wheelslip[0]);
|
||||
}
|
||||
if (usbhapticdevice->tyre == FRONTRIGHT || usbhapticdevice->tyre == FRONTS || usbhapticdevice->tyre == ALLFOUR)
|
||||
{
|
||||
play += simdata->wheelslip[1];
|
||||
play += (1.0 - simdata->wheelslip[1]);
|
||||
}
|
||||
if (usbhapticdevice->tyre == REARLEFT || usbhapticdevice->tyre == REARS || usbhapticdevice->tyre == ALLFOUR)
|
||||
{
|
||||
play += simdata->wheelslip[2];
|
||||
play += (1.0 - simdata->wheelslip[2]);
|
||||
}
|
||||
if (usbhapticdevice->tyre == REARRIGHT || usbhapticdevice->tyre == REARS || usbhapticdevice->tyre == ALLFOUR)
|
||||
{
|
||||
play += simdata->wheelslip[3];
|
||||
play += (1.0 - simdata->wheelslip[3]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -42,7 +42,7 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
|
|||
|
||||
if (play != usbhapticdevice->state)
|
||||
{
|
||||
if(play > 0)
|
||||
if(play > .40)
|
||||
{
|
||||
fprintf(usbhapticdevice->handle, "%i\n", usbhapticdevice->value1);
|
||||
fflush(usbhapticdevice->handle);
|
||||
|
|
|
|||
|
|
@ -324,10 +324,10 @@ int tester(SimDevice* devices, int numdevices)
|
|||
simdata->rpms = 100;
|
||||
simdata->maxrpm = 8000;
|
||||
simdata->abs = 0;
|
||||
simdata->wheelslip[0] = 0;
|
||||
simdata->wheelslip[1] = 0;
|
||||
simdata->wheelslip[2] = 0;
|
||||
simdata->wheelslip[3] = 0;
|
||||
simdata->wheelslip[0] = 1;
|
||||
simdata->wheelslip[1] = 1;
|
||||
simdata->wheelslip[2] = 1;
|
||||
simdata->wheelslip[3] = 1;
|
||||
sleep(3);
|
||||
|
||||
fprintf(stdout, "Setting rpms to 1000\n");
|
||||
|
|
@ -347,20 +347,20 @@ int tester(SimDevice* devices, int numdevices)
|
|||
sleep(3);
|
||||
simdata->abs = 0;
|
||||
|
||||
fprintf(stdout, "Setting Wheelslip to 1\n");
|
||||
simdata->wheelslip[0] = 1;
|
||||
simdata->wheelslip[1] = 1;
|
||||
simdata->wheelslip[2] = 1;
|
||||
simdata->wheelslip[3] = 1;
|
||||
fprintf(stdout, "Setting Wheelslip to 0, no traction\n");
|
||||
simdata->wheelslip[0] = 0;
|
||||
simdata->wheelslip[1] = 0;
|
||||
simdata->wheelslip[2] = 0;
|
||||
simdata->wheelslip[3] = 0;
|
||||
for (int x = 0; x < numdevices; x++)
|
||||
{
|
||||
devices[x].update(&devices[x], simdata);
|
||||
}
|
||||
sleep(3);
|
||||
simdata->wheelslip[0] = 0;
|
||||
simdata->wheelslip[1] = 0;
|
||||
simdata->wheelslip[2] = 0;
|
||||
simdata->wheelslip[3] = 0;
|
||||
simdata->wheelslip[0] = 1;
|
||||
simdata->wheelslip[1] = 1;
|
||||
simdata->wheelslip[2] = 1;
|
||||
simdata->wheelslip[3] = 1;
|
||||
|
||||
fprintf(stdout, "Shifting into first gear\n");
|
||||
simdata->gear = 2;
|
||||
|
|
|
|||
Loading…
Reference in New Issue