Home > scans > generate > makeCrossScan.m

makeCrossScan

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function makeCrossScan(azrange, elrange, scanParams, outfile)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  function makeScan(azrange, elval, scanParams, outFile)

    azrange is range of full scan in degrees ([minaz, maxaz]);
    elrange is range of full el scan in degrees ([minel maxel]);
    scanParams = [azVelocity, azAcc, elVel, elAcc];
       where azVelocity is the velocity during the scan
             maxAccel is the maximum allowed acceleration

    outFile is scan file name.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function makeCrossScan(azrange, elrange, scanParams, outfile)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 %  function makeScan(azrange, elval, scanParams, outFile)
0006 %
0007 %    azrange is range of full scan in degrees ([minaz, maxaz]);
0008 %    elrange is range of full el scan in degrees ([minel maxel]);
0009 %    scanParams = [azVelocity, azAcc, elVel, elAcc];
0010 %       where azVelocity is the velocity during the scan
0011 %             maxAccel is the maximum allowed acceleration
0012 %
0013 %    outFile is scan file name.
0014 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0015 
0016 % define some things:
0017 azVel = scanParams(1);
0018 azAcc = scanParams(2);
0019 elVel = scanParams(3);
0020 elAcc = scanParams(4);
0021 
0022 % first let's figure out how long it takes for each turnaround.
0023 turnTimeAz = abs(azVel/azAcc);
0024 % just to be safe, let's multiply it by 50%
0025 turnTimeAz = ceil(turnTimeAz*1.5);
0026 
0027 % first the startup:
0028 azStart(1) = 0;
0029 azVels(1) = 0;
0030 for m=1:turnTimeAz
0031   prevAz = azStart(m);
0032   newVel = azVels(m) + azAcc;
0033   if(newVel> azVel)
0034     newVel = azVel;
0035   end
0036   newAz = prevAz + newVel;  % since we get a loc every second, this is easy
0037   
0038   azStart = [azStart; newAz];
0039   azVels = [azVels; newVel];
0040 end
0041 azStart = azStart - max(azStart) + azrange(1);
0042 % allow at least 5 seconds to get there.
0043 toGetThere = ones(15,1)*azStart(1);
0044 
0045 % now we apply the body to the scan.
0046 azBody = azrange(1):azVel:azrange(2);
0047 % first entry is repeated in last entry of start:
0048 % last entry repeated in first of stop
0049 azBody(1) = [];
0050 azBody(length(azBody)) = [];
0051 azBody = azBody';
0052 
0053 % now we stop.
0054 azStop(1) = azrange(2);
0055 for m=1:turnTimeAz
0056   prevAz = azStop(m);
0057   newAz = prevAz + azVels(length(azVels)-m+1);
0058   
0059   azStop = [azStop; newAz];
0060 end
0061 
0062 stopTime = length(azStop)-1;
0063 
0064 % now we combine them all:
0065 azValsPlus = [azStart; azBody; azStop];
0066 
0067 % add the going back to center
0068 backSlow = reverseVector(azStart) - min(azValsPlus);
0069 toCenter = min(azStop)-azVel:-azVel:max(backSlow);
0070 azValsBack = [reverseVector(azStop); toCenter'; backSlow];
0071 
0072 azVals  = [toGetThere; azValsPlus; azValsBack];
0073 
0074 
0075 % now do the same for the elevation
0076 % first let's figure out how long it takes for each turnaround.
0077 turnTimeEl = abs(elVel/elAcc);
0078 % just to be safe, let's multiply it by 50%
0079 turnTimeEl = ceil(turnTimeEl*1.5);
0080 
0081 % first the startup:
0082 elStart(1) = 0;
0083 elVels(1) = 0;
0084 for m=1:turnTimeEl
0085   prevEl = elStart(m);
0086   newVel = elVels(m) + elAcc;
0087   if(newVel> elVel)
0088     newVel = elVel;
0089   end
0090   newEl = prevEl + newVel;  % since we get a loc every second, this is easy
0091   
0092   elStart = [elStart; newEl];
0093   elVels = [elVels; newVel];
0094 end
0095 elStart = elStart - max(elStart) + elrange(1);
0096 % allow at least 5 seconds to get there.
0097 toGetThere = ones(15,1)*elStart(1);
0098 
0099 % now we apply the body to the scan.
0100 elBody = elrange(1):elVel:elrange(2);
0101 % first entry is repeated in last entry of start:
0102 % last entry repeated in first of stop
0103 elBody(1) = [];
0104 elBody(length(elBody)) = [];
0105 elBody = elBody';
0106 
0107 % now we stop.
0108 elStop(1) = elrange(2);
0109 for m=1:turnTimeEl
0110   prevEl = elStop(m);
0111   newEl = prevEl + elVels(length(elVels)-m+1);
0112   
0113   elStop = [elStop; newEl];
0114 end
0115 
0116 stopTime = length(elStop)-1;
0117 
0118 % now we combine them all:
0119 elValsPlus = [elStart; elBody; elStop];
0120 
0121 % add the going back to center
0122 backSlow = reverseVector(elStart) - min(elValsPlus);
0123 toCenter = min(elStop)-elVel:-elVel:max(backSlow);
0124 elValsBack = [reverseVector(elStop); toCenter'; backSlow];
0125 
0126 elVals  = [toGetThere; elValsPlus; elValsBack];
0127 
0128 % now we combine the two.
0129 azValsFin = [azVals; zeros(size(elVals))];
0130 elValsFin = [zeros(size(azVals)); elVals];
0131 
0132 daVals = zeros(size(elValsFin));
0133 
0134 index = 0:1:(length(azValsFin)-1);
0135 
0136 % now we make the file:
0137 fid = fopen(outfile, 'w');
0138 fprintf(fid, 'MSPERSAMPLE 1000\n');
0139 for m=1:length(index)
0140   fprintf(fid, '%d \t %3.8f \t %3.3f \t 0\n', index(m), azValsFin(m), elValsFin(m));
0141 end
0142 fclose(fid);
0143 
0144 
0145 return;
0146 
0147 
0148 
0149 function revVec = reverseVector(vec)
0150 
0151 revVec = zeros(size(vec));
0152 
0153 for m=1:length(vec)
0154   revVec(m) = vec(length(vec)-m+1);
0155 end
0156 
0157 return;

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005