@@ -373,17 +373,17 @@ def apply_inverse_rotation(self, rotmat):
373
373
def plot_gyro (self ):
374
374
xplot = plt .subplot (311 )
375
375
376
- plt .plot (self .gyro [:,0 ], self .gyro [:,1 ])
376
+ plt .plot (self .standard_gyro [:,0 ], self .standard_gyro [:,1 ])
377
377
plt .ylabel ("omega x [rad/s]" )
378
378
379
379
plt .subplot (312 , sharex = xplot )
380
380
381
- plt .plot (self .gyro [:,0 ], self .gyro [:,2 ])
381
+ plt .plot (self .standard_gyro [:,0 ], self .standard_gyro [:,2 ])
382
382
plt .ylabel ("omega y [rad/s]" )
383
383
384
384
plt .subplot (313 , sharex = xplot )
385
385
386
- plt .plot (self .gyro [:,0 ], self .gyro [:,3 ])
386
+ plt .plot (self .standard_gyro [:,0 ], self .standard_gyro [:,3 ])
387
387
#plt.plot(self.integrator.get_raw_data("t") + d2, self.integrator.get_raw_data("z"))
388
388
plt .xlabel ("time [s]" )
389
389
plt .ylabel ("omega z [rad/s]" )
@@ -394,26 +394,26 @@ def plot_acc(self):
394
394
if type (self .acc ) != type (None ):
395
395
xplot = plt .subplot (411 )
396
396
397
- plt .plot (self .acc [:,0 ], self .acc [:,1 ])
397
+ plt .plot (self .standard_acc [:,0 ], self .standard_acc [:,1 ])
398
398
plt .ylabel ("acc x [g]" )
399
399
400
400
plt .subplot (412 , sharex = xplot )
401
401
402
- plt .plot (self .acc [:,0 ], self .acc [:,2 ])
402
+ plt .plot (self .standard_acc [:,0 ], self .standard_acc [:,2 ])
403
403
plt .ylabel ("acc y [g]" )
404
404
405
405
plt .subplot (413 , sharex = xplot )
406
406
407
- plt .plot (self .acc [:,0 ], self .acc [:,3 ])
407
+ plt .plot (self .standard_acc [:,0 ], self .standard_acc [:,3 ])
408
408
#plt.plot(self.integrator.get_raw_data("t") + d2, self.integrator.get_raw_data("z"))
409
409
plt .xlabel ("time [s]" )
410
410
plt .ylabel ("acc z [g]" )
411
411
412
412
plt .subplot (414 , sharex = xplot )
413
413
414
- plt .plot (self .acc [:,0 ], np .sqrt (np .sum (self .acc [:,1 :]** 2 ,1 )))
415
- plt .plot ([0 , self .acc [- 1 ,0 ]], [1.1 ,1.1 ])
416
- plt .plot ([0 , self .acc [- 1 ,0 ]], [0.9 ,0.9 ])
414
+ plt .plot (self .standard_acc [:,0 ], np .sqrt (np .sum (self .standard_acc [:,1 :]** 2 ,1 )))
415
+ plt .plot ([0 , self .standard_acc [- 1 ,0 ]], [1.1 ,1.1 ])
416
+ plt .plot ([0 , self .standard_acc [- 1 ,0 ]], [0.9 ,0.9 ])
417
417
#plt.plot(self.integrator.get_raw_data("t") + d2, self.integrator.get_raw_data("z"))
418
418
plt .xlabel ("time [s]" )
419
419
plt .ylabel ("mag [g]" )
@@ -756,8 +756,8 @@ def __init__(self):
756
756
self .filename_pattern = "(?i).*\.mp4"
757
757
758
758
self .variants = {
759
- "smo4k" : [0 ],
760
- "insta360 oner" : [0 ]
759
+ "smo4k" : [22 ],
760
+ "insta360 oner" : [22 ]
761
761
}
762
762
763
763
self .variant = "smo4k"
@@ -783,19 +783,19 @@ def guess_log_from_videofile(self, videofile):
783
783
def extract_log_internal (self , filename ):
784
784
785
785
if self .variant == "smo4k" :
786
- gyro_data_input , self .acc = insta360_util .get_insta360_gyro_data (filename , filterArray = [])
786
+ self . gyro , self .acc = insta360_util .get_insta360_gyro_data (filename , filterArray = [])
787
787
elif self .variant == "insta360 oner" :
788
- gyro_data_input , self .acc = insta360_util .get_insta360_gyro_data (filename , filterArray = [], revertIMU = False )
788
+ self . gyro , self .acc = insta360_util .get_insta360_gyro_data (filename , filterArray = [], revertIMU = False )
789
789
else :
790
790
# Assume SMO4K - For no real reason....
791
- gyro_data_input , self .acc = insta360_util .get_insta360_gyro_data (filename , filterArray = [])
791
+ self . gyro , self .acc = insta360_util .get_insta360_gyro_data (filename , filterArray = [])
792
792
793
793
# Coverting gyro to XYZ to -Z,-X,Y
794
- self .gyro = np .empty ([len (gyro_data_input ), 4 ])
795
- self .gyro [:,0 ] = gyro_data_input [:,0 ][:]
796
- self .gyro [:,1 ] = gyro_data_input [:,2 ][:] * - 1
797
- self .gyro [:,2 ] = gyro_data_input [:,3 ][:]
798
- self .gyro [:,3 ] = gyro_data_input [:,1 ][:] * - 1
794
+ # self.gyro = np.empty([len(gyro_data_input), 4])
795
+ # self.gyro[:,0] = gyro_data_input[:,0][:]
796
+ # self.gyro[:,1] = gyro_data_input[:,2][:] * -1
797
+ # self.gyro[:,2] = gyro_data_input[:,3][:]
798
+ # self.gyro[:,3] = gyro_data_input[:,1][:] * -1
799
799
800
800
return True
801
801
@@ -999,20 +999,30 @@ def extract_log_internal(self, filename):
999
999
1000
1000
#print(tscale, gscale, ascale)
1001
1001
1002
+
1003
+ header = line .split ("," )
1004
+ header_length = len (header )
1005
+
1006
+ has_gyro = "gx" in header
1007
+ has_acc = "ax" in header
1008
+ has_mag = "mx" in header
1009
+
1010
+
1002
1011
# Get data
1003
1012
lines = csvfile .readlines ()
1004
1013
1005
1014
data_list = []
1006
1015
1007
1016
for line in lines :
1008
1017
splitdata = [float (x ) for x in line .split ("," )]
1009
- t = splitdata [0 ] * tscale
1018
+ if len (splitdata ) == header_length : # make sure no missing fields
1019
+ t = splitdata [0 ] * tscale
1010
1020
1011
- gx = splitdata [1 ] * gscale
1012
- gy = splitdata [2 ] * gscale
1013
- gz = splitdata [3 ] * gscale
1021
+ gx = splitdata [1 ] * gscale
1022
+ gy = splitdata [2 ] * gscale
1023
+ gz = splitdata [3 ] * gscale
1014
1024
1015
- data_list .append ([t , gx , gy , gz ])
1025
+ data_list .append ([t , gx , gy , gz ])
1016
1026
1017
1027
self .gyro = np .array (data_list )
1018
1028
@@ -1155,6 +1165,7 @@ def guess_log_type_from_log(logfile, check_data = False):
1155
1165
#"test_clips/DJIG0043wiebe.mp4",
1156
1166
#"test_clips/GX016015.MP4",
1157
1167
#"test_clips/nivim_insta360.mp4",
1168
+ "test_clips/smo4k_calibration.mp4" ,
1158
1169
"test_clips/Tiago_Ferreira_5_inch.mp4" ,
1159
1170
"test_clips/MasterTim17_caddx.mp4" ,
1160
1171
"test_clips/starling2.MOV" ,
0 commit comments