Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

USARBot.KSCarWheelJoint


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
/* The Safe KCarWheelJoint 
 * When the constraint force is larger than KForceThreshold,
 * we remove the motor's torque and apply a brake torgue to
 * the joint.
 * 
 * Author: Jijun Wang
 */
class KSCarWheelJoint extends KCarWheelJoint;
var float StallTime;
var float StallTimeLeft;
var float oldTorque;
var bool bNeedRestore;

simulated function Tick(float delta) {
    //local vector Force;
    
    //KGetConstraintForce(Force);
    //log("force:"@VSize(Force)/50);
    if (StallTimeLeft>0)
        StallTimeLeft -= delta;
    else if (bNeedRestore) {
            KMotorTorque = oldTorque;
            bNeedRestore = false;
    }
}

event KForceExceed(float forceMag) {
    log("ForceExceed"@forceMag);
    if (StallTimeLeft<=0) {
        oldTorque = KMotorTorque;
        bNeedRestore = true;
    }
    StallTimeLeft = StallTime;
    KMotorTorque = KMotorTorque/2;
    KBraking = oldTorque/2;
}

defaultproperties {
    KForceThreshold=200
    StallTime=1.0
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Do 1.6.2006 05:48:50.000 - Creation time: Mo 16.4.2007 11:20:49.250 - Created with UnCodeX