Compare commits
2 commits
a1e647d1be
...
27cec19b80
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27cec19b80 | ||
|
|
9d2b5bd8d2 |
1 changed files with 14 additions and 10 deletions
24
seth_hk.py
24
seth_hk.py
|
|
@ -163,16 +163,16 @@ def calculate_heading(mag, phi, theta):
|
|||
mag_world = np.matmul(Rz(-phi), np.matmul(Ry(theta-np.pi), np.matmul(Rz(phi), mag)))
|
||||
mag_world_psi = np.arctan2(mag_world[1], mag_world[0]) + declination # angle mag vector in wf, x axis in wf + delta because TN is delta left of the MN (=mag vector)
|
||||
if mag_world_psi <= 0:
|
||||
mag_world_psi = 2*np.pi + mag_world_psi # because compass counts clock-wise and atan2 counter CW
|
||||
mag_world_psi = abs(mag_world_psi) # because compass counts clock-wise and atan2 counter CW
|
||||
else:
|
||||
pass
|
||||
mag_world_psi = 2*np.pi - mag_world_psi
|
||||
heading = mag_world_psi * 180/np.pi # heading in degrees (0deg = True North)
|
||||
return heading
|
||||
|
||||
|
||||
def calculate_ads(acc_raw, mag_raw):
|
||||
acc, mag = calibrate_vectors(acc_raw, mag_raw)
|
||||
pitch = math.atan(acc[0]/acc[2])
|
||||
pitch = math.atan(acc[0]/acc[2]) # math package returns in radians
|
||||
roll = math.atan(acc[1]/acc[2])
|
||||
phi = math.atan2(acc[1], acc[2])
|
||||
g_length_xy = math.sqrt(acc[0]**2+acc[1]**2+acc[2]**2)
|
||||
|
|
@ -254,12 +254,16 @@ def main(input):
|
|||
pres.append(b[1]) # may only be two P lines in one interval
|
||||
|
||||
if l[:2] == 'H ': # One every 12s
|
||||
ts = int(l.split()[1])
|
||||
if fp and fp.split('/')[-1] == "2025-08-14-longtime-23e.AHA" and ts > 1800000000: # timestamps wrong in this file
|
||||
ts = l.split()[1]
|
||||
if ts == 'nan':
|
||||
time.append(ts)
|
||||
else:
|
||||
ts = int(ts)
|
||||
if fp and fp.split('/')[-1] == "2025-08-14-longtime-23e.AHA" and ts != 'nan' and ts > 1800000000: # timestamps wrong in this file
|
||||
ts -= 1963615744
|
||||
if i < 2000 and ts >= 3718824668-1963615744:
|
||||
ts -= 12*3600
|
||||
if fp and fp.split('/')[-1] == '2025-08-08-seth-17e.AHA' and ts > 1800000000:
|
||||
if fp and fp.split('/')[-1] == '2025-08-08-seth-17e.AHA' and ts != 'nan' and ts > 1800000000:
|
||||
ts -= 2138848512
|
||||
if i < 500 and ts > 3893525631-2138848512:
|
||||
ts -= 16404
|
||||
|
|
@ -273,10 +277,10 @@ def main(input):
|
|||
if sl == '0' or sl == '1': # only operate if slice numbers are correct
|
||||
dorn_temps.extend(hdorn(l))
|
||||
|
||||
if l[:8] == 'I2C-MAG ':
|
||||
mag_raw = [float(num) for num in l.split()[2:]]
|
||||
if l[:8] == 'I2C-ACC ':
|
||||
acc_raw = [float(num) for num in l.split()[2:]]
|
||||
if l[:8] == 'I2C-MAG ' and l.split()[1] == '19':
|
||||
mag_raw = [int(num) for num in l.split()[2:]]
|
||||
if l[:8] == 'I2C-ACC ' and l.split()[1] == '19':
|
||||
acc_raw = [int(num) for num in l.split()[2:]]
|
||||
|
||||
if l[:4] == 'C64 ':
|
||||
heading, roll, pitch = calculate_ads(acc_raw, mag_raw)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue