Skip to content

Commit

Permalink
add more example on graph-view/online plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
k-okada committed Nov 30, 2021
1 parent e534112 commit a312557
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions irteus/demo/walk-motion.l
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,20 @@
tm-list (reverse zmp-list) (reverse cog-list) (reverse ref-zmp-list2))
)
(unless (or (null x::*display*) (= x::*display* 0))
;; graph-view
(graph-view (list (reverse zmp-list) (reverse cog-list) (reverse ref-zmp-list2)) tm-list
:xlabel "Time [s]" :ylabel "ZMP X [mm]"
:keylist '("card zmp" "cog" "refmp"))
;; online-version
(setq *gnuplot* (gnuplot))
(send *gnuplot* :proc-length (length tm-list))
(mapcar #'(lambda (tm zmp cog refzmp)
(send *gnuplot* :proc-one (list zmp cog refzmp)
:direction :left
:title '("cart zmp" "cog" "refzmp")
))
tm-list (reverse zmp-list) (reverse cog-list) (reverse ref-zmp-list2))
;; raw-command version
(let ((gp-command-list (list
"set xlabel 'Time [s]';"
"set ylabel 'ZMP X [mm]';"
Expand Down
6 changes: 6 additions & 0 deletions irteus/irtmath.l
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,12 @@
#|
(defun lms-draw (r point-list)
(let ()
;; graph-view
(graph-view (list (mapcar #'vector-y point-list)) (mapcar #'vector-x point-list)
:mode "point" :xrange '(0 80) :yrange '(0 50)
:keylist (list "data")
:graph-instance *gnuplot*)
;; raw-command version
(send *gnuplot* :command (format nil "plot [0:80][0:50] ~A * x + ~A title \"regression\", '-' with point title \"data\"~%~Ae"
(/ (elt (car r) 0) (- (elt (car r) 1)))
(/ (cadr r) (- (elt (car r) 1)))
Expand Down
10 changes: 10 additions & 0 deletions irteus/kalmanlib.l
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@
(f (format nil "data_~a.dat" suffix) :direction :output)
(dotimes (i (length x))
(format f "~A ~A~%" (elt x i) (elt y i))))
;; online gnuplotting
(if (not (boundp '*g*))
(send *g* :proc-length (length x)))

;; write estimated data
(with-open-file
Expand All @@ -197,6 +200,13 @@
(setq z (send kf :proc (float-vector (elt x i) (elt y i)) :adaptive t)))
(t
(setq z (send kf :proc (float-vector (elt x i) (elt y i))))))
;; online gnuplotting
(send *g* :proc-one (list (elt y i) (elt z 1) (send kf :error) (aref (send kf :P) 1 1) -0.37727)
:direction :left
:xrange '(0 100)
:yrange '(-0.6 0)
:y2tics (list nil nil t t nil)
:title '("ovserved" "estimated" "error" "P covariance" "baseline"))
(format f "~A ~A ~A ~A~%" (elt x i) (elt z 1) (send kf :error) (aref (send kf :P) 1 1))))

;; write graph data
Expand Down

0 comments on commit a312557

Please sign in to comment.