-
Notifications
You must be signed in to change notification settings - Fork 1
/
contPlot.py
executable file
·87 lines (65 loc) · 2.44 KB
/
contPlot.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
import numpy as np
style.use('science')
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
### this script will run in parallel to the main pybullet code..
### set the flag to give proper legends and title of the plot...
titleFlag = 0
## set 0 for error...
## set 1 for end effector state
## set 2 for forces and torques..
print("I am doing something")
XErrors,YErrors,ZErrors,RollErrors,PitchErrors,YawErrors = [],[],[],[],[],[]
if titleFlag == 0:
print("here")
def animate(i):
csv = np.loadtxt("plot.csv", dtype= float, delimiter= ',')
#print(XErrors)
# for row in csv:
# #print(len(row))
# if len(row) > 1 :
# x,y,z,roll,pitch,yaw = row
# XErrors.append(x)
# YErrors.append(y)
# ZErrors.append(z)
# RollErrors.append(roll)
# PitchErrors.append(pitch)
# YawErrors.append(yaw)
ax1.clear()
ax1.set_title('Error Over Time')
ax1.plot(csv[:,0], label = 'X Error')
ax1.plot(csv[:,1], label = 'Y Error')
ax1.plot(csv[:,2], label = 'Y Error')
ax1.plot(csv[:,3], label = 'Roll Error')
ax1.plot(csv[:,4],label = 'Pitch Error')
ax1.plot(csv[:,5], label = 'Yaw Error')
ax1.legend()
ani = animation.FuncAnimation(fig,animate,interval = 300)
plt.show()
if titleFlag == 1:
def animate(i):
csv = np.loadtxt("plot.csv", dtype= float, delimiter= ',')
XPos,YPos,ZPos,RollPos,PitchPos,YawPos = [],[],[],[],[],[]
for row in csv:
if len(row) >1 :
x,y,z,roll,pitch,yaw = row
XPos.append(x)
YPos.append(y)
ZPos.append(z)
RollPos.append(roll)
PitchPos.append(pitch)
YawPos.append(yaw)
ax1.clear()
ax1.set_title('Position State Over Time')
ax1.plot(XPos, label = 'XPos')
ax1.plot(YPos, label = 'YPos')
ax1.plot(ZPos, label = 'ZPos')
ax1.plot(RollPos, label = 'RollPos')
ax1.plot(PitchPos,label = 'PitchPos')
ax1.plot(YawPos, label = 'YawPos')
ax1.legend()
ani = animation.FuncAnimation(fig,animate,interval = 300)
plt.show()