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

USARBot.RangeScanner


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
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
class RangeScanner extends RangeSensor config (USARBot);

var config float ScanInterval;
var config float Resolution;
var config float ScanFov;
var config bool bYaw;
var config bool bPitch;

var int uuResolution, uuScanFov;

var string rangeData;
var float time;
var USARRemoteBot rBot;

simulated function PostNetBeginPlay()
{
    Super.PostNetBeginPlay();
    rangeData="";
    if (ScanInterval>=0.1)
        SetTimer(ScanInterval,true);
}

function ConvertParam(USARConverter converter)
{
    super.ConvertParam(converter);

    if (converter!=None) {
        uuResolution = converter.AngleToUU(Resolution);
        uuScanFov = converter.AngleToUU(ScanFov);
    } else {
        uuResolution = Resolution;
        uuScanFov = ScanFov;
    }
}

function timer()
{
    local int i;
    local float range;
    local rotator turn;

    time = Level.TimeSeconds;
    rangeData="";
    //from right to left
    for (i=uuScanFov/2;i>-uuScanFov/2;i-=uuResolution)
    {
        if (bYaw)
            turn.Yaw = i;
        if (bPitch)
            turn.Pitch = i;
        curRot = rTurn(Rotation,turn);
        range = GetRange();
        if (rangeData == "") rangeData = converter.FloatString(range);
        else rangeData = rangeData$","$converter.FloatString(range);
        //log("i="$i@"rot="$rot@"Rotation="$Rotation@"range="$range);
    }
}

function rotator rTurn(rotator rHeading,rotator rTurnAngle)
{
    // Generate a turn in object coordinates
    //     this should handle any gymbal lock issues

    local vector vForward,vRight,vUpward;
    local vector vForward2,vRight2,vUpward2;
    local rotator T;
    local vector  V;

    GetAxes(rHeading,vForward,vRight,vUpward);
    //  rotate in plane that contains vForward&vRight
    T.Yaw=rTurnAngle.Yaw; V=vector(T);
    vForward2=V.X*vForward + V.Y*vRight;
    vRight2=V.X*vRight - V.Y*vForward;
    vUpward2=vUpward;

    // rotate in plane that contains vForward&vUpward
    T.Yaw=rTurnAngle.Pitch; V=vector(T);
    vForward=V.X*vForward2 + V.Y*vUpward2;
    vRight=vRight2;
    vUpward=V.X*vUpward2 - V.Y*vForward2;

    // rotate in plane that contains vUpward&vRight
    T.Yaw=rTurnAngle.Roll; V=vector(T);
    vForward2=vForward;
    vRight2=V.X*vRight + V.Y*vUpward;
    vUpward2=V.X*vUpward - V.Y*vRight;

    T=OrthoRotation(vForward2,vRight2,vUpward2);

   return(T);
}

function string Set(String opcode, String args)
{
    if (Caps(opcode)=="SCAN") {
        timer();
        return "OK";
    }
    return "Failed";
}

function String GetHead()
{
    local string outstring;

    if (bWithTimeStamp)
        outstring="SEN {Time "$time$"} {Type "$ItemType$"}";
    else
        outstring="SEN {Type "$ItemType$"}";

    return outstring;
}
function String GetData()
{
    local string outstring;

    if (rangeData == "") return "";

    outstring =  "{Name "$ItemName$"} "
                //$"{Time "$time$"} "
                //$"{Location "$Location$"} "
                //$"{Rotation "$(base.Rotation + myDirection)$"} "
                $"{Resolution "$converter.FloatString(Resolution)$"} "
                $"{FOV "$converter.FloatString(ScanFov)$"} "
                $"{Range "$rangeData$"}";
    rangeData = "";

    return outstring;
}

function String GetConfData()
{
    local string outstring;
    outstring = Super.GetConfData();
    outstring = outstring@"{Resolution "$converter.FloatString(Resolution)$"} {Fov "$converter.FloatString(ScanFov)$"}";
    outstring = outstring@"{Paning "$bYaw$"} {Tilting "$bPitch$"}";
    return outstring;
}

defaultproperties
{
//Scaled with 4.762 at Mon Sep 25 14:21:52 EDT 2006
    bHardAttach=true
    ItemType="RangeScanner"
    MaxRange=3
    MinRange=0.1
    ScanInterval=0.0
    Resolution=0.087 // 5 deg
    ScanFov=3.14
    bYaw=false
    bPitch=false
    OutputCurve=(Points=((InVal=0,OutVal=0),(InVal=1000,OutVal=1000)))
    drawscale=0.4762
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 26.9.2006 17:52:34.000 - Creation time: Mo 16.4.2007 11:20:52.656 - Created with UnCodeX