-
Notifications
You must be signed in to change notification settings - Fork 3
/
plot_energy.py
63 lines (46 loc) · 1.84 KB
/
plot_energy.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
#!/usr/bin/env python
""" plot_energy.py
Plot power & energy consumption of the enav dataset
Author: Olivier Lamarre <[email protected]>
Affl.: Space and Terrestrial Autonomous Robotic Systems Laboratory
University of Toronto
Date: February 10, 2019
"""
import sys
import argparse
import matplotlib.pyplot as plt
sys.path.append("..")
from rosbag_data_load import FetchEnergyDataset
# Parse bag file name
parser = argparse.ArgumentParser()
parser.add_argument("-b", "--bag_file", help="path to rosbag file")
args = parser.parse_args()
if __name__ == "__main__":
# Fetch data
bag_obj = FetchEnergyDataset(args.bag_file)
power_data = bag_obj.load_energy_data(rel_time=True)
# Plot data
plt.figure(1)
ax1 = plt.subplot(411)
plt.plot(power_data[:,0], power_data[:,1], label="Left driver")
plt.plot(power_data[:,0], power_data[:,3], label="Right driver")
plt.ylabel('Voltage (V)')
plt.title("Left and right motor drivers voltages, currents, \n power and total energy spent vs time")
plt.legend(loc='upper right')
plt.subplot(412, sharex=ax1)
plt.plot(power_data[:,0], power_data[:,2], label="Left driver")
plt.plot(power_data[:,0], power_data[:,4], label="Right driver")
plt.ylabel('Current (A)')
plt.legend(loc='upper right')
plt.subplot(413, sharex=ax1)
plt.plot(power_data[:,0], power_data[:,5], label="Left driver")
plt.plot(power_data[:,0], power_data[:,6], label="Right driver")
plt.ylabel('Power (W)')
plt.legend(loc='upper right')
plt.subplot(414, sharex=ax1)
plt.plot(power_data[:,0], power_data[:,7]/3600, label="Left driver")
plt.plot(power_data[:,0], power_data[:,8]/3600, label="Right driver")
plt.xlabel('Time (s)')
plt.ylabel('Energy (Wh)')
plt.legend(loc='upper right')
plt.show()