-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_serialData.py
63 lines (52 loc) · 1.66 KB
/
plot_serialData.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
import string
import numpy as np
import math as m
import matplotlib.pyplot as plt
import sys
import csv
filename = sys.argv[1]
with open(filename, 'rb') as csvfile:
reader = csv.reader(csvfile)
[ time_array, angle_pitch, angle_roll, angle_yaw, rate_pitch,
rate_roll, rate_yaw, integr_pitch, integr_roll, integr_yaw,
control_pitch, control_roll, control_yaw, motor_power, battery ] = np.array( list(reader), dtype=float ).T
plt.figure(1)
plt.plot( time_array, rate_yaw, 'y-', label='Rate' )
plt.plot( time_array, angle_yaw, 'g-', label='Angle' )
plt.plot( time_array, integr_yaw, 'k-', label='Integr' )
plt.plot( time_array, control_yaw, 'r-', label='Control' )
plt.ylabel('Angle')
plt.xlabel('Time')
plt.grid()
plt.title('Yaw')
plt.legend()
plt.figure(2)
plt.plot( time_array, rate_roll, 'y-', label='Rate' )
plt.plot( time_array, angle_roll, 'g-', label='Angle' )
plt.plot( time_array, integr_roll, 'k-', label='Integr' )
plt.plot( time_array, control_roll, 'r-', label='Control' )
plt.ylabel('Angle')
plt.xlabel('Time')
plt.grid()
plt.title('Roll')
plt.legend()
plt.figure(3)
plt.plot( time_array, rate_pitch, 'y-', label='Rate' )
plt.plot( time_array, angle_pitch, 'g-', label='Angle' )
plt.plot( time_array, integr_pitch, 'k-', label='Integr' )
plt.plot( time_array, control_pitch, 'r-', label='Control' )
plt.ylabel('Angle')
plt.xlabel('Time')
plt.grid()
plt.title('Pitch')
plt.legend()
plt.figure(4)
motor_power = [float(x) / 20 for x in motor_power]
plt.plot( time_array, motor_power, 'y-', label='Power' )
plt.plot( time_array, battery, 'g-', label='Battery' )
plt.ylabel('Value')
plt.xlabel('Time')
plt.grid()
plt.title('Power')
plt.legend()
plt.show()