-
Notifications
You must be signed in to change notification settings - Fork 1
/
read_odom.py
50 lines (39 loc) · 905 Bytes
/
read_odom.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
# !/usr/bin/python
#
# Example code to read and plot the odometry data.
#
# To call:
#
# python read_odom.py odometry.csv
#
import sys
import matplotlib.pyplot as plt
import numpy as np
def main(args):
if len(sys.argv) < 2:
print 'Please specify odometry file'
return 1
odom = np.loadtxt(sys.argv[1], delimiter = ",")
t = odom[:, 0]
x = odom[:, 1]
y = odom[:, 2]
z = odom[:, 3]
r = odom[:, 4]
p = odom[:, 5]
h = odom[:, 6]
plt.figure()
plt.subplot(1, 2, 1)
plt.scatter(x, y, 1, c=z, linewidth=0)
plt.axis('equal')
plt.title('Odometry position')
plt.colorbar()
plt.subplot(1, 2, 2)
plt.plot(t, r, 'r')
plt.plot(t, p, 'g')
plt.plot(t, h, 'b')
plt.legend(['Roll', 'Pitch', 'Heading'])
plt.title('Odometry rph')
plt.show()
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))