next up previous
Next: 6 探索プログラム例 Up: ソフトウェア特論 講義資料 ロボットのソフトウェア Previous: 4 座標系モデル

5 三次元形状モデラ

euslispの大きな特徴は三次元形状モデラを内蔵している点です. このモデラは多面体モデラです.多面体のモデルを表現するクラスとしてbody があります.基本立体を作るための手続きとして,make-cube, make-cylinder などがあります. bodyは,

(defclass body
  :super cascaded-coords
  :slots
   (faces         ; 面データ
    edges         ; 辺データ
    vertices      ; 頂点データ
    model-vertices
    box           ; surrounding box
    convexp       ; 凸かどうか
    evertedp      ; ひっくり返っているかどうか
    csg           ; CSG表現
    ))
というように,cascaded-coordsを親クラスとして持つようなクラス定義になっ ています.そのため,cascaded-coordsで定義されていた:assocなどの手続き もbodyのインスタンスに対して適用できることになります.

eus$ (setq b1 (make-cube 30 40 100))
#<body #X27b920 (:cube 30 40 100) 
                0.0 0.0 0.0 / 0.0 0.0 0.0>
eus$ (describe b1)
plist=
((:volume . 1.200000e+05)
 (:centroid . #f(0.0 -9.676299e-08 -9.527433e-07)))
rot=#2f((1.0 0.0 0.0)
        (0.0 1.0 0.0)
        (0.0 0.0 1.0))
pos=#f(0.0 0.0 0.0)
parent=nil
descendants=nil
worldcoords=#<coordinates #X27b710
            0.0 0.0 0.0 / 0.0 0.0 0.0>
manager=#<body #X27b920
          (:cube 30 40 100) 0.0 0.0 0.0 / 0.0 0.0 0.0>
changed=nil
faces=(#<face #X27ba1c (:cube 30 40 100) :bottom>
   #<face #X27bf44 (:cube 30 40 100) :top>
   #<face #X27bab8 (:cube 30 40 100) :side 3 y>
   #<face #X27bbb4 (:cube 30 40 100) :side 2 x>
   #<face #X27bcb0 (:cube 30 40 100) :side 1 -y>
   #<face #X27be0c (:cube 30 40 100) :side 0 -x>)
edges=(
   #<edge #X27baf4 #f(15.0 20.0 -50.0)
                   #f(-15.0 20.0 -50.0)>
   #<edge #X27bf20 #f(15.0 20.0 50.0)
                   #f(-15.0 20.0 50.0)>
   #<edge #X27bbf0 #f(15.0 -20.0 -50.0)
                   #f(15.0 20.0 -50.0)>
   #<edge #X27bc14 #f(15.0 20.0 -50.0)
                   #f(15.0 20.0 50.0)>
   #<edge #X27be84 #f(15.0 -20.0 50.0)
                   #f(15.0 20.0 50.0)>
   #<edge #X27bcec #f(-15.0 -20.0 -50.0)
                   #f(15.0 -20.0 -50.0)>
   #<edge #X27bd10 #f(15.0 -20.0 -50.0)
                   #f(15.0 -20.0 50.0)>
   #<edge #X27bea8 #f(-15.0 -20.0 50.0)
                   #f(15.0 -20.0 50.0)>
   #<edge #X27bde8 #f(-15.0 20.0 50.0)
                   #f(-15.0 20.0 -50.0)>
   #<edge #X27bdac #f(-15.0 20.0 -50.0)
                   #f(-15.0 -20.0 -50.0)>
   #<edge #X27bd88 #f(-15.0 -20.0 -50.0)
                   #f(-15.0 -20.0 50.0)>
   #<edge #X27bee4 #f(-15.0 20.0 50.0)
                   #f(-15.0 -20.0 50.0)>)
vertices=(#f(15.0 20.0 -50.0)
            #f(15.0 20.0 50.0)
            #f(15.0 -20.0 -50.0)
            #f(15.0 -20.0 50.0)
            #f(-15.0 20.0 -50.0)
            #f(-15.0 -20.0 -50.0)
            #f(-15.0 -20.0 50.0)
            #f(-15.0 20.0 50.0))
model-vertices=(#f(15.0 20.0 -50.0)
                  #f(15.0 20.0 50.0)
                  #f(15.0 -20.0 -50.0)
                  #f(15.0 -20.0 50.0)
                  #f(-15.0 20.0 -50.0)
                  #f(-15.0 -20.0 -50.0)
                  #f(-15.0 -20.0 50.0)
                  #f(-15.0 20.0 50.0))
box=#<surrounding-box #X20bc88
     #f(-15.03 -20.04 -50.1)/#f(15.03 20.04 50.1)>
convexp=t
evertedp=nil
csg=((:cube 30 40 100))
nil
このように,多面体を表現するデータにはたくさんの情報が含まれています. また,立体の集合演算も定義されています.和(body+),積(body*),差 (body-)などがあります.ただし,立体の頂点が他の立体の面や辺や頂点上に ある場合にはこの演算は成功しないようになっています.そのため,集合演算 を行なって複雑な形状の立体を作る場合,一方の立体の頂点が他方の立体の辺 や面上にこないように使うということになります.

eus$ (setq b2 (make-cube 100 100 30))
#<body #X27e4d0 (:cube 100 100 30)
                0.0 0.0 0.0 / 0.0 0.0 0.0>
eus$ (setq b3 (body+ b1 b2))
#<body #X27e104 :complex 0.0 0.0 0.0 / 0.0 0.0 0.0>
eus$ (setq b4 (body* b1 b2))
#<body #X24f420 :complex 0.0 0.0 0.0 / 0.0 0.0 0.0>
これらのモデルを表示したのが図1です.
図 1: b1,b3投影図
\includegraphics[height=3.5cm]{/home/inaba/eps/lecture/fig/b1.eps} \includegraphics[height=3.5cm]{/home/inaba/eps/lecture/fig/b3p.eps}
euslispはこのような基本関数やクラスが用意されて,ロボットの 構造モデリングやシミュレーション,ユーザインタフェースなど のプログラミング言語として利用されています.図2 にそのロボットやモデリングの操作パネルを示します.
図 2: 実験ロボットやそのユーザインタフェース
\includegraphics[width=7cm]{/home/inaba/eps/lecture/fig/photo_4humanoids.eps}

\includegraphics[width=7cm]{/home/inaba/eps/lecture/fig/igoidpickview.eps}


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