collab/pb-hal
git clone https://git.julia.blue/collab/pb-hal
9cbe263
master
1#!/usr/bin/env python3 2import matplotlib .pyplot as plt 3import numpy as np 4from scipy .interpolate import spline 5import sys 6 7if len (sys .argv )< 2 : 8"Please pass a log file as input" ) 9sys .exit () 10 11f = open (sys .argv [1 ]) 12current = f .readline () 13while current : 14points = [] 15plt .title (f .readline ().strip ()) 16current = f .readline () 17currentTime = 0 18while current .strip (): 19points .append (list (map (float ,current .strip ().split (' ' )))) 20points [- 1 ][0 ]+= currentTime 21currentTime = points [- 1 ][0 ] 22current = f .readline () 23if not len (points ): 24continue 25 26# Removes tail if data stays constant after reaching setpoint 27while len (points )> 5 and points [- 1 ][1 ]== points [- 3 ][1 ]: 28del (points [- 1 ]) 29 30del points [0 ] 31x = np .array ([i [0 ]for i in points ]) 32y = [] 33for i in range (1 ,len (points [0 ])): 34y .append ([j [i ]for j in points ]) 35# Interpolation is fun and pretty but we kind of want exact data for tuning 36# prettyX = np.linspace(x.min(), x.max(), 300) # number of points to interpolate 37# prettyY = spline(x, y, prettyX) 38plt .tight_layout () 39for i in y : 40plt .plot (x ,i ) 41plt .legend (["P" ,"I" ,"D" ,"Output" ]) 42# plt.plot(prettyX, prettyY) 43plt .show ()