Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
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 00156 00157 00158 00159 00160 00161 00162 |
// =============================================================== // USARBot.RFIDSensor // // This class simulates the RFID reader. It iterates all the // registered RFID tags and reports the tags that are within the // detecting range. Single transmission is applied in tag info // transfer. // // Original created by: Alexander Kleiner and Christian // Modified by: Jijun Wang -- 12/15/2005 // Mentar Mahmudi - IUB - m.mahmudi@iu-bremen.de -- 14/02/2006 // =============================================================== class RFIDSensor extends sensor config(USARBot); var config float MaxRange; var config float MaxSingleShotRange; var config float TagNoise; var float uuMaxRangeSquare; var float uuMaxSingleShotRangeSquare; var array<int> detectedTags; function ConvertParam(USARConverter converter) { if (converter != None) { uuMaxRangeSquare = converter.LengthToUU(MaxRange) * converter.LengthToUU(MaxRange); uuMaxSingleShotRangeSquare = converter.LengthToUU(MaxSingleShotRange) * converter.LengthToUU(MaxSingleShotRange); } else { uuMaxRangeSquare = MaxRange*MaxRange; uuMaxSingleShotRangeSquare = MaxSingleShotRange*MaxSingleShotRange; } } function int getDetectedTag(int idx) { local int i; for (i = 0; i < detectedTags.length; i++) { if (detectedTags[i] == idx) return i; } return -1; } function float VectLenSq(vector v) { return v.x * v.x + v.y * v.y + v.z * v.z; } function String GetData() { local string Outstring; local int i, idx; local vector diff, pos; local array<RFIDTag> tags; Outstring=""; tags = USARDeathMatch(Level.Game).RFIDTags; //Prints the position of the tag(s) in terms of the coordinate system with //the robot tag sensor being at the origin. for (i = 0; i < tags.length; i++) { diff = tags[i].Location - Location; if ( ( (VectLenSq(diff) < uuMaxRangeSquare) && ( !tags[i].bSingleShot ) ) || ( (VectLenSq(diff) < uuMaxSingleShotRangeSquare) && ( tags[i].bSingleShot ) ) ) { //if (!tags[i].bSingleShot || getDetectedTag(i) == -1) { if (getDetectedTag(i) == -1) { Outstring = Outstring$" {ID "$tags[i].id$"}"; pos = tag_pos(tags[i]); Outstring = Outstring$" {Location "$converter.VectorString(pos, 2)$"}"; if (tags[i].bSingleShot) { detectedTags.Insert(detectedTags.length, 1); detectedTags[detectedTags.length - 1] = i; } } } else if (!tags[i].bSingleShot) { idx = getDetectedTag(i); if (idx >= 0) detectedTags.Remove(idx, 1); } } if (Outstring!="") Outstring = "{Name "$ItemName$"}"$OutString; //if (Outstring!="") log(Outstring); return Outstring; } function vector tag_pos(RFIDTag aTag) { local vector tag_pos, robot_pos, VX, VY, VZ, tmp, pos; local Rotator robot_rot; local Matrix T; local Plane PX, PY, PZ, PW; tag_pos = aTag.Location; robot_pos = Location; robot_rot = Rotation; // calculating the position of the tag GetUnAxes (robot_rot, VX, VY, VZ); PX.x = VX.x; PX.y = VX.y; PX.z = VX.z; PX.W = 0; PY.x = VY.x; PY.y = VY.y; PY.z = VY.z; PY.W = 0; PZ.x = VZ.x; PZ.y = VZ.y; PZ.z = VZ.z; PZ.W = 0; tmp.x = VX.x; tmp.y = VY.x; tmp.z = VZ.x; PW.x = - ( tmp Dot robot_pos ); tmp.x = VX.y; tmp.y = VY.y; tmp.z = VZ.y; PW.y = - ( tmp Dot robot_pos); tmp.x = VX.z; tmp.y = VY.z; tmp.z = VZ.z; PW.z = - ( tmp Dot robot_pos); PW.W = 1; T.XPlane = PX; T.YPlane = PY; T.ZPlane = PZ; T.WPlane = PW; //use converter here pos.x = converter.LengthFromUU(T.XPlane.X * tag_pos.x + T.YPlane.x * tag_pos.y + T.zplane.x * tag_pos.z + T.wplane.x); pos.y = converter.LengthFromUU(T.XPlane.Y * tag_pos.x + T.YPlane.Y * tag_pos.y + T.zplane.Y * tag_pos.z + T.wplane.Y); pos.z = converter.LengthFromUU(-(T.XPlane.Z * tag_pos.x + T.YPlane.Z * tag_pos.y + T.zplane.Z * tag_pos.z + T.wplane.Z)); if ( ! aTag.bSingleShot ) { pos.x += RandRange(-TagNoise, TagNoise); pos.y += RandRange(-TagNoise, TagNoise); pos.z += RandRange(-TagNoise, TagNoise); } return pos; //yaw = robot_rot.yaw*2*Pi/65536; //the calculation is correct. //x = ((tag_pos.x - robot_pos.x) * cos(yaw) + (tag_pos.y - robot_pos.y) * sin(yaw))/52.5; //y = (-(tag_pos.x - robot_pos.x) * sin(yaw) + (tag_pos.y - robot_pos.y) * cos(yaw))/52.5; } function String GetConfData() { local string outstring; outstring = Super.GetConfData(); outstring = outstring@"{MaxRange "$MaxRange$"}"; return outstring; } defaultproperties { //Scaled with 4.762 at Mon Sep 25 14:21:52 EDT 2006 MaxRange=2 MaxSingleShotRange=6 ItemType="RFID" TagNoise=0.6 drawscale=0.4762 } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |