next up previous
Next: 5 視覚システム Up: 4 物体操作の記述 Previous: 4.3 ハノイの塔の操作 sample/hanoimanipulation.l

4.4 ハノイの塔の例 demo8.l


(load "hanoimanipulation.l")
(load "hanoi.l")

(setq table-a (hanoi-table :pos #f(300 200 0)))
(setq table-b (hanoi-table :pos #f(300 0 0)))
(setq table-c (hanoi-table :pos #f(300 -200 0)))

(setq *tables* (list table-a table-b table-c))

(setq *hanoi-draw-number* 0)
(setq *hanoi-kdraw-file* "sarm")
(hanoi-init 3 table-a)

(setq *robot* sarm)
(setq *worlds* (append (list *robot*) *disks* *tables*))

(defun sarm-eps nil
  (bdraw "sarm-separated-links.eps")
  (bdraw "sarm-separated-links-axis.eps" t)
  (worlds :p "sarm-park.eps")  
  (worlds :p :larm 4 80 "sarm-park-link-axis.eps")  
  (worlds :s "sarm-special.eps")
  (worlds :p :larm :l0 :l7 :l8 "sarm-park-all-axis.eps")  
  (worlds :s :larm :l0 :l7 :l8 "sarm-special-all-axis.eps")  
  )

(defun bdraw (&optional kdraw axis)
  (let* ((bb (copy-object (append sarm-links
                                  (list sarm7 sarm8 sarm0))))
         (ll bb))
    (cls)
    (send (pop ll) :translate #f(-50 0 300) :world)
    (send (pop ll) :translate #f(200 0 -250) :world)
    (send (pop ll) :translate #f(150 0 0) :world)
    (send (pop ll) :translate #f(-50 0 -200) :world)
    (send (pop ll) :translate #f(-150 100 -150) :world)
    (send (pop ll) :translate #f(-150 100 -150) :world)
    (send (pop ll) :translate #f(50 0 0) :world)
    (send (pop ll) :translate #f(50 0 0) :world)
    (send-all bb :worldcoords)

    (send *viewer* :viewsurface :line-width 2)
    (hid *viewer* bb)
    (send *viewer* :viewsurface :line-width 4)
    (if axis (dolist (b bb) (draw-axis 50 b)))
    (send *viewer* :viewsurface :line-width 1)

    (when (stringp kdraw)
      (kdraw kdraw
             (send *viewer* :viewsurface :line-width 2)
             (hid *viewer* bb)
             (send *viewer* :viewsurface :line-width 4)
             (if axis (dolist (b bb) (draw-axis 50 b)))
             (send *viewer* :viewsurface :line-width 1)
             (send *viewer* :pane)
             ))
    ))

;(hanoi-show)
;(sarm-eps)
;(hanoi-eps)
物体操作の手順を記述する方法として,ハノイの塔の例を取り上げる.ハノイ の塔の問題は,何枚かの円板を移動する際に,円板の上にはそれより大きい円 板を積み重ねることができず,退避するための場所が一箇所だけ利用できると いうものである. この問題をロボットが解く場合に, これらのルールも与えて手順を生成させる 方法と,人間の側でルールを租借して手順を生成する方法を与える場合が 考えられる.後者の方法の場合には,人間の方で再帰的な手続きとして 円板が何枚あろうとも成り立つプログラムを与える方法や,現在の円板の枚数に だけ対応できるプログラムを与える方法がありうる. 前者の再帰的な手続きというのは, n枚の円板があるとして,一番下の円板以外の n-1枚の円板を退避場所へ全部移動してから,一番下の円板を目標位置へ 移動し,退避場所にあるn-1枚の円板をその一番下の円板の上へ移すという 手順になる.n-1枚の円板を移動する時にn枚の移動を行うプログラムを 再帰的に利用することができるからである. 生成される各段階の動作は,どの対象物をつかみ(grasp), どの台の上に積み重ねるか(pile-on)という記述になる. pile-onには台が指定されるが,その台の上には円板が載っている場合も あり,その台の一番上にある円板が何であり,その円板の上の面上へ すでに把握している円板の下の面を置くという移動動作が生成 される必要がある. 3枚の円板での例を図12にそのシーケンスを示す.
図 12: ハノイの塔の実験環境モデル
(move (park)) (grasp (disk 1)) (pile-on table-b)
\includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq0.eps} \includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq1.eps} \includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq2.eps} (grasp (disk 2)) (pile-on table-c) (grasp (disk 1))
\includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq3.eps} \includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq4.eps} \includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq5.eps} (pile-on table-c) (grasp (disk 3)) (pile-on table-b)
\includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq6.eps} \includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq7.eps} \includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq8.eps} (grasp (disk 1)) (pile-on table-a) (grasp (disk 2))
\includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq9.eps} \includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq10.eps} \includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq11.eps} (pile-on table-b) (grasp (disk 1)) (move (park))
\includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq12.eps} \includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq13.eps} \includegraphics[height=2.6cm]{/home/inaba/text/iwanami/inaba/chap4/hanoi-seq14.eps}
一般に,作業環境中の物体の移動管理を行い,その形状モデルを 持つ場合には,このような物体を積み重ねるという操作手順の 記述は単純化しやすい問題となる.n枚の円板の高さが違って いても対応ができることになる. 人間が操作手順を再帰的手続きとして与えるのでは無い方法として, 初期状態が ((on (disk 3) table-a) (on (disk 2) (disk 3)) (on (disk 1) (disk 2))) から, ((on (disk 3) table-b) (on (disk 2) (disk 3)) (on (disk 1) (disk 2))) という目標状態へ移動するという問題で,違いを解決するために, (disk 3)をtable-bへ置くために, (move (disk 3) table-b)を行えばすべてが解決されるように (move A B)という手続きを一般化する方法も考えられる.

generated through LaTeX2HTML. M.Inaba 平成18年5月7日