1 '''
2 Created on 08.09.2016
3
4 @author: johanneskinzig
5 '''
6
7 from DroneDataConversion import DroneDataConversion
8 import matplotlib
9 matplotlib.use('TkAgg')
10 import matplotlib.pyplot as plt
11
12
14 """Use matplotlib to plot the graphs"""
15
17 """Get instances and prepare vars"""
18
19
20 flightDataProvider = DroneDataConversion.BebopFlightDataManager(pud_file)
21
22 self.sec, self.lat, self.lon, self.alt, self.spe, self.bat = flightDataProvider.passFlightData()
23
25 """Plot battery usage against time"""
26 battery_plt = plt
27 fig_bat = battery_plt.figure("Battery Usage")
28 battery_plt.title('Battery Usage (%)')
29 battery_plot = fig_bat.add_subplot(111)
30 battery_plot.plot(self.sec, self.bat, color='#A901DB', linewidth=2.0)
31 battery_plot.set_xlabel('Time (ms)')
32 battery_plot.set_ylabel('Battery Usage (%)')
33 battery_plt.show(block=False)
34
36 """Plot altitude against time"""
37 altitude_plt = plt
38 fig_alt = altitude_plt.figure('Altitude (m)')
39 plt.title('Altitude (m)')
40 altitude_plot = fig_alt.add_subplot(111)
41 altitude_plot.plot(self.sec, self.alt, color='#00BFFF', linewidth=2.0)
42 altitude_plot.set_xlabel('Time (ms)')
43 altitude_plot.set_ylabel('Altitude (m)')
44 plt.show(block=False)
45
47 """Plot speed against time"""
48 speed_plt = plt
49 fig_speed = speed_plt.figure('Speed (m/s)')
50 speed_plt.title('Speed (m/s)')
51 speed_plot = fig_speed.add_subplot(111)
52 speed_plot.plot(self.sec, self.spe, color='#01DFA5', linewidth=2.0)
53 speed_plot.set_xlabel('Time (ms)')
54 speed_plot.set_ylabel('Speed (m/s)')
55 speed_plt.show(block=False)
56
58 """Plot Track -- experimental only"""
59 track_plt = plt
60 fig_track = track_plt.figure('Track, lat against lon')
61 track_plt.title('Track, lat against lon')
62 track_plot = fig_track.add_subplot(111)
63 track_plot.plot(self.lon, self.lat, color='#01DFA5', linewidth=2.0)
64 track_plot.set_xlabel('lon')
65 track_plot.set_ylabel('lat')
66 track_plt.show(block=False)
67
68 if __name__ == "__main__":
69 filepath = "DroneDataFiles/BebopFourthFlight_2016_08_01.json"
70 print("File: " + filepath)
71 plot_data = Plotlib(filepath)
72 plot_data.plotAltitude()
73 plot_data.plotBatteryUsage()
74 plot_data.plotSpeed()
75 plot_data.plotTrack()
76