-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_joints.py
52 lines (36 loc) · 1012 Bytes
/
plot_joints.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
import sys
import csv
import numpy as np
from matplotlib import pyplot as plt
if len(sys.argv) < 2:
sys.exit(1)
folder = sys.argv[1]
if folder[-1] != "/":
folder = folder + "/"
file_name = folder + "joints_positions.csv"
with open(file_name) as f:
reader = csv.reader(f)
rows = [r for r in reader][1:]
joints = {}
for r in rows:
name = r[0]
t = float(r[1])
pos = float(r[2])
if name not in joints.keys():
joints[name] = [], []
if pos != 0.0:
joints[name][0].append(t)
joints[name][1].append(pos)
# L0 R0 L1 R1
joint_names = ['whisker_' + side + str(i) + '_joint'
for i in range(2) for side in 'LR']
fig, ax = plt.subplots(2, 2, sharex=True, sharey=True)
ax = ax.ravel()
for i, joint_name in enumerate(joint_names):
joint = joints[joint_name]
plt.tight_layout()
ax[i].set_title(joint_name)
ax[i].set_xlabel('$t$ (s)')
ax[i].set_ylabel('$angle$ (rad)')
ax[i].plot(joint[0], joint[1])
plt.show()