Created
July 13, 2015 13:57
-
-
Save garaemon/58f8117a1af88e01997e to your computer and use it in GitHub Desktop.
drc timetable visualization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import matplotlib.patches as mpatches | |
| import matplotlib.pyplot as plt | |
| from matplotlib.dates import DateFormatter, MinuteLocator, SecondLocator | |
| import csv | |
| ax = plt.gca() | |
| # ax.xaxis_date() | |
| # myFmt = DateFormatter('%H:%M:%S') | |
| tasks = ["Vehicle", "Reset", "Door", "Valve", "Drill", "Stair"] | |
| labels = ["driving", "handling", "manipulation", "head", "walking", "stop", "reset"] | |
| colors = ["b", "g", "r", "c", "m", "y", "k"] | |
| with open("/home/lueda/Downloads/drc_timetable.csv") as f: | |
| reader = csv.reader(f) | |
| reader.next() | |
| prev_task = None | |
| for row in reader: | |
| if not row[5]: | |
| break | |
| robot_state = row[5] | |
| task = row[3] | |
| start_time = int(row[0]) | |
| end_time = start_time + 1 | |
| y = labels.index(robot_state) # 0-6 | |
| plt.hlines([y], start_time, end_time, linewidth=50, color=colors[y]) | |
| plt.hlines(7, start_time, end_time, linewidth=50, color=colors[tasks.index(task)]) | |
| prev_task = task | |
| plt.grid() | |
| plt.yticks(range(-1, len(labels) + 1), [''] + labels + ['Task', '']) | |
| plt.ylim(-1, len(labels) + 1) | |
| plt.xlabel('Time') | |
| plt.ylabel('Robot State') | |
| #plt.legend(handles=[mpatches.Patch(label=task, color=colors[tasks.index(task)]) for task in tasks]) | |
| plt.legend([mpatches.Patch(label=task, color=colors[tasks.index(task)]) for task in tasks], tasks) | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment