[Dprglist] Visualizing data [was: PID]

David Anderson davida at smu.edu
Sat Oct 3 09:33:06 PDT 2020


Hi Murray,


On 10/3/20 8:23 AM, Christian M Netter via DPRGlist wrote:
> David Anderson seems to have a (as an outside observer) very quick process to
> get data into GnuPlot,

It's actually pretty trivial to use gnuplot if you are comfortable with 
Linux.  Here's what I did to plot your log data. First, data from your 
html file were cut and pasted to a flat ASCII file named 
"murray_log-20200929.txt."

Then, because Linux uses white space as a column separator by default,  
a few places had to be modified which was done like this:

$ cat murray_log-20200929.txt | grep error | sed 's/=/= /g'

which passes through the lines which have the word "error" in them and 
extends the "error=" and "D=" labels by an extra space so they are seen 
by the parser as separate fields.

That output was piped to a gawk command that printed out only the data 
values of interest and not the accompanying ASCII labels:

$ cat murray_log-20200929.txt | grep error | sed 's/=/= /g' | gawk 
'{print $1,$2,$7,$9,$11,$13,$15,$17}'

Then a separate file was created for the left and right motors by 
grep'ing on the terms "pid:port" and "pid:stbd" so the whole thing for 
the port motor looks like this:

$ cat murray_log-20200929.txt | grep error | sed 's/=/= /g' | gawk 
'{print $1,$2,$7,$9,$11,$13,$15,$17}' | grep "pid:port" > port.dat

The process of graphing these data with gnuplot is then just a matter of 
plotting the fields of interest with gnuplot's "plot" command:

gnuplot> plot "port.dat" using ($1):($3) title "Error" with lines, \
         "port.dat" using ($1):($4) title "P " with lines, \
         "port.dat" using ($1):($7) title "Setpt" with lines, \
         "port.dat" using ($1):($8) title "Output" with lines

Each of these lines uses the first field, the line number, as the 
horizontal X value, and the given field as the Y value.  If the log file 
is created with a time stamp as the first entry and white space (or 
commas) as the field separators, then none of the data preprocessing 
steps would be necessary,  and the graphs could be generated by gnuplot 
directly from the log files with just a single command, as above.

cheers

David








More information about the DPRGlist mailing list