2 Created on Feb 22, 2014 6 from numbers
import Number
13 import pylib.pose
as pose
14 import pylib.filterTools
as ft
17 import time
as systime
19 from numpy
import uint8
as u8
20 from numpy
import uint16
as u16
21 from numpy
import uint32
as u32
22 from numpy
import int32
as i32
23 from numpy
import float32
as f32
24 from numpy
import int64
as i64
25 from numpy
import float64
as f64
29 refLla = np.r_[40.0557114, -111.6585476, 1426.77]
50 if size
and size[0] > 1:
60 GPS_start_Time = datetime.datetime.strptime(
'6/Jan/1980',
"%d/%b/%Y")
61 WEEK_TIME = GPS_start_Time + (datetime.timedelta(weeks=int(week)))
65 return [WEEK_TIME + datetime.timedelta(milliseconds=int(i))
for i
in ms]
69 return [WEEK_TIME + datetime.timedelta(seconds=float(i))
for i
in s]
72 GPS_start_Time = datetime.datetime.strptime(
'1/Jan/1970',
"%d/%b/%Y")
73 return [GPS_start_Time + datetime.timedelta(seconds=float(t[
'time'] + t[
'sec']))
for t
in gtime]
97 def set(self, name, dtype):
110 return np.c_[_v[name +
'[0]'].T, _v[name +
'[1]'].T, _v[name +
'[2]'].T]
114 return np.c_[_v[name +
'[0]'].T, _v[name +
'[1]'].T, _v[name +
'[2]'].T, _v[name +
'[3]'].T]
122 RAW_DATA_RTK_SOL = 123
124 dtypeGpsRaw = np.dtype([
126 (
'receiverIndex', u8),
132 dtypeGtime = np.dtype([
136 dtypeEph = np.dtype([
173 dtypeGEph = np.dtype([
190 dtypeSbas = np.dtype([
195 (
'reserved', (u8, 3)),
198 dtypeSta = np.dtype([
206 dtypeObsD = np.dtype([
207 (
'time', dtypeGtime),
223 def __init__(self, index, directory, serialNumber, refIns=None):
231 (
'classification', u16),
232 (
'name', np.dtype((str, 4))),
233 (
'invName', np.dtype((str, 4))),
235 (
'invDataSize', u32),
237 (
'devSerialNum', u32),
243 (
'dHdr', [(
'id', u32),
253 self.
di[1].set(
'devInfo', np.dtype([
256 (
'serialNumber', u32),
257 (
'hardwareVer', (u8, 4)),
258 (
'firmwareVer', (u8, 4)),
260 (
'commVer', (u8, 4)),
261 (
'repoRevision', f32),
262 (
'manufacturer', np.dtype((str, 24))),
263 (
'buildDate', (u8, 4)),
264 (
'buildTime', (u8, 4)),
265 (
'addInfo', np.dtype((str, 24))),
268 dtypeImu = np.dtype([
275 self.
di[3].set(
'preintegratedImu', np.dtype([
278 (
'theta1', (f32, 3)),
279 (
'theta2', (f32, 3)),
285 self.
di[4].set(
'ins1', np.dtype([
297 self.
di[5].set(
'ins2', np.dtype([
308 dtypeGpsPos = np.dtype([
311 (
'timeOfWeekMs', u32),
323 self.
di[6].set(
'gps1UbxPos', dtypeGpsPos)
328 dtStartVars = np.dtype([
334 self.
di[9].set(
'insMisc', np.dtype([
348 self.
di[10].set(
'sysParams', np.dtype([
359 (
'reserved2', (f32, 4)),
360 (
'genFaultcode', u32),
365 self.
di[12].set(
'flashConfig', np.dtype([
370 (
'startupSampleDtMs', u32),
371 (
'startupNavDtMs', u32),
372 (
'ser0BaudRate', u32),
373 (
'ser1BaudRate', u32),
374 (
'insRotation', (f32, 3)),
375 (
'insOffset', (f32, 3)),
376 (
'gps1AntOffset', (f32, 3)),
377 (
'insDynModel', u32),
379 (
'refLla', (f64, 3)),
380 (
'lastLla', (f64, 3)),
381 (
'lastLlaTimeOfWeekMs', u32),
382 (
'lastLlaWeek', u32),
383 (
'lastLlaUpdateDistance', f32),
386 (
'gps2AntOffset', (f32, 3)),
387 (
'zeroVelRotation', (f32, 3)),
388 (
'zeroVelOffset', (f32, 3)),
389 (
'magInclination', f32),
390 (
'magDeclination', f32),
391 (
'gpsTimeSyncPulsePeriodMs', u32),
392 (
'startupGPSDtMs', u32),
395 (
'ser2BaudRate', u32),
398 self.
di[13].set(
'gps1Pos', dtypeGpsPos)
399 self.
di[14].set(
'gps2Pos', dtypeGpsPos)
407 self.
di[20].set(
'insResources', np.dtype([
410 (
'x_dot', dtStartVars),
411 (
'magYawOffset', f32),
414 self.
di[21].set(
'gps1RtkPosRel', np.dtype([
416 (
'timeOfWeekMs', u32 ),
417 (
'differentialAge', f32 ),
419 (
'vectorToBase', (f32, 3)),
420 (
'distanceToBase', f32 ),
421 (
'headingToBase', f32 ),
424 self.
di[22].set(
'gps1RtkPosMisc', np.dtype([
426 (
'timeOfWeekMs', u32),
427 (
'accuracyPos', (f32, 3)),
428 (
'accuracyCov', (f32, 3)),
429 (
'arThreshold', f32),
433 (
'baseLla', (f64, 3)),
434 (
'cycleSlipCount', u32),
435 (
'roverGpsObservationCount', u32),
436 (
'baseGpsObservationCount', u32),
437 (
'roverGlonassObservationCount', u32),
438 (
'baseGlonassObservationCount', u32),
439 (
'roverGalileoObservationCount', u32),
440 (
'baseGalileoObservationCount', u32),
441 (
'roverBeidouObservationCount', u32),
442 (
'baseBeidouObservationCount', u32),
443 (
'roverQzsObservationCount', u32),
444 (
'baseQzsObservationCount', u32),
445 (
'roverGpsEphemerisCount', u32),
446 (
'baseGpsEphemerisCount', u32),
447 (
'roverGlonassEphemerisCount', u32),
448 (
'baseGlonassEphemerisCount', u32),
449 (
'roverGalileoEphemerisCount', u32),
450 (
'baseGalileoEphemerisCount', u32),
451 (
'roverBeidouEphemerisCount', u32),
452 (
'baseBeidouEphemerisCount', u32),
453 (
'roverQzsEphemerisCount', u32),
454 (
'baseQzsEphemerisCount', u32),
455 (
'roverSbasCount', u32),
456 (
'baseSbasCount', u32),
457 (
'baseAntennaCount', u32),
458 (
'ionUtcAlmCount', u32)
463 dtypeSensorsMpuWTemp = np.dtype([
470 self.
di[24].set(
'sensorsIs1', np.dtype([
472 (
'mpu', (dtypeSensorsMpuWTemp, 2)),
478 self.
di[27].set(
'sensorBias', np.dtype([
491 dtypeGpsVel = np.dtype([
493 (
'timeOfWeekMs', u32),
494 (
'velEcef', (f32, 3)),
498 self.
di[30].set(
'gps1Vel', dtypeGpsVel)
499 self.
di[31].set(
'gps2Vel', dtypeGpsVel)
505 self.
di[39].set(
'debugArray', np.dtype([
512 self.
di[47].set(
'insDev1', np.dtype([
522 (
'eulerErr', (f32, 3)),
523 (
'uvwErr', (f32, 3)),
524 (
'nedErr', (f32, 3)),
527 self.
di[48].set(
'ekfStates', np.dtype([
533 (
'biasPqr', (f32, 3)),
534 (
'biasAcc', (f32, 3)),
544 self.
di[52].set(
'magnetometer1', np.dtype([
550 self.
di[53].set(
'barometer', np.dtype([
559 self.
di[54].set(
'gps1RtkPos', dtypeGpsPos)
561 self.
di[55].set(
'gps1RtkCmpRel', np.dtype([
563 (
'timeOfWeekMs', u32 ),
564 (
'differentialAge', f32 ),
566 (
'vectorToBase', (f32, 3)),
567 (
'distanceToBase', f32 ),
568 (
'headingToBase', f32 ),
571 self.
di[56].set(
'gpsVersion', np.dtype([
573 (
'swVersion', np.dtype((str, 30))),
574 (
'hwVersion', np.dtype((str, 10))),
575 (
'extension', np.dtype((str, 30))),
576 (
'reserved', (u32, 2)),
581 self.
di[58].set(
'dualImu', np.dtype([
584 (
'I', (dtypeImu, 2)),
587 self.
di[59].set(
'inl2MagObs', np.dtype([
590 (
'Ncal_samples', u32),
597 (
'magInsHdgDelta', f32),
599 (
'nis_threshold', f32),
601 (
'activeCalSet', u32),
602 (
'magHeadingOffset', f32),
606 self.
di[60].set(
'GPSBaseRaw', dtypeGpsRaw)
615 self.
di[67].set(
'inl2Variance', np.dtype([
618 (
'PxyxNED', (f32, 3)),
619 (
'PvelNED', (f32, 3)),
620 (
'PattNED', (f32, 3)),
621 (
'PABias', (f32, 3)),
622 (
'PWBias', (f32, 3)),
624 (
'PDeclination', f32),
629 self.
di[69].set(
'GPS1Raw', dtypeGpsRaw)
630 self.
di[70].set(
'GPS2Raw', dtypeGpsRaw)
632 self.
di[91].set(
'gps1RtkCmpMisc', np.dtype([
634 (
'timeOfWeekMs', u32),
635 (
'accuracyPos', (f32, 3)),
636 (
'accuracyCov', (f32, 3)),
637 (
'arThreshold', f32),
641 (
'baseLla', (f64, 3)),
642 (
'cycleSlipCount', u32),
643 (
'roverGpsObservationCount', u32),
644 (
'baseGpsObservationCount', u32),
645 (
'roverGlonassObservationCount', u32),
646 (
'baseGlonassObservationCount', u32),
647 (
'roverGalileoObservationCount', u32),
648 (
'baseGalileoObservationCount', u32),
649 (
'roverBeidouObservationCount', u32),
650 (
'baseBeidouObservationCount', u32),
651 (
'roverQzsObservationCount', u32),
652 (
'baseQzsObservationCount', u32),
653 (
'roverGpsEphemerisCount', u32),
654 (
'baseGpsEphemerisCount', u32),
655 (
'roverGlonassEphemerisCount', u32),
656 (
'baseGlonassEphemerisCount', u32),
657 (
'roverGalileoEphemerisCount', u32),
658 (
'baseGalileoEphemerisCount', u32),
659 (
'roverBeidouEphemerisCount', u32),
660 (
'baseBeidouEphemerisCount', u32),
661 (
'roverQzsEphemerisCount', u32),
662 (
'baseQzsEphemerisCount', u32),
663 (
'roverSbasCount', u32),
664 (
'baseSbasCount', u32),
665 (
'baseAntennaCount', u32),
666 (
'ionUtcAlmCount', u32)
670 timeStart = systime.time()
682 if refIns
is not None:
683 print(
"#%2d Opening: Ref INS %s" % (index, directory))
685 fileMask =
"LOG_REF_INS*.dat" 688 print(
"#%2d Opening: %s %s" % (index, serialNumber, directory))
690 fileMask =
"LOG_" + serialNumber +
"*.sdat" 692 if not os.path.isdir(directory):
693 print(
"Directory doesn't exist!")
700 raise Exception(
'Load Error: .sdat files not found.')
706 self.
loadTime = systime.time() - timeStart
707 print(
"Load time: %.2fs" % (self.
loadTime))
710 for key, item
in self.
data.iteritems():
711 if not isinstance(item, np.ndarray):
714 for field
in [
'towMs',
'timeOfWeekMs',
'tow']:
715 if field
in item.dtype.names:
716 if (np.diff(item[field].astype(np.int64)) < 0).any():
717 idx = np.argmin(np.diff(item[field].astype(np.int64)))
718 print(
"\033[93m" +
"Time went backwards in ", key,
r"!!!, removing all data " + (
"before" if idx < len(item[field])/2.0
else "after") +
"\033[0m")
719 if idx < len(item[field])/2.0:
720 self.
data[key] = item[idx +1:]
722 self.
data[key] = item[:idx]
723 ms_multiplier = 1000.0
if 'Ms' in field
else 1.0
724 if (np.diff(item[field]) > 3600 * ms_multiplier).any():
725 print(
"\033[93m" +
"greater than 1 minute gap in ", key,
" data, assuming GPS fix was acquired during data set, and chopping data"+
"\033[0m")
726 idx = np.argmax(np.diff(item[field])) + 1
727 self.
data[key] = item[idx:]
740 for key, item
in self.
data[name].iteritems():
741 self.
data[name][key] = np.array(item)
742 if 'ins2' in self.
data.keys():
748 valid_types = [1, 2, 3, 4, 5, 6, 123]
749 valid_receiver_indexes = [1, 2, 3, 4]
754 buf = np.fromfile(f, np.uint8, count=cHdr[
'dataSize'])
755 for i
in range(sHdr[
'dCount']):
757 hdr_size = np.dtype(dtypeGpsRaw).itemsize
758 gps_raw_header = buf[pointer:pointer + hdr_size].view(dtypeGpsRaw)
763 type = gps_raw_header[
'type'][0]
764 count = gps_raw_header[
'count'][0]
765 receiverIndex = gps_raw_header[
'receiverIndex'][0]
766 assert (type
in valid_types
and receiverIndex
in valid_receiver_indexes)
767 if dati.name
not in self.
data.keys():
768 self.
data[dati.name] = {
'dataSerNum': [gps_raw_header[
'dataSerNum'][0]],
769 'receiverIndex': [receiverIndex],
774 self.
data[dati.name][
'dataSerNum'].append(gps_raw_header[
'dataSerNum'][0])
775 self.
data[dati.name][
'receiverIndex'].append(gps_raw_header[
'receiverIndex'][0])
776 self.
data[dati.name][
'type'].append(type)
777 self.
data[dati.name][
'count'].append(count)
779 print(
"invalid raw gps header: type=", type,
"count = ", count,
"receiverIndex = ", receiverIndex)
780 self.
data[dati.name][
'corrupt_data'] += 1
783 if type == RAW_DATA_OBS:
785 bytes_in_payload = np.dtype(dtypeObsD).itemsize * count
786 obs = buf[pointer:pointer + bytes_in_payload].view(dtypeObsD)
787 pointer += bytes_in_payload
788 if 'obs' not in self.
data[dati.name]:
789 self.
data[dati.name][
'obs'] = np.rec.array(obs)
791 self.
data[dati.name][
'obs'] = np.hstack((self.
data[dati.name][
'obs'], np.rec.array(obs)))
793 print(
"badly formed raw gps data - DID: %d type: Obs, count: %d, actual: %f" %
794 (did, count, (len(buf) - 8) / (float(np.dtype(dtypeObsD).itemsize))))
795 self.
data[dati.name][
'corrupt_data'] += 1
799 with open(filename,
'rb')
as f:
803 cHdr = np.fromfile(f, dtype=self.
dtCnkHdr, count=1)
805 count = cHdr[
'dataSize']
807 if np.shape(cHdr)[0] == 0
or cHdr[
'marker'][0] != 0xFC05EA32:
812 sHdr = np.fromfile(f, dtype=self.
dtCnkSubHdr, count=1)
815 did = sHdr[
'dHdr'][
'id'][0]
816 dsize = sHdr[
'dHdr'][
'size'][0]
822 print(
"==============================================================================")
823 print(
" - ERROR - Data ID " + str(did) +
" out of range " + str(
824 self.
DID_COUNT) +
". Please add missing DID definitions to ISToolsDataSorted.pyx.")
825 print(
"==============================================================================")
833 if dsize == (dati.dtype.itemsize - 4):
836 cDat = np.fromfile(f, dati.dtype, count=sHdr[
'dCount'])
838 if dati.name
in self.
data.keys():
841 self.
data[dati.name] = np.concatenate([self.
data[dati.name], cDat])
844 self.
data[dati.name] = cDat
847 elif dati.dtype == dtypeGpsRaw:
852 print(
"==============================================================================")
853 print(
" - ERROR - Data ID", did,
"(" + dati.name +
") mismatched size. Read", dsize,
"expected", dati.dtype.itemsize - 4)
854 print(
"==============================================================================")
857 cDat = np.fromfile(f, np.uint8, count=cHdr[
'dataSize'][0])
862 print(
"Undefined DID: ", did)
863 cDat = np.fromfile(f, np.uint8, count=cHdr[
'dataSize'][0])
879 def loadData(self, directory=None, serialNumbers=None, refIns=None, startDev=0, devCount=-1):
883 timeLoadStart = systime.time()
887 raise Exception(
'refIns not supported right now.')
889 if directory
is not None:
891 directory = directory.replace(
'\\',
'/')
900 selectionFileName =
'selection.txt' 901 if os.path.exists(selectionFileName):
902 with open(selectionFileName)
as f:
903 lines = f.read().splitlines()
906 directory += lines[0].replace(
'\\',
'/')
910 for serNum
in lines[1:]:
914 serialNumbers.append(serNum)
917 files = os.listdir(directory)
918 if not any(
".sdat" in s
for s
in files):
923 if len(fname) >= 15
and fname[0:2] ==
'20' and fname[8:9] ==
'_':
924 dTime = int(fname[0:8] + fname[9:15])
934 print(
"Loading Data: ", directory)
937 if serialNumbers
is None or serialNumbers == []:
939 files = os.listdir(directory)
942 if str.find(
'.sdat') != -1:
943 str = str.replace(
'.sdat',
'')
944 if str.find(
'LOG_SN') != -1:
946 if not str
in serNums:
948 elif str.find(
'LOG_PR') != -1:
949 str = str.replace(
'LOG_',
'')
950 str = str[:str.find(
'_')]
951 if not str
in serNums:
953 serialNumbers = serNums
955 count = len(serialNumbers)
959 raise Exception(
'Load Error: .sdat files not found.')
962 if devCount > 0
and devCount < count:
964 endIndex = min(startDev + count, len(serialNumbers))
969 for i
in range(startDev, endIndex):
970 device =
cDevice(i, directory, serialNumbers[i], refIns)
974 self.
loadTime = systime.time() - timeLoadStart
975 print(
"Total load time: %.2fs" % (self.
loadTime))
984 size = np.shape(gpsWeek)
985 if size
and size[0] > 1:
989 gpsWeek = np.max(gpsWeek)
996 gpsEpoch = (1980, 1, 6, 0, 0, 0)
999 epochTuple = gpsEpoch + (-1, -1, 0)
1000 t0 = systime.mktime(epochTuple) - systime.timezone
1001 tdiff = (gpsWeek * secsInWeek) + gpsSOW - leapSecs
1007 sizes = np.array([a.itemsize
for a
in arrays])
1008 offsets = np.r_[0, sizes.cumsum()]
1010 joint = np.empty((n, offsets[-1]), dtype=np.uint8)
1011 for a, size, offset
in zip(arrays, sizes, offsets):
1012 joint[:, offset:offset + size] = a.view(np.uint8).reshape(n, size)
1013 dtype = sum((a.dtype.descr
for a
in arrays), [])
1014 return joint.ravel().view(dtype)
1019 newdtype = sum((a.dtype.descr
for a
in arrays), [])
1020 newrecarray = np.empty(len(arrays[0]), dtype=newdtype)
1022 for name
in a.dtype.names:
1023 newrecarray[name] = a[name]
1037 self.
__flt.pqr =
None 1038 self.
__flt.acc =
None 1039 self.
__flt.pqrNoBias =
None 1040 self.
__flt.accNoBias =
None 1041 self.
__flt.barNoBias =
None 1049 for j
in range(0, 2):
1050 self.
i[j].pqr =
None 1051 self.
i[j].acc =
None 1054 if 'I' in self.
v.dtype.names:
1055 self.
i[0].pqr = self.
v[
'I'][
'pqr'][:, 0, :]
1056 self.
i[1].pqr = self.
v[
'I'][
'pqr'][:, 1, :]
1057 self.
i[0].acc = self.
v[
'I'][
'acc'][:, 0, :]
1058 self.
i[1].acc = self.
v[
'I'][
'acc'][:, 1, :]
1061 if 'theta1' in self.
v.dtype.names
and 'theta2' in self.
v.dtype.names:
1062 divDt = 1.0 / self.
v[
'dt']
1063 self.
i[0].pqr = self.
v[
'theta1']
1064 self.
i[1].pqr = self.
v[
'theta2']
1065 self.
i[0].acc = self.
v[
'vel1']
1066 self.
i[1].acc = self.
v[
'vel2']
1068 for i
in range(0, 2):
1069 for a
in range(0, 3):
1070 self.
i[i].pqr[:, a] *= divDt
1071 self.
i[i].acc[:, a] *= divDt
1074 if self.
__flt.acc
is None:
1076 return self.
__flt.acc
1079 if self.
__flt.pqr
is None:
1081 return self.
__flt.pqr
1084 if 'pqrNoBias' in self.
v.dtype.names
and self.
__flt.pqrNoBias
is None:
1085 self.
__flt.pqrNoBias = ft.lpfNoDelay(self.
v[
'pqrNoBias'], self.
cornerFreqHz, time=self.
v[
'time'])
1086 return self.
__flt.pqrNoBias
1089 if 'accNoBias' in self.
v.dtype.names
and self.
__flt.accNoBias
is None:
1090 self.
__flt.accNoBias = ft.lpfNoDelay(self.
v[
'accNoBias'], self.
cornerFreqHz, time=self.
v[
'time'])
1091 return self.
__flt.accNoBias
1094 if 'mslBarNoBias' in self.
v.dtype.names
and self.
__flt.barNoBias
is None:
1095 self.
__flt.mslBarNoBias = ft.lpfNoDelay(self.
v[
'mslBarNoBias'], self.
cornerFreqHz, time=self.
v[
'time'])
1096 return self.
__flt.mslBarNoBias
1116 if not 'euler' in self.
v.dtype.names
and 'q' in self.
v.dtype.names:
1119 dtypeeuler = np.dtype([(
'euler', (np.float, 3))])
1120 e = pose.quat2eulerArray(self.
v[
'q'])
1121 euler = np.ndarray(np.shape(e)[0], dtype=dtypeeuler, buffer=e)
1124 if not 'q' in self.
v.dtype.names
and 'euler' in self.
v.dtype.names:
1127 dtypeq = np.dtype([(
'q', (np.float, 4))])
1128 q = pose.euler2quatArray(self.
v[
'euler'])
1129 quat = np.ndarray(np.shape(q)[0], dtype=dtypeq, buffer=q)
1135 self.
__velNED = np.zeros(np.shape(self.
v[
'uvw']))
1138 DCM = pose.eulerDCM(self.
v[
'euler'][i, :])
1139 velNED = np.dot(DCM.T, self.
v[
'uvw'][i, :])
1146 self.
__course = np.arctan2(self.velNED[:, 1], self.velNED[:, 0])
1151 if self.
__ned is None:
1152 self.
__ned = pose.lla2ned(refLla, self.
v[
'lla'])
1157 self.
__ecef = pose.lla2ecef(self.
v[
'lla'])
1164 return np.sqrt(np.square(self.
v[
'uvw'][:, 0]) +
1165 np.square(self.
v[
'uvw'][:, 1]))
1168 return np.sqrt(np.square(self.
v[
'uvw'][:, 0]) +
1169 np.square(self.
v[
'uvw'][:, 1]) +
1170 np.square(self.
v[
'uvw'][:, 2]))
1185 accBias=np.r_[0, 0, 0],
1186 pqrBias=np.r_[0, 0, 0],
1187 rotate=np.r_[0, 0, 0]):
1191 self.
__flt.pqr =
None 1192 self.
__flt.acc =
None 1194 if accBias[0] != 0
or accBias[1] != 0
or accBias[2] != 0:
1195 self.
v[
'acc'] += accBias
1197 if pqrBias[0] != 0
or pqrBias[1] != 0
or pqrBias[2] != 0:
1198 self.
v[
'pqr'] += pqrBias
1200 if rotate[0] != 0
or rotate[1] != 0
or rotate[2] != 0:
1201 self.
v[
'acc'] = pose.vectorRotateInertialToBody2(self.
v[
'acc'], rotate)
1202 self.
v[
'pqr'] = pose.vectorRotateInertialToBody2(self.
v[
'pqr'], rotate)
1205 if self.
__flt.pqr
is None:
1207 return self.
__flt.pqr
1210 if self.
__flt.acc
is None:
1212 return self.
__flt.acc
1228 self.
v[
'euler'][:, 0] += self.
__rotate[0]
1229 self.
v[
'euler'][:, 1] += self.
__rotate[1]
1230 self.
v[
'euler'][:, 2] += self.
__rotate[2]
1233 if self.
__ned is None:
1234 self.
__ned = pose.lla2ned(refLla, self.
v[
'lla'])
1239 self.
__nedDotDot = ft.derivative(self.
v[
'time'], self.
v[
'nedDot'], delta=2)
1246 if self.
__uvw is None:
1247 self.
__uvw = pose.vectorRotateInertialToBody(self.
v[
'nedDot'], self.
v[
'euler'])
1260 self.
__acc.ned =
None 1263 if self.
__ned is None:
1264 self.
__ned = pose.lla2ned(refLla, self.
v[
'lla'])
1268 if self.
__acc.ned
is None:
1271 self.
__acc.ned = ft.meanDerivative(self.
v[
'time'], self.
v[
'vel.ned'], 2, 2)
1272 return self.
__acc.ned
1283 self.
ned = pose.lla2ned(refLla, _v[
'lla'])
1300 if 'obs' in _v.keys():
1303 self.
obstime = np.array([np.datetime64(int(np.round((t[
'time'] + t[
'sec'])*1000000)),
'us')
for t
in _v[
'obs'][
'time']])
1304 except OverflowError
as e:
1325 if self.
__acc is None:
1327 self.
__acc.time = self.time
1329 self.
__acc.ned = ft.meanDerivative(self.time, self.
v[
'ned'], 2, 2)
1367 if 'tow' in _v.dtype.names:
1370 if 'towMs' in _v.dtype.names:
1404 self.
accNed.refHdg = np.arctan2(self.
v[
'accNed'][
'ref'][:, 1], self.
v[
'accNed'][
'ref'][:, 0])
1405 self.
accNed.insHdg = np.arctan2(self.
v[
'accNed'][
'ins'][:, 1], self.
v[
'accNed'][
'ins'][:, 0])
1407 self.
lla.refNed = pose.lla2ned(refLla, _v[
'lla'][
'ref'])
1408 self.
lla.insNed = pose.lla2ned(refLla, _v[
'lla'][
'ins'])
1420 if 'magTowMs' in _v.dtype.names:
1425 def lla2kml(time, lla, serialNumber, kmlFileName="log.kml", **kwargs):
1426 kml = simplekml.Kml()
1428 color = kwargs.pop(
'color', simplekml.Color.yellow)
1429 altitudeMode = kwargs.pop(
'altitudeMode', simplekml.constants.AltitudeMode.absolute)
1430 timeStep = kwargs.pop(
'timeStep', 0)
1435 for i
in range(0, np.shape(lla)[0]):
1436 latLon.append((lla[i, 1], lla[i, 0], lla[i, 2]))
1445 if time[i] >= tNext:
1448 if time[i] >= lNext:
1449 if timeStep > lNext:
1453 pt = kml.newpoint(name=
"%.2f" % time[i], coords=[latLon[i]])
1455 pt = kml.newpoint(coords=[latLon[i]])
1456 pt.style.iconstyle.color = color
1457 pt.style.iconstyle.scale = 0.4
1458 pt.style.labelstyle.scale = 0.6
1459 pt.altitudemode = altitudeMode
1462 ls = kml.newlinestring(name=
"Tracks", description=serialNumber +
" tracks", coords=latLon)
1466 ls.altitudemode = altitudeMode
1467 ls.style.linestyle.width = 2
1468 ls.style.linestyle.color = color
1469 kml.save(kmlFileName)
1478 result.align =
cObj()
1479 result.align.coarse =
cObj()
1480 result.align.good =
cObj()
1481 result.align.fine =
cObj()
1484 result.align.coarse.att = (istatus >> 0) & 1
1485 result.align.coarse.vel = (istatus >> 1) & 1
1486 result.align.coarse.pos = (istatus >> 2) & 1
1489 result.align.good.att = (istatus >> 4) & 1
1490 result.align.good.vel = (istatus >> 5) & 1
1491 result.align.good.pos = (istatus >> 6) & 1
1492 result.align.fine.att = (istatus >> 7) & 1
1495 result.usingGps = (istatus >> 8) & 1
1496 result.usingMag = (istatus >> 11) & 1
1499 result.navMode = (istatus >> 12) & 1
1502 result.solutionStatus = (istatus >> 16) & 0x7
1505 result.magActiveCalSet = (istatus >> 20) & 1
1506 result.magRecalibrating = (istatus >> 22) & 1
1507 result.magInterOrBadCal = ((istatus >> 23) & 1) != 1
1512 result.rtosTaskPeriodOverrun = (istatus >> 29) & 1
1513 result.generalFault = (istatus >> 31) & 1
1523 result.motionGyrSig = (hstatus >> 0) & 0x1
1524 result.motionAccSig = (hstatus >> 1) & 0x1
1525 result.motionGyrDev = (hstatus >> 2) & 0x1
1526 result.motionAccDev = (hstatus >> 3) & 0x1
1529 result.satellite_rx = (hstatus >> 4) & 0x1
1532 result.saturationGyr = (hstatus >> 8) & 0x1
1533 result.saturationAcc = (hstatus >> 9) & 0x1
1534 result.saturationMag = (hstatus >> 10) & 0x1
1535 result.saturationBaro = (hstatus >> 11) & 0x1
1538 result.saturationHistory = (hstatus >> 12) & 0x1
1541 result.errComTxLimited = (hstatus >> 16) & 0x1
1542 result.errComRxOverrun = (hstatus >> 17) & 0x1
1543 result.errGpsTxLimited = (hstatus >> 18) & 0x1
1544 result.errGpsRxOverrun = (hstatus >> 19) & 0x1
1547 result.comParseErrCount = (hstatus >> 20) & 0xF
1550 result.selfTestFault = (hstatus >> 24) & 0x1
1551 result.errTemperature = (hstatus >> 25) & 0x1
1554 result.faultWatchdogReset = (hstatus >> 28) & 0x1
1555 result.faultBODReset = (hstatus >> 29) & 0x1
1556 result.faultPORReset = (hstatus >> 30) & 0x1
1557 result.faultCPUErrReset = (hstatus >> 31) & 0x1
GeneratorWrapper< T > range(T const &start, T const &end, T const &step)