2 Created on Feb 17, 2017 11 import pylib.ISToolsDataSorted
as itd
12 import subprocess
as subprocess
16 from scipy.interpolate
import interp1d
29 a = math.sin(dLat/2)*math.sin(dLat/2) + math.cos(lat1) * math.cos(lat2) * math.sin(dLon/2) * math.sin(dLon/2)
30 c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
37 for dev
in log.devices:
38 if 'debugArray' in dev.data.keys()
and 'GPS1Raw' in dev.data.keys():
39 dbg = dev.data[
'debugArray'][
'i']
40 counts = dev.data[
'GPS1Raw'][
'count'][dev.data[
'GPS1Raw'][
'type'] == 1]
41 total_obs_in_log=np.sum(counts)
42 obs_at_start = dbg[0,:]
43 obs_at_end = dbg[-1, :]
44 print(
"===================== Raw GPS Message Statistics ======================")
45 print(
"uINS - %d", dev.serialNumber)
46 print(
"recorded observations: %d, " % total_obs_in_log)
47 print(
"observations reported by firmware %d, " % obs_at_end[3])
54 for dIndex
in range(0,len(ins.v[
'euler'])):
56 prevHeading = ins.v[
'euler'][0][2]
57 newData.append(ins.v[
'euler'][0][2])
59 currHeading = ins.v[
'euler'][dIndex][2]
60 if prevHeading - currHeading > np.pi:
62 elif prevHeading - currHeading < -np.pi:
64 prevHeading = currHeading
65 newData.append((currHeading + offset*2*np.pi))
69 for dIndex
in range(0,len(ins.v[
'euler'])):
70 ins.v[
'euler'][dIndex][2] = newData[dIndex]
76 for n
in range(0,len(time)):
77 if time[n] >
max(tow):
79 elif time[n] < min(tow):
82 newDataSet = np.zeros((len(time),3),dtype=np.float32)
83 for sIndex
in range(0,3):
84 newData = np.zeros((len(time)),dtype=np.float32)
85 oldData = np.zeros((len(tow)),dtype=np.float32)
86 for dIndex
in range(0,len(tow)):
87 oldData[dIndex] = dataSet[dIndex][sIndex]
89 f = interp1d(tow,oldData,kind=
'cubic')
92 for n
in range(0,len(time)):
93 newDataSet[n][sIndex] = newData[n]
98 numDev = len(log.devices)
102 print(
"\nComputing RMS Accuracies: (%d devices)" % (numDev))
108 States = [
'uvw',
'lla',
'euler']
110 for index
in range(0,numDev):
111 ins.append(itd.cINS(log.devices[index].data[
'ins2']))
117 unwrappedHeading = {}
118 for devIndex
in range(0,numDev):
122 for dIndex
in range(0,len(ins[devIndex].v[
'euler'])):
123 headingData.append(ins[devIndex].v[
'euler'][dIndex][2])
124 time.append(ins[devIndex].v[
'tow'][dIndex])
125 plt.plot(time, headingData)
130 nPts = len(ins[0].v[
'tow'])
131 time = np.zeros((nPts,1),dtype=np.float32)
132 for n
in range(0,nPts):
133 time[n] = ins[0].v[
'tow'][n]
136 totalRebaselines = 3*numDev
138 for stateSet
in States:
139 for devIndex
in range(0,numDev):
141 insA[devIndex][stateSet] =
shiftTime(ins[devIndex].v[
'tow'],ins[devIndex].v[stateSet],time)
143 print(
"Rebaselining - %d of %d" % (rebaseline,totalRebaselines) )
146 cumulativeValues = {}
152 for stateSet
in States:
155 cumulativeValues[stateSet] = [[0.0
for x
in range(3)]
for y
in range(len(insA[0][stateSet]))]
156 for devIndex
in range(0,numDev):
157 for sIndex
in range(0,3):
158 for dIndex
in range(0,len(insA[0][stateSet])):
159 cumulativeValues[stateSet][dIndex][sIndex] += insA[devIndex][stateSet][dIndex][sIndex]
161 averageValues[stateSet] = [[0
for x
in range(3)]
for y
in range(len(insA[0][stateSet]))]
162 for sIndex
in range(0,3):
163 for dIndex
in range(0,len(insA[0][stateSet])):
164 averageValues[stateSet][dIndex][sIndex] = cumulativeValues[stateSet][dIndex][sIndex] / numDev
167 bias[stateSet] = [[0
for x
in range(3)]
for y
in range(numDev)]
168 if 'euler' in stateSet:
169 for devIndex
in range(0,numDev):
170 for sIndex
in range(0,3):
171 n = len(insA[0][stateSet])
173 for dIndex
in range(int(n/2),n-1):
174 cumError += averageValues[stateSet][dIndex][sIndex] - insA[devIndex][stateSet][dIndex][sIndex]
175 bias[stateSet][devIndex][sIndex] = cumError/(n/2-1)
178 se[stateSet] = [[[0
for x
in range(3)]
for y
in range(len(insA[0][stateSet]))]
for z
in range(numDev)]
179 for devIndex
in range(0,numDev):
180 for sIndex
in range(0,3):
181 for dIndex
in range(0,len(insA[0][stateSet])):
182 se[stateSet][devIndex][dIndex][sIndex] = pow(averageValues[stateSet][dIndex][sIndex] - insA[devIndex][stateSet][dIndex][sIndex] - bias[stateSet][devIndex][sIndex],2)
185 deviceRMS[stateSet] = [[0
for x
in range(3)]
for y
in range(numDev)]
186 for devIndex
in range(0,numDev):
187 for sIndex
in range(0,3):
188 n = len(se[stateSet][devIndex])
191 for dIndex
in range(int(n/2),n-1):
192 cumValue += se[stateSet][devIndex][dIndex][sIndex]
193 deviceRMS[stateSet][devIndex][sIndex] = math.sqrt(cumValue/(n/2-1))
196 averageRMS[stateSet] = [0
for x
in range(3)]
197 for sIndex
in range(0,3):
199 for devIndex
in range(0,numDev):
200 cumValue += deviceRMS[stateSet][devIndex][sIndex]
201 averageRMS[stateSet][sIndex]=cumValue/numDev
204 average = np.zeros(shape=(len(insA[0][stateSet]),1))
205 for dIndex
in range(0,len(insA[0][stateSet])):
206 average[dIndex] = averageValues[
'euler'][dIndex][2]
207 plt.plot(ins[0].v[
'tow'],average)
213 deviceRMS[
'ned'] = deviceRMS[
'lla']
214 for devNum
in range(0,numDev):
216 n = len(averageValues[
'lla'])
217 iLat = averageValues[
'lla'][int(n/2)][0] * DEG2RAD
218 iLon = averageValues[
'lla'][int(n/2)][1] * DEG2RAD
219 fLat = iLat + deviceRMS[
'lla'][devNum][0] * DEG2RAD
225 fLon = iLon + deviceRMS[
'lla'][devNum][1] * DEG2RAD
229 deviceRMS[
'ned'][devNum][0] = dNorth
230 deviceRMS[
'ned'][devNum][1] = dEast
231 deviceRMS[
'ned'][devNum][2] = -deviceRMS[
'lla'][devNum][2]
233 n = len(averageValues[
'lla'])
234 iLat = averageValues[
'lla'][int(n/2)][0] * DEG2RAD
235 iLon = averageValues[
'lla'][int(n/2)][1] * DEG2RAD
236 fLat = iLat + averageRMS[
'lla'][0] * DEG2RAD
242 fLon = iLon + averageRMS[
'lla'][1] * DEG2RAD
246 averageRMS[
'ned'] = averageRMS[
'lla']
247 averageRMS[
'ned'][0] = dNorth
248 averageRMS[
'ned'][1] = dEast
249 averageRMS[
'ned'][2] = -averageRMS[
'lla'][2]
251 navMode = ins[0].iStatus().navMode[-1]
257 specThresh[
'ned'] = np.array([0.2,0.2,0.2])
258 specThresh[
'uvw'] = np.array([0.1,0.1,0.1])
259 specThresh[
'euler'] = np.array([0.1,0.1,0.0])
261 specThresh[
'euler'][2] = 0.3
263 specThresh[
'euler'][2] = 2.0
265 specThresh[
'euler'] = tolerance * specThresh[
'euler']
266 specThresh[
'ned'] = tolerance * specThresh[
'ned']
267 specThresh[
'uvw'] = tolerance * specThresh[
'uvw']
270 sigTest[
'euler'] = [
'NA ',
'NA ',
'NA ']
271 sigTest[
'ned'] = [
'NA ',
'NA ',
'NA ']
272 sigTest[
'uvw'] = [
'NA ',
'NA ',
'NA ']
274 sigTest[
'euler'][i] =
'PASS' if averageRMS[
'euler'][i]*RAD2DEG < specThresh[
'euler'][i]
else 'FAIL' 276 sigTest[
'ned'][i] =
'PASS' if averageRMS[
'ned'][i] < specThresh[
'ned'][i]
else 'FAIL' 277 sigTest[
'uvw'][i] =
'PASS' if averageRMS[
'uvw'][i] < specThresh[
'uvw'][i]
else 'FAIL' 279 filename = os.path.join(directory,
'RMS_report.txt');
280 f = open(filename,
'w')
281 f.write(
'***** Performance Analysis Report - %s *****\n' % (subdir))
283 f.write(
'Directory: %s\n' % (directory))
289 f.write(
'--------------------------------------------------- RMS Accuracy -------------------------------------------\n')
290 line = line +
'UVW[ (m/s) (m/s) (m/s) ], NED[ (m) (m) (m) ],' 292 f.write(
'-------------- RMS Accuracy --------------\n')
293 line = line +
' Eul[ (deg) (deg) (deg) ]\n' 296 for n
in range(0,numDev):
297 devInfo = itd.cDevInfo(log.devices[n].data[
'devInfo'])
298 line =
'%2d SN%d ' % (n, devInfo.v[
'serialNumber'][-1])
300 line = line +
'[%7.4f %7.4f %7.4f ], ' % (deviceRMS[
'uvw'][n][0],deviceRMS[
'uvw'][n][1],deviceRMS[
'uvw'][n][2])
301 line = line +
'[%7.4f %7.4f %7.4f ], ' % (deviceRMS[
'ned'][n][0],deviceRMS[
'ned'][n][1],deviceRMS[
'ned'][n][2])
302 line = line +
'[%7.4f %7.4f %7.4f ]\n' % (deviceRMS[
'euler'][n][0]*RAD2DEG,deviceRMS[
'euler'][n][1]*RAD2DEG,deviceRMS[
'euler'][n][2]*RAD2DEG)
307 f.write(
'------------------------------------------------------------------------------------------------------------\n')
308 line = line +
'[%7.4f %7.4f %7.4f ], ' % (averageRMS[
'uvw'][0],averageRMS[
'uvw'][1],averageRMS[
'uvw'][2])
309 line = line +
'[%7.4f %7.4f %7.4f ], ' % (averageRMS[
'ned'][0],averageRMS[
'ned'][1],averageRMS[
'ned'][2])
311 f.write(
'------------------------------------------\n')
312 line = line +
'[%7.4f %7.4f %7.4f ]\n' % (averageRMS[
'euler'][0]*RAD2DEG,averageRMS[
'euler'][1]*RAD2DEG,averageRMS[
'euler'][2]*RAD2DEG)
317 line = line +
'[%7.4f %7.4f %7.4f ], ' % (specThresh[
'uvw'][0],specThresh[
'uvw'][1],specThresh[
'uvw'][2])
318 line = line +
'[%7.4f %7.4f %7.4f ], ' % (specThresh[
'ned'][0],specThresh[
'ned'][1],specThresh[
'ned'][2])
319 line = line +
'[%7.4f %7.4f %7.4f ]\n' % (specThresh[
'euler'][0],specThresh[
'euler'][1],specThresh[
'euler'][2])
324 line = line +
'[ %s %s %s ], ' % (sigTest[
'uvw'][0],sigTest[
'uvw'][1],sigTest[
'uvw'][2])
325 line = line +
'[ %s %s %s ], ' % (sigTest[
'ned'][0],sigTest[
'ned'][1],sigTest[
'ned'][2])
326 line = line +
'[ %s %s %s ]\n' % (sigTest[
'euler'][0],sigTest[
'euler'][1],sigTest[
'euler'][2])
333 f.write(
'(NAV mode)\n\n' if ins[0].iStatus().navMode[-1]
else '(AHRS mode)\n\n')
336 f.write(
'--------------- Angular Mounting Biases ----------------\n')
337 f.write(
'Device Euler Biases[ (deg) (deg) (deg) ]\n')
338 for n
in range(0,numDev):
339 devInfo = itd.cDevInfo(log.devices[n].data[
'devInfo'])
340 f.write(
'%2d SN%d [ %7.4f %7.4f %7.4f ]\n' % (n, devInfo.v[
'serialNumber'][-1],bias[
'euler'][n][0]*RAD2DEG,bias[
'euler'][n][1]*RAD2DEG,bias[
'euler'][n][2]*RAD2DEG))
344 f.write(
'------------------------------------------- Device Info -------------------------------------------------\n')
345 for n
in range(0,numDev):
346 devInfo = itd.cDevInfo(log.devices[n].data[
'devInfo'])
347 hver = devInfo.v[
'hardwareVer'][-1]
348 cver = devInfo.v[
'commVer'][-1]
349 fver = devInfo.v[
'firmwareVer'][-1]
350 buld = devInfo.v[
'build'][-1]
351 repo = devInfo.v[
'repoRevision'][-1]
352 date = devInfo.v[
'buildDate'][-1]
353 time = devInfo.v[
'buildTime'][-1]
354 addi = devInfo.v[
'addInfo'][-1]
355 f.write(
'%2d SN%d HW: %d.%d.%d.%d FW: %d.%d.%d.%d build %d repo %d Proto: %d.%d.%d.%d Date: %04d-%02d-%02d %02d:%02d:%02d %s\n' %(
356 n, devInfo.v[
'serialNumber'][-1],
357 hver[3], hver[2], hver[1], hver[0],
358 fver[3], fver[2], fver[1], fver[0], buld, repo,
359 cver[3], cver[2], cver[1], cver[0],
360 2000+date[2], date[1], date[0],
361 time[3], time[2], time[1],
368 if 'win' in sys.platform:
369 subprocess.Popen([
"notepad.exe", filename])
371 subprocess.Popen([
"gedit", filename])
def calculateDistance(lat1, lon1, lat2, lon2)
GeneratorWrapper< T > range(T const &start, T const &end, T const &step)
#define max(a, b)
Takes the maximal value of a and b.
def computeRmsAccuracies(log, directory, subdir)
def handleHeadingWrapping(ins)
def shiftTime(tow, dataSet, time)
def checkRawDataDrop(log)