-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_flight.py
executable file
·105 lines (70 loc) · 2.85 KB
/
plot_flight.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 11 08:13:07 2020
@author: rschmehl
"""
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy.io import loadmat
plt.close('all')
mpl.rcParams['figure.figsize'] = 10, 8
import scipy.io
def read_variables_from_matlab_file(filename, locations):
# Load the MATLAB file
mat = scipy.io.loadmat(filename)
mat = mat['logData_FCC114_1']
# Initialize a dictionary to hold the variable values
variable_values = {}
# Loop over the specified locations
for location_name, location_vars in locations.items():
# Get the data from the current location
location_data = mat[location_name][0,0]['packetData'][0,0]
# Initialize a dictionary to hold the variable values for this location
location_variable_values = {}
# Extract the time variable
location_variable_values['time'] = mat[location_name][0,0]['time'][0,0]
# Loop over the variable names for this location and extract the corresponding data
for variable_name in location_vars:
variable_data = location_data[variable_name][0,0]
location_variable_values[variable_name] = variable_data
# Add the location variable values to the overall dictionary
variable_values[location_name] = location_variable_values
return variable_values
#%% Read Variables
# Example usage
filename = 'logData_FCC114_1.mat'
locations = {
'NavigationData': ['positionNED', 'velocityNED'],
'ProcessedSensorData': ['trueAirspeed', 'angleOfAttack', 'sideSlip','angleOfAttackValid'],
'WinchData': ['length_total', 'length_on_drum', 'tether_speed', 'tether_tension','state']
}
data = read_variables_from_matlab_file(filename, locations)
positionNED= data['NavigationData']['positionNED']
velocityNED = data['NavigationData']['velocityNED']
time_nav = data['NavigationData']['time']-data['NavigationData']['time'][0]
aoa = data['ProcessedSensorData']['angleOfAttack']
aoaValid = data['ProcessedSensorData']['angleOfAttackValid']
time_winch = data['WinchData']['time']-data['WinchData']['time'][0]
tether_speed = data['WinchData']['tether_speed']
tether_tension = data['WinchData']['tether_tension']
length_total = data['WinchData']['length_total']
#%%
valid = aoaValid.astype(bool).flatten()
plt.figure()
plt.plot(time_nav[valid], positionNED[valid,0])
plt.xlabel('Time [s]')
plt.ylabel('x [m]')
plt.figure()
plt.plot(time_nav[valid], aoa[valid]*180/np.pi)
plt.xlabel('Time [s]')
plt.ylabel('Angle of Attack [deg]')
start = 30000
plt.figure()
plt.plot(time_winch[start:], tether_tension[start:])
plt.xlabel('Time [s]')
plt.ylabel('Tether Tension [N]')
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot(-positionNED[valid,0], -positionNED[valid,1], -positionNED[valid,2])