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),
397 self.
di[13].set(
'gps1Pos', dtypeGpsPos)
398 self.
di[14].set(
'gps2Pos', dtypeGpsPos)
406 self.
di[20].set(
'insResources', np.dtype([
409 (
'x_dot', dtStartVars),
410 (
'magYawOffset', f32),
413 self.
di[21].set(
'gps1RtkPosRel', np.dtype([
415 (
'timeOfWeekMs', u32 ),
416 (
'differentialAge', f32 ),
418 (
'vectorToBase', (f32, 3)),
419 (
'distanceToBase', f32 ),
420 (
'headingToBase', f32 ),
423 self.
di[22].set(
'gps1RtkPosMisc', np.dtype([
425 (
'timeOfWeekMs', u32),
426 (
'accuracyPos', (f32, 3)),
427 (
'accuracyCov', (f32, 3)),
428 (
'arThreshold', f32),
432 (
'baseLla', (f64, 3)),
433 (
'cycleSlipCount', u32),
434 (
'roverGpsObservationCount', u32),
435 (
'baseGpsObservationCount', u32),
436 (
'roverGlonassObservationCount', u32),
437 (
'baseGlonassObservationCount', u32),
438 (
'roverGalileoObservationCount', u32),
439 (
'baseGalileoObservationCount', u32),
440 (
'roverBeidouObservationCount', u32),
441 (
'baseBeidouObservationCount', u32),
442 (
'roverQzsObservationCount', u32),
443 (
'baseQzsObservationCount', u32),
444 (
'roverGpsEphemerisCount', u32),
445 (
'baseGpsEphemerisCount', u32),
446 (
'roverGlonassEphemerisCount', u32),
447 (
'baseGlonassEphemerisCount', u32),
448 (
'roverGalileoEphemerisCount', u32),
449 (
'baseGalileoEphemerisCount', u32),
450 (
'roverBeidouEphemerisCount', u32),
451 (
'baseBeidouEphemerisCount', u32),
452 (
'roverQzsEphemerisCount', u32),
453 (
'baseQzsEphemerisCount', u32),
454 (
'roverSbasCount', u32),
455 (
'baseSbasCount', u32),
456 (
'baseAntennaCount', u32),
457 (
'ionUtcAlmCount', u32)
462 dtypeSensorsMpuWTemp = np.dtype([
469 self.
di[24].set(
'sensorsIs1', np.dtype([
471 (
'mpu', (dtypeSensorsMpuWTemp, 2)),
477 self.
di[27].set(
'sensorBias', np.dtype([
490 dtypeGpsVel = np.dtype([
492 (
'timeOfWeekMs', u32),
493 (
'velEcef', (f32, 3)),
497 self.
di[30].set(
'gps1Vel', dtypeGpsVel)
498 self.
di[31].set(
'gps2Vel', dtypeGpsVel)
504 self.
di[39].set(
'debugArray', np.dtype([
511 self.
di[47].set(
'insDev1', np.dtype([
521 (
'eulerErr', (f32, 3)),
522 (
'uvwErr', (f32, 3)),
523 (
'nedErr', (f32, 3)),
526 self.
di[48].set(
'ekfStates', np.dtype([
532 (
'biasPqr', (f32, 3)),
533 (
'biasAcc', (f32, 3)),
543 self.
di[52].set(
'magnetometer1', np.dtype([
549 self.
di[53].set(
'barometer', np.dtype([
558 self.
di[54].set(
'gps1RtkPos', dtypeGpsPos)
560 self.
di[55].set(
'gps1RtkCmpRel', np.dtype([
562 (
'timeOfWeekMs', u32 ),
563 (
'differentialAge', f32 ),
565 (
'vectorToBase', (f32, 3)),
566 (
'distanceToBase', f32 ),
567 (
'headingToBase', f32 ),
570 self.
di[56].set(
'gpsVersion', np.dtype([
572 (
'swVersion', np.dtype((str, 30))),
573 (
'hwVersion', np.dtype((str, 10))),
574 (
'extension', np.dtype((str, 30))),
575 (
'reserved', (u32, 2)),
580 self.
di[58].set(
'dualImu', np.dtype([
583 (
'I', (dtypeImu, 2)),
586 self.
di[59].set(
'inl2MagObs', np.dtype([
589 (
'Ncal_samples', u32),
596 (
'magInsHdgDelta', f32),
598 (
'nis_threshold', f32),
600 (
'activeCalSet', u32),
601 (
'magHeadingOffset', f32),
605 self.
di[60].set(
'GPSBaseRaw', dtypeGpsRaw)
614 self.
di[67].set(
'inl2Variance', np.dtype([
617 (
'PxyxNED', (f32, 3)),
618 (
'PvelNED', (f32, 3)),
619 (
'PattNED', (f32, 3)),
620 (
'PABias', (f32, 3)),
621 (
'PWBias', (f32, 3)),
623 (
'PDeclination', f32),
628 self.
di[69].set(
'GPS1Raw', dtypeGpsRaw)
629 self.
di[70].set(
'GPS2Raw', dtypeGpsRaw)
631 self.
di[91].set(
'gps1RtkCmpMisc', np.dtype([
633 (
'timeOfWeekMs', u32),
634 (
'accuracyPos', (f32, 3)),
635 (
'accuracyCov', (f32, 3)),
636 (
'arThreshold', f32),
640 (
'baseLla', (f64, 3)),
641 (
'cycleSlipCount', u32),
642 (
'roverGpsObservationCount', u32),
643 (
'baseGpsObservationCount', u32),
644 (
'roverGlonassObservationCount', u32),
645 (
'baseGlonassObservationCount', u32),
646 (
'roverGalileoObservationCount', u32),
647 (
'baseGalileoObservationCount', u32),
648 (
'roverBeidouObservationCount', u32),
649 (
'baseBeidouObservationCount', u32),
650 (
'roverQzsObservationCount', u32),
651 (
'baseQzsObservationCount', u32),
652 (
'roverGpsEphemerisCount', u32),
653 (
'baseGpsEphemerisCount', u32),
654 (
'roverGlonassEphemerisCount', u32),
655 (
'baseGlonassEphemerisCount', u32),
656 (
'roverGalileoEphemerisCount', u32),
657 (
'baseGalileoEphemerisCount', u32),
658 (
'roverBeidouEphemerisCount', u32),
659 (
'baseBeidouEphemerisCount', u32),
660 (
'roverQzsEphemerisCount', u32),
661 (
'baseQzsEphemerisCount', u32),
662 (
'roverSbasCount', u32),
663 (
'baseSbasCount', u32),
664 (
'baseAntennaCount', u32),
665 (
'ionUtcAlmCount', u32)
669 timeStart = systime.time()
681 if refIns
is not None:
682 print(
"#%2d Opening: Ref INS %s" % (index, directory))
684 fileMask =
"LOG_REF_INS*.dat" 687 print(
"#%2d Opening: %s %s" % (index, serialNumber, directory))
689 fileMask =
"LOG_" + serialNumber +
"*.sdat" 691 if not os.path.isdir(directory):
692 print(
"Directory doesn't exist!")
699 raise Exception(
'Load Error: .sdat files not found.')
705 self.
loadTime = systime.time() - timeStart
706 print(
"Load time: %.2fs" % (self.
loadTime))
709 for key, item
in self.
data.iteritems():
710 if not isinstance(item, np.ndarray):
713 for field
in [
'towMs',
'timeOfWeekMs',
'tow']:
714 if field
in item.dtype.names:
715 if (np.diff(item[field].astype(np.int64)) < 0).any():
716 idx = np.argmin(np.diff(item[field].astype(np.int64)))
717 print(
"\033[93m" +
"Time went backwards in ", key,
r"!!!, removing all data " + (
"before" if idx < len(item[field])/2.0
else "after") +
"\033[0m")
718 if idx < len(item[field])/2.0:
719 self.
data[key] = item[idx +1:]
721 self.
data[key] = item[:idx]
722 ms_multiplier = 1000.0
if 'Ms' in field
else 1.0
723 if (np.diff(item[field]) > 3600 * ms_multiplier).any():
724 print(
"\033[93m" +
"greater than 1 minute gap in ", key,
" data, assuming GPS fix was acquired during data set, and chopping data"+
"\033[0m")
725 idx = np.argmax(np.diff(item[field])) + 1
726 self.
data[key] = item[idx:]
739 for key, item
in self.
data[name].iteritems():
740 self.
data[name][key] = np.array(item)
741 if 'ins2' in self.
data.keys():
747 valid_types = [1, 2, 3, 4, 5, 6, 123]
748 valid_receiver_indexes = [1, 2, 3, 4]
753 buf = np.fromfile(f, np.uint8, count=cHdr[
'dataSize'])
754 for i
in range(sHdr[
'dCount']):
756 hdr_size = np.dtype(dtypeGpsRaw).itemsize
757 gps_raw_header = buf[pointer:pointer + hdr_size].view(dtypeGpsRaw)
762 type = gps_raw_header[
'type'][0]
763 count = gps_raw_header[
'count'][0]
764 receiverIndex = gps_raw_header[
'receiverIndex'][0]
765 assert (type
in valid_types
and receiverIndex
in valid_receiver_indexes)
766 if dati.name
not in self.
data.keys():
767 self.
data[dati.name] = {
'dataSerNum': [gps_raw_header[
'dataSerNum'][0]],
768 'receiverIndex': [receiverIndex],
773 self.
data[dati.name][
'dataSerNum'].append(gps_raw_header[
'dataSerNum'][0])
774 self.
data[dati.name][
'receiverIndex'].append(gps_raw_header[
'receiverIndex'][0])
775 self.
data[dati.name][
'type'].append(type)
776 self.
data[dati.name][
'count'].append(count)
778 print(
"invalid raw gps header: type=", type,
"count = ", count,
"receiverIndex = ", receiverIndex)
779 self.
data[dati.name][
'corrupt_data'] += 1
782 if type == RAW_DATA_OBS:
784 bytes_in_payload = np.dtype(dtypeObsD).itemsize * count
785 obs = buf[pointer:pointer + bytes_in_payload].view(dtypeObsD)
786 pointer += bytes_in_payload
787 if 'obs' not in self.
data[dati.name]:
788 self.
data[dati.name][
'obs'] = np.rec.array(obs)
790 self.
data[dati.name][
'obs'] = np.hstack((self.
data[dati.name][
'obs'], np.rec.array(obs)))
792 print(
"badly formed raw gps data - DID: %d type: Obs, count: %d, actual: %f" %
793 (did, count, (len(buf) - 8) / (float(np.dtype(dtypeObsD).itemsize))))
794 self.
data[dati.name][
'corrupt_data'] += 1
798 with open(filename,
'rb')
as f:
802 cHdr = np.fromfile(f, dtype=self.
dtCnkHdr, count=1)
804 count = cHdr[
'dataSize']
806 if np.shape(cHdr)[0] == 0
or cHdr[
'marker'][0] != 0xFC05EA32:
811 sHdr = np.fromfile(f, dtype=self.
dtCnkSubHdr, count=1)
814 did = sHdr[
'dHdr'][
'id'][0]
815 dsize = sHdr[
'dHdr'][
'size'][0]
821 print(
"==============================================================================")
822 print(
" - ERROR - Data ID " + str(did) +
" out of range " + str(
823 self.
DID_COUNT) +
". Please add missing DID definitions to ISToolsDataSorted.pyx.")
824 print(
"==============================================================================")
832 if dsize == (dati.dtype.itemsize - 4):
835 cDat = np.fromfile(f, dati.dtype, count=sHdr[
'dCount'])
837 if dati.name
in self.
data.keys():
840 self.
data[dati.name] = np.concatenate([self.
data[dati.name], cDat])
843 self.
data[dati.name] = cDat
846 elif dati.dtype == dtypeGpsRaw:
851 print(
"==============================================================================")
852 print(
" - ERROR - Data ID", did,
"(" + dati.name +
") mismatched size. Read", dsize,
"expected", dati.dtype.itemsize - 4)
853 print(
"==============================================================================")
856 cDat = np.fromfile(f, np.uint8, count=cHdr[
'dataSize'][0])
861 print(
"Undefined DID: ", did)
862 cDat = np.fromfile(f, np.uint8, count=cHdr[
'dataSize'][0])
878 def loadData(self, directory=None, serialNumbers=None, refIns=None, startDev=0, devCount=-1):
882 timeLoadStart = systime.time()
886 raise Exception(
'refIns not supported right now.')
888 if directory
is not None:
890 directory = directory.replace(
'\\',
'/')
899 selectionFileName =
'selection.txt' 900 if os.path.exists(selectionFileName):
901 with open(selectionFileName)
as f:
902 lines = f.read().splitlines()
905 directory += lines[0].replace(
'\\',
'/')
909 for serNum
in lines[1:]:
913 serialNumbers.append(serNum)
916 files = os.listdir(directory)
917 if not any(
".sdat" in s
for s
in files):
922 if len(fname) >= 15
and fname[0:2] ==
'20' and fname[8:9] ==
'_':
923 dTime = int(fname[0:8] + fname[9:15])
933 print(
"Loading Data: ", directory)
936 if serialNumbers
is None or serialNumbers == []:
938 files = os.listdir(directory)
941 if str.find(
'.sdat') != -1:
942 str = str.replace(
'.sdat',
'')
943 if str.find(
'LOG_SN') != -1:
945 if not str
in serNums:
947 elif str.find(
'LOG_PR') != -1:
948 str = str.replace(
'LOG_',
'')
949 str = str[:str.find(
'_')]
950 if not str
in serNums:
952 serialNumbers = serNums
954 count = len(serialNumbers)
958 raise Exception(
'Load Error: .sdat files not found.')
961 if devCount > 0
and devCount < count:
963 endIndex = min(startDev + count, len(serialNumbers))
968 for i
in range(startDev, endIndex):
969 device =
cDevice(i, directory, serialNumbers[i], refIns)
973 self.
loadTime = systime.time() - timeLoadStart
974 print(
"Total load time: %.2fs" % (self.
loadTime))
983 size = np.shape(gpsWeek)
984 if size
and size[0] > 1:
988 gpsWeek = np.max(gpsWeek)
995 gpsEpoch = (1980, 1, 6, 0, 0, 0)
998 epochTuple = gpsEpoch + (-1, -1, 0)
999 t0 = systime.mktime(epochTuple) - systime.timezone
1000 tdiff = (gpsWeek * secsInWeek) + gpsSOW - leapSecs
1006 sizes = np.array([a.itemsize
for a
in arrays])
1007 offsets = np.r_[0, sizes.cumsum()]
1009 joint = np.empty((n, offsets[-1]), dtype=np.uint8)
1010 for a, size, offset
in zip(arrays, sizes, offsets):
1011 joint[:, offset:offset + size] = a.view(np.uint8).reshape(n, size)
1012 dtype = sum((a.dtype.descr
for a
in arrays), [])
1013 return joint.ravel().view(dtype)
1018 newdtype = sum((a.dtype.descr
for a
in arrays), [])
1019 newrecarray = np.empty(len(arrays[0]), dtype=newdtype)
1021 for name
in a.dtype.names:
1022 newrecarray[name] = a[name]
1036 self.
__flt.pqr =
None 1037 self.
__flt.acc =
None 1038 self.
__flt.pqrNoBias =
None 1039 self.
__flt.accNoBias =
None 1040 self.
__flt.barNoBias =
None 1048 for j
in range(0, 2):
1049 self.
i[j].pqr =
None 1050 self.
i[j].acc =
None 1053 if 'I' in self.
v.dtype.names:
1054 self.
i[0].pqr = self.
v[
'I'][
'pqr'][:, 0, :]
1055 self.
i[1].pqr = self.
v[
'I'][
'pqr'][:, 1, :]
1056 self.
i[0].acc = self.
v[
'I'][
'acc'][:, 0, :]
1057 self.
i[1].acc = self.
v[
'I'][
'acc'][:, 1, :]
1060 if 'theta1' in self.
v.dtype.names
and 'theta2' in self.
v.dtype.names:
1061 divDt = 1.0 / self.
v[
'dt']
1062 self.
i[0].pqr = self.
v[
'theta1']
1063 self.
i[1].pqr = self.
v[
'theta2']
1064 self.
i[0].acc = self.
v[
'vel1']
1065 self.
i[1].acc = self.
v[
'vel2']
1067 for i
in range(0, 2):
1068 for a
in range(0, 3):
1069 self.
i[i].pqr[:, a] *= divDt
1070 self.
i[i].acc[:, a] *= divDt
1073 if self.
__flt.acc
is None:
1075 return self.
__flt.acc
1078 if self.
__flt.pqr
is None:
1080 return self.
__flt.pqr
1083 if 'pqrNoBias' in self.
v.dtype.names
and self.
__flt.pqrNoBias
is None:
1084 self.
__flt.pqrNoBias = ft.lpfNoDelay(self.
v[
'pqrNoBias'], self.
cornerFreqHz, time=self.
v[
'time'])
1085 return self.
__flt.pqrNoBias
1088 if 'accNoBias' in self.
v.dtype.names
and self.
__flt.accNoBias
is None:
1089 self.
__flt.accNoBias = ft.lpfNoDelay(self.
v[
'accNoBias'], self.
cornerFreqHz, time=self.
v[
'time'])
1090 return self.
__flt.accNoBias
1093 if 'mslBarNoBias' in self.
v.dtype.names
and self.
__flt.barNoBias
is None:
1094 self.
__flt.mslBarNoBias = ft.lpfNoDelay(self.
v[
'mslBarNoBias'], self.
cornerFreqHz, time=self.
v[
'time'])
1095 return self.
__flt.mslBarNoBias
1115 if not 'euler' in self.
v.dtype.names
and 'q' in self.
v.dtype.names:
1118 dtypeeuler = np.dtype([(
'euler', (np.float, 3))])
1119 e = pose.quat2eulerArray(self.
v[
'q'])
1120 euler = np.ndarray(np.shape(e)[0], dtype=dtypeeuler, buffer=e)
1123 if not 'q' in self.
v.dtype.names
and 'euler' in self.
v.dtype.names:
1126 dtypeq = np.dtype([(
'q', (np.float, 4))])
1127 q = pose.euler2quatArray(self.
v[
'euler'])
1128 quat = np.ndarray(np.shape(q)[0], dtype=dtypeq, buffer=q)
1134 self.
__velNED = np.zeros(np.shape(self.
v[
'uvw']))
1137 DCM = pose.eulerDCM(self.
v[
'euler'][i, :])
1138 velNED = np.dot(DCM.T, self.
v[
'uvw'][i, :])
1145 self.
__course = np.arctan2(self.velNED[:, 1], self.velNED[:, 0])
1150 if self.
__ned is None:
1151 self.
__ned = pose.lla2ned(refLla, self.
v[
'lla'])
1156 self.
__ecef = pose.lla2ecef(self.
v[
'lla'])
1163 return np.sqrt(np.square(self.
v[
'uvw'][:, 0]) +
1164 np.square(self.
v[
'uvw'][:, 1]))
1167 return np.sqrt(np.square(self.
v[
'uvw'][:, 0]) +
1168 np.square(self.
v[
'uvw'][:, 1]) +
1169 np.square(self.
v[
'uvw'][:, 2]))
1184 accBias=np.r_[0, 0, 0],
1185 pqrBias=np.r_[0, 0, 0],
1186 rotate=np.r_[0, 0, 0]):
1190 self.
__flt.pqr =
None 1191 self.
__flt.acc =
None 1193 if accBias[0] != 0
or accBias[1] != 0
or accBias[2] != 0:
1194 self.
v[
'acc'] += accBias
1196 if pqrBias[0] != 0
or pqrBias[1] != 0
or pqrBias[2] != 0:
1197 self.
v[
'pqr'] += pqrBias
1199 if rotate[0] != 0
or rotate[1] != 0
or rotate[2] != 0:
1200 self.
v[
'acc'] = pose.vectorRotateInertialToBody2(self.
v[
'acc'], rotate)
1201 self.
v[
'pqr'] = pose.vectorRotateInertialToBody2(self.
v[
'pqr'], rotate)
1204 if self.
__flt.pqr
is None:
1206 return self.
__flt.pqr
1209 if self.
__flt.acc
is None:
1211 return self.
__flt.acc
1227 self.
v[
'euler'][:, 0] += self.
__rotate[0]
1228 self.
v[
'euler'][:, 1] += self.
__rotate[1]
1229 self.
v[
'euler'][:, 2] += self.
__rotate[2]
1232 if self.
__ned is None:
1233 self.
__ned = pose.lla2ned(refLla, self.
v[
'lla'])
1238 self.
__nedDotDot = ft.derivative(self.
v[
'time'], self.
v[
'nedDot'], delta=2)
1245 if self.
__uvw is None:
1246 self.
__uvw = pose.vectorRotateInertialToBody(self.
v[
'nedDot'], self.
v[
'euler'])
1259 self.
__acc.ned =
None 1262 if self.
__ned is None:
1263 self.
__ned = pose.lla2ned(refLla, self.
v[
'lla'])
1267 if self.
__acc.ned
is None:
1270 self.
__acc.ned = ft.meanDerivative(self.
v[
'time'], self.
v[
'vel.ned'], 2, 2)
1271 return self.
__acc.ned
1282 self.
ned = pose.lla2ned(refLla, _v[
'lla'])
1299 if 'obs' in _v.keys():
1302 self.
obstime = np.array([np.datetime64(int(np.round((t[
'time'] + t[
'sec'])*1000000)),
'us')
for t
in _v[
'obs'][
'time']])
1303 except OverflowError
as e:
1324 if self.
__acc is None:
1326 self.
__acc.time = self.time
1328 self.
__acc.ned = ft.meanDerivative(self.time, self.
v[
'ned'], 2, 2)
1366 if 'tow' in _v.dtype.names:
1369 if 'towMs' in _v.dtype.names:
1403 self.
accNed.refHdg = np.arctan2(self.
v[
'accNed'][
'ref'][:, 1], self.
v[
'accNed'][
'ref'][:, 0])
1404 self.
accNed.insHdg = np.arctan2(self.
v[
'accNed'][
'ins'][:, 1], self.
v[
'accNed'][
'ins'][:, 0])
1406 self.
lla.refNed = pose.lla2ned(refLla, _v[
'lla'][
'ref'])
1407 self.
lla.insNed = pose.lla2ned(refLla, _v[
'lla'][
'ins'])
1419 if 'magTowMs' in _v.dtype.names:
1424 def lla2kml(time, lla, serialNumber, kmlFileName="log.kml", **kwargs):
1425 kml = simplekml.Kml()
1427 color = kwargs.pop(
'color', simplekml.Color.yellow)
1428 altitudeMode = kwargs.pop(
'altitudeMode', simplekml.constants.AltitudeMode.absolute)
1429 timeStep = kwargs.pop(
'timeStep', 0)
1434 for i
in range(0, np.shape(lla)[0]):
1435 latLon.append((lla[i, 1], lla[i, 0], lla[i, 2]))
1444 if time[i] >= tNext:
1447 if time[i] >= lNext:
1448 if timeStep > lNext:
1452 pt = kml.newpoint(name=
"%.2f" % time[i], coords=[latLon[i]])
1454 pt = kml.newpoint(coords=[latLon[i]])
1455 pt.style.iconstyle.color = color
1456 pt.style.iconstyle.scale = 0.4
1457 pt.style.labelstyle.scale = 0.6
1458 pt.altitudemode = altitudeMode
1461 ls = kml.newlinestring(name=
"Tracks", description=serialNumber +
" tracks", coords=latLon)
1465 ls.altitudemode = altitudeMode
1466 ls.style.linestyle.width = 2
1467 ls.style.linestyle.color = color
1468 kml.save(kmlFileName)
1477 result.align =
cObj()
1478 result.align.coarse =
cObj()
1479 result.align.good =
cObj()
1480 result.align.fine =
cObj()
1483 result.align.coarse.att = (istatus >> 0) & 1
1484 result.align.coarse.vel = (istatus >> 1) & 1
1485 result.align.coarse.pos = (istatus >> 2) & 1
1488 result.align.good.att = (istatus >> 4) & 1
1489 result.align.good.vel = (istatus >> 5) & 1
1490 result.align.good.pos = (istatus >> 6) & 1
1491 result.align.fine.att = (istatus >> 7) & 1
1494 result.usingGps = (istatus >> 8) & 1
1495 result.usingMag = (istatus >> 11) & 1
1498 result.navMode = (istatus >> 12) & 1
1501 result.solutionStatus = (istatus >> 16) & 0x7
1504 result.magActiveCalSet = (istatus >> 20) & 1
1505 result.magRecalibrating = (istatus >> 22) & 1
1506 result.magInterOrBadCal = ((istatus >> 23) & 1) != 1
1511 result.rtosTaskPeriodOverrun = (istatus >> 29) & 1
1512 result.generalFault = (istatus >> 31) & 1
1522 result.motionGyrSig = (hstatus >> 0) & 0x1
1523 result.motionAccSig = (hstatus >> 1) & 0x1
1524 result.motionGyrDev = (hstatus >> 2) & 0x1
1525 result.motionAccDev = (hstatus >> 3) & 0x1
1528 result.satellite_rx = (hstatus >> 4) & 0x1
1531 result.saturationGyr = (hstatus >> 8) & 0x1
1532 result.saturationAcc = (hstatus >> 9) & 0x1
1533 result.saturationMag = (hstatus >> 10) & 0x1
1534 result.saturationBaro = (hstatus >> 11) & 0x1
1537 result.saturationHistory = (hstatus >> 12) & 0x1
1540 result.errComTxLimited = (hstatus >> 16) & 0x1
1541 result.errComRxOverrun = (hstatus >> 17) & 0x1
1542 result.errGpsTxLimited = (hstatus >> 18) & 0x1
1543 result.errGpsRxOverrun = (hstatus >> 19) & 0x1
1546 result.comParseErrCount = (hstatus >> 20) & 0xF
1549 result.selfTestFault = (hstatus >> 24) & 0x1
1550 result.errTemperature = (hstatus >> 25) & 0x1
1553 result.faultWatchdogReset = (hstatus >> 28) & 0x1
1554 result.faultBODReset = (hstatus >> 29) & 0x1
1555 result.faultPORReset = (hstatus >> 30) & 0x1
1556 result.faultCPUErrReset = (hstatus >> 31) & 0x1
GeneratorWrapper< T > range(T const &start, T const &end, T const &step)