Drive and Brake

magura

26-04-2006 04:38:56

Hey, I'm unable to get appropriate acceleration and deceleration.

The Simulation im working on is for a mobility scooter, which are limited to 10km/h, and I have set the gearbox pretty faithfully i think. Its an electric motor and I think they're pretty much on/off throttle


void CGameObjectScooter::InitMotor()
{
/*
Initialise the scooter's motor - The nxOgre motor class is designed around a traditional
gearbox/engine, but we are setting it up for a more digital/electrical motor as in a
mobility scooter
*/

// Construct the torque curve
m_nxoVehicle->mMotor->_torqueCurve.insert(0, 0);
m_nxoVehicle->mMotor->_torqueCurve.insert(1, 500); // 1 Gear setting at 500rpm - an estimate

// The rev limits - we want these close together as we want on/off throttle control.
m_nxoVehicle->mMotor->_minRpm = 450.0f;
m_nxoVehicle->mMotor->_maxRpm = 500.f; // A slight curve - barest acceleration.

// Differential Ratio is the size of the main cog in the gearbox compared to the gears.
m_nxoVehicle->_differentialRatio = 1;

m_nxoVehicle->_transmissionEfficiency = 1.0f;

m_nxoVehicle->mGear[0] = 2; // Gear cog is half as big as the main cog.
m_nxoVehicle->mGearCount = 1;
m_nxoVehicle->mReverseGear = -2;

m_nxoVehicle->_maxVelocity = 10;
}

Honestly, acceleration/speed seems fine, though it seems rev limited, and the top speed flag doesnt seem to do much.

My real problem is in braking - whether I roll to a stop, or apply the brakes, it slows down at the same rate almost.

// We process explicit braking first because it brakes harder than just "letting go"
// Explicit braking
if (m_inputreader->isKeyDown(KC_DOWN))
{
m_objScooter->GetVehicle()->drive(0, 1);
}

if (m_inputreader->isKeyDown(KC_UP))
{
m_objScooter->GetVehicle()->mCurrentGear = 0;
m_objScooter->GetVehicle()->drive(1, 0);
}
else
{
// Implicit braking
m_objScooter->GetVehicle()->drive(0, 0.5);
}

// Reverse
if (m_inputreader->isKeyDown(KC_R))
{
m_objScooter->GetVehicle()->drive(-1, 0);
}

Again, it does stop, but not quickly heh.

I suspect it may be something to do with global and/or tyre friction? I have set the default material to 1 in both dynamic and static friction, though tbh im not sure exactly which one applies here, as it's between a dynamic body(the wheel) and a static body(the world mesh).

Any suggestions?

Cheers, Geoff

betajaen

26-04-2006 10:44:58

Perhaps you could cheat and increase the brake power by 10 fold.

I don't think to much friction would make much of a difference, but I know it's either static or dynamic, you can increase the friction above 1. So make it 20 or 30 and see what happens.

However as I hate to admit it the NxOgre vehicle prefab is very buggy at the moment, so I'm surprised you've got it working this far. Kudos! :D

magura

27-04-2006 06:55:51

heh yeh ive tried both of those while trying to suss it out, neither increasing the friction or increasing breaking power gets it slowing down properly.

I'm having a look through nxogre source currently so see if i can work it out myself but any ideas that I can try? If i forgot to mention im still using preview 2.0 btw as I'm pretty hesitant to swap over to the new Ogre hehe.

I dont have a working vehicle sample currently (as I've modified some of the nxogre vehicle functions - added additional parameters to functions, etc), but does the sample vehicle have this issue of no brakes?

cheers again betajaen

magura

27-04-2006 08:16:46

hmm well i tried changing the factor the breakpedal is multiplied by in the simulate source(originally 750) to 2750, and it was a drastic change in brakes heh - worked too heavily.

Set it back to 750, changed the numbers i was using for the break pedal to 2 instead of 1. works like a dream :)

Now i just have to stop a vehicle that ISNT under player control from rolling infinitely. Friction doesn't seem to be doing it.

betajaen

27-04-2006 09:43:35

Ahh good. :D

Bizzarly how it sounds Friction doesn't do a whole lot when it comes to largish things like your scooter , so what I'd do is increase the dampening (linear and angular) of wheels and the scooter and fiddle around with that.

I do recommend you upgrade to the CVS though, but it does require upgrading to the latest PhysX (which is untested). There are a few bugs (including a massive memory leak) that have been fixed, but it's up to you.

Enjoy!