set terminal postscript eps enhanced color solid 
set terminal postscript landscape
set output "|ps2pdf - jointDataPlot.pdf"
#set output "|epstopdf --filter > jointDataPlot.pdf"

set datafile missing "NaN"
#show datafile missing

set pointsize 0.5

set title "joint angle"
set ylabel "angle [rad]"
set xlabel "time [milliseconds]"
set grid
set offsets 0, 0, 0.1, 0.1
plot  "jointDataTrace" using 1:2 title 'angle setpoint' with dots linewidth 5, "jointDataTrace" using 1:9 title 'sensed angle' with lines linewidth 2

set title "joint encoder ticks"
set ylabel "encoder ticks"
set xlabel "time [milliseconds]"
set grid
set offsets 0, 0, 0.01, 0.01
plot  "jointDataTrace" using 1:8 title 'encoder setpoint' with dots linewidth 5, "jointDataTrace" using 1:10 title 'sensed encoder' with lines linewidth 2

set title "joint velocity"
set ylabel "velocity [rad/s]"
set xlabel "time [milliseconds]"
set grid
set offsets 0, 0, 0.2, 0.2
plot  "jointDataTrace" using 1:3 title 'velocity setpoint' with dots linewidth 5, "jointDataTrace" using 1:11 title 'sensed velocity' with lines linewidth 2

set title "joint rounds per minute"
set ylabel "rpm"
set xlabel "time [milliseconds]"
set grid
set offsets 0, 0, 1, 1
plot  "jointDataTrace" using 1:4 title 'rpm setpoint' with dots linewidth 5, "jointDataTrace" using 1:12 title 'sensed rpm' with lines linewidth 2

set title "joint current"
set ylabel "current [ampere]"
set xlabel "time [milliseconds]"
set grid
set offsets 0, 0, 0.1, 0.1
plot  "jointDataTrace" using 1:5 title 'current setpoint' with dots linewidth 5, "jointDataTrace" using 1:13 title 'sensed current' with lines linewidth 2

set title "joint torque"
set ylabel "torque [Nm]"
set xlabel "time [milliseconds]"
set grid
set offsets 0, 0, 0.01, 0.01
plot  "jointDataTrace" using 1:6 title 'torque setpoint' with dots linewidth 5, "jointDataTrace" using 1:14 title 'sensed torque' with lines linewidth 2

set title "ramp generator velocity setpoint"
set ylabel "velocity setpoint"
set xlabel "time [milliseconds]"
set grid
set offsets 0, 0, 0.01, 0.01
plot  "jointDataTrace" using 1:7 title 'ramp generator velocity setpoint' with dots linewidth 5

unset datafile

set multiplot 
set xlabel ""
set title ""

set size 1, 0.25
set origin 0.0,0.25
set yrange [-0.1:1.1]
set ytics 1
set ylabel "velocity mode"
set grid
plot "jointDataTrace" using 1:23 title '' with lines linewidth 3

set size 1, 0.25
set origin 0.0,0.5
set yrange [-0.1:1.1]
set ytics 1
set ylabel "position mode"
set grid
plot "jointDataTrace" using 1:24 title '' with lines linewidth 3

set size 1, 0.25
set origin 0.0,0.75
set yrange [-0.1:1.1]
set ytics 1
set ylabel "torque mode"
set grid
plot "jointDataTrace" using 1:25 title '' with lines linewidth 3

unset multiplot

set multiplot 
set xlabel ""
set title ""

set size 1, 0.25
set origin 0,0
set yrange [-0.1:1.1]
set ytics 1
set ylabel "over current"
set grid
plot "jointDataTrace" using 1:16 title '' with lines linewidth 3

set size 1, 0.25
set origin 0.0,0.25
set yrange [-0.1:1.1]
set ytics 1
set ylabel "under voltage"
set grid
plot "jointDataTrace" using 1:17 title '' with lines linewidth 3

set size 1, 0.25
set origin 0.0,0.5
set yrange [-0.1:1.1]
set ytics 1
set ylabel "over voltage"
set grid
plot "jointDataTrace" using 1:18 title '' with lines linewidth 3

set size 1, 0.25
set origin 0.0,0.75
set yrange [-0.1:1.1]
set ytics 1
set ylabel "over temperature"
set grid
plot "jointDataTrace" using 1:19 title '' with lines linewidth 3

unset multiplot


set multiplot 
set xlabel ""
set title ""

set size 1, 0.25
set origin 0,0
set yrange [-0.1:1.1]
set ytics 1
set ylabel "motor halted"
set grid
plot "jointDataTrace" using 1:20 title '' with lines linewidth 3

set size 1, 0.25
set origin 0.0,0.25
set yrange [-0.1:1.1]
set ytics 1
set ylabel "hall sensor error"
set grid
plot "jointDataTrace" using 1:21 title '' with lines linewidth 3

set size 1, 0.25
set origin 0.0,0.5
set yrange [-0.1:1.1]
set ytics 1
set ylabel "position reached"
set grid
plot "jointDataTrace" using 1:26 title '' with lines linewidth 3

set size 1, 0.25
set origin 0.0,0.75
set yrange [-0.1:1.1]
set ytics 1
set ylabel "initialized"
set grid
plot "jointDataTrace" using 1:27 title '' with lines linewidth 3

unset multiplot

set multiplot 
set xlabel ""
set title ""

set size 1, 0.25
set origin 0,0
set yrange [-0.1:1.1]
set ytics 1
set ylabel "timeout"
set grid
plot "jointDataTrace" using 1:28 title '' with lines linewidth 3

set size 1, 0.25
set origin 0.0,0.25
set yrange [-0.1:1.1]
set ytics 1
set ylabel "i2t exeeded"
set grid
plot "jointDataTrace" using 1:29 title '' with lines linewidth 3


unset multiplot


