# Calculate to prevent a vehicle to start on higher gears

## Calculate to prevent a vehicle to start on higher gears

I have put in a manual transmission, which works fine.(if anyone wants to know how, read this thread:http://software.intel.com/en-us/forums/showthread.php?t=68202&o=a&s=lr)

All works fine and well when gearing up, but the problem I have, is that I can start from 0 and going to full speed without any problems on all gears. Normally you wouldnt be able to start from zero in gears higher than 2nd gear, and I cant wrap my head around how to fix this.

I havent found any good calculation or sollution for this on this forum, or in the user guide. So I was wondering if there is a good sollution for preventing to accelerate from zero on higher gears? Should it be a calculation on the TransmissionOutput::m_wheelsTransmittedTorque array, or should I calculate it in another way?

[EDIT] - Ive put in some example code of how I do it, it might be easier for everyone to understand my problem.

Here I do the normal calculations for the transmission:
```hkBool IsRev = pTransmission->calcIsReversing(vehicle, TransmissionOutputOut);
TransmissionOutputOut.m_isReversing = IsRev;
hkReal TransTorque = pTransmission->calcMainTransmittedTorque(vehicle, TransmissionOutputOut);
hkReal Rpm = pTransmission->calcTransmissionRPM(vehicle, TransmissionOutputOut);

TransmissionOutputOut.m_mainTransmittedTorque	= TransTorque;
TransmissionOutputOut.m_transmissionRPM			= Rpm;
for(int i = 0; i < pTransmission->m_wheelsTorqueRatio.getSize(); i++)
{
TransmissionOutputOut.m_wheelsTransmittedTorque[i] = TransTorque * pTransmission->m_wheelsTorqueRatio[i];
}

```

Now, here I check if I should go up a gear, or down a gear. Both are similar, so I will only display the GearUp event. Its here I suspect Im doing something wrong.I set the transmission RPM to the upshiftRPM, so the engine will know its time to go to next gear.

```TransmissionOutputOut.m_transmissionRPM = pTransmission->m_upshiftRPM;
TransmissionOutputOut.m_currentGear++;
pTransmission->updateCurrentGear(deltaTime, vehicle, TransmissionOutputOut);```

3 posts / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.

Hey codemastermike,

As mentioned in the other thread, our standard automatic transmission updates backwards from using wheel speed/RPM to compute transmission speed, to update the current gear, to compute the engine RPM (and ensure it's within min/max ranges), to compute engine torque, and to finally applying that torque to push the chassis forward. By having a manual transmission, you must have your own logic for updating the current gear, and part of that will need to determine when a gear request is not viable and handle it appropriately by overriding/killing engine torque until a valid gear is chosen.

As you mentioned, you can probably accomplish this by setting m_wheelsTransmittedTorque to 0 for all wheels, but I'd also suggest doing this higher-up in the vehicle system... by directly killing engine torque as well.

I'd recommend determining a bad gear request by calling hkpVehicleDefaultTransmission::calcTransmissionRPM after updating the current gear. This should give you the transmission-driven engine RPM value, which you can verify as being valid if it is between hkpVehicleDefaultEngine::m_minRPM/m_maxRPM. If engine RPM is not within this range, you should ensure that engine torque (hkpVehicleInstance::m_torque) is 0 before the next vehicle step (and keep torque at 0 as long as the gear is invalid).

Chris

Developer Support Engineer
Havok
www.havok.com