-
Notifications
You must be signed in to change notification settings - Fork 0
/
showRobot.py
65 lines (55 loc) · 1.43 KB
/
showRobot.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
# -*- coding: utf-8 -*-
"""
show robot: visualize robot state information
Created Mar 2022
@author: Niraj
"""
import numpy as np
import matplotlib.pyplot as plt
import csv
t = np.empty((0))
pos = np.empty((3,0))
euler = np.empty((3,0))
vel = np.empty((3,0))
angvel = np.empty((3,0))
with open("state_estimation/localizeTestLog.csv", 'r') as inFile:
reader = csv.DictReader(inFile)
for row in reader:
t = np.append(t, row['time'])
pos = np.hstack((pos, np.array(row['pos[3]'].split(), dtype=float).reshape((3,1))))
euler = np.hstack((euler, np.array(row['euler[3]'].split(), dtype=float).reshape((3,1))))
vel = np.hstack((vel, np.array(row['vel[3]'].split(), dtype=float).reshape((3,1))))
angvel = np.hstack((angvel, np.array(row['angvel[3]'].split(), dtype=float).reshape((3,1))))
print("Read", pos.shape[1], "data points.")
#Plot position
plt.figure(1)
plt.clf()
ax = plt.subplot(321)
plt.suptitle("State position")
ax.clear()
ax.relim()
ax.autoscale()
plt.ylabel("x")
plt.plot(t, pos[0,:])
#plt.grid()
ax = plt.subplot(323)
plt.ylabel("y")
plt.plot(t, pos[1,:])
#plt.grid()
ax = plt.subplot(325)
plt.ylabel("z")
plt.plot(t, pos[2,:])
#plt.grid()
ax = plt.subplot(322)
plt.ylabel(r'$\alpha$')
plt.plot(t, euler[0,:])
#plt.grid()
ax = plt.subplot(324)
plt.ylabel(r'$\beta$')
plt.plot(t, euler[1,:])
#plt.grid()
ax = plt.subplot(326)
plt.ylabel(r'$\gamma$')
plt.plot(t, euler[2,:])
#plt.grid()
plt.show()