-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add eusbullet for using bullet collision function (implement with c defun) #555
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,121 @@ | ||
\section{干渉計算} | ||
|
||
干渉計算には2組の幾何モデルが交差するかを判定する物である. | ||
irteusではノースカロライナ大学のLin氏らのグループにより開発されたPQPを | ||
他言語インターフェースを介して利用できるようにしてある. | ||
(他の干渉計算ソフトウェアパッケージについてはhttp://gamma.cs.unc.edu/research/collision/に詳しい.) | ||
PQPは | ||
(1)2つのモデルが交差するかを判定する衝突検出, | ||
(2)2つのモデル間の最初距離を算出する距離計算, | ||
(3)2つのモデルがある距離以下であるかを判定する近接検証, | ||
等の3つ機能を提供する. | ||
\subsection{干渉計算の概要} | ||
|
||
干渉計算は2組の幾何モデルが交差するかを判定しその距離を求める処理である. | ||
主に以下の2つ機能を提供する. | ||
\begin{itemize} | ||
\item 2つのモデルが交差するかを判定する衝突検出 (collision-check関数) | ||
\item 2つのモデル間の最短距離を算出する距離計算 (collision-distance関数) | ||
\end{itemize} | ||
|
||
irteusでは,他言語インターフェースを介して外部ライブラリを呼び出すことで干渉計算を実行する. | ||
外部ライブラリとして,PQPとBulletの呼び出しが実装されており,デフォルトではPQPが利用される. | ||
以下のように,select-collision-algorithm関数により使用するライブラリを切り替えることができる. | ||
{\baselineskip=10pt | ||
\begin{verbatim} | ||
(select-collision-algorithm *collision-algorithm-pqp*) ;; use PQP | ||
(select-collision-algorithm *collision-algorithm-bullet*) ;; use Bullet | ||
\end{verbatim} | ||
} | ||
|
||
PQPソフトウェアパッケージの使い方はirteus/PQP/README.txtに | ||
書いてあり,irteus/PQP/src/PQP.hを読むことで理解できるようになって | ||
いる. | ||
個々の外部ライブラリの特徴については以降で詳しく説明する. | ||
他の干渉計算ソフトウェアパッケージについては http://gamma.cs.unc.edu/research/collision/に詳しい.(情報が古い可能性があるので注意.例えばBulletは載っていない.) | ||
|
||
\input{irtcollision-func} | ||
|
||
\subsubsection{物体形状モデル同士の干渉計算例} | ||
以下は,collision-checkやcollision-distanceを利用して,2つの立方体の衝突検出と距離計算を行い,最近点どうしを結ぶ線分を描画する例である. | ||
干渉が生じているときにcollision-distance関数で得られる最近点は,PQPとBulletで仕様が異なる.詳しくは以降のBulletに関する説明を参照. | ||
{\baselineskip=10pt | ||
\begin{verbatim} | ||
;; Make models | ||
(setq *b0* (make-cube 100 100 100)) | ||
(setq *b1* (make-cube 100 100 100)) | ||
|
||
;; Case 1 : no collision | ||
(send *b0* :newcoords (make-coords :pos #f(100 100 -100) | ||
:rpy (list (deg2rad 10) (deg2rad -20) (deg2rad 30)))) | ||
(objects (list *b0* *b1*)) | ||
(print (collision-check *b0* *b1*)) ;; Check collision | ||
(let ((ret (collision-distance *b0* *b1*))) ;; Check distance and nearest points | ||
(print (car ret)) ;; distance | ||
(send (cadr ret) :draw-on :flush nil :size 20 :color #f(1 0 0)) ;; nearest point on *b0* | ||
(send (caddr ret) :draw-on :flush nil :size 20 :color #f(1 0 0)) ;; nearest point on *b1* | ||
(send *irtviewer* :viewer :draw-line (cadr ret) (caddr ret)) | ||
(send *irtviewer* :viewer :viewsurface :flush)) | ||
|
||
;; Case 2 : collision | ||
(send *b0* :newcoords (make-coords :pos #f(50 50 -50) | ||
:rpy (list (deg2rad 10) (deg2rad -20) (deg2rad 30)))) | ||
(objects (list *b0* *b1*)) | ||
(print (collision-check *b0* *b1*)) ;; Check collision | ||
(let ((ret (collision-distance *b0* *b1*))) ;; Check distance and nearest points | ||
(print (car ret)) ;; distance | ||
;; In case of collision, nearest points are insignificant values. | ||
(send (cadr ret) :draw-on :flush nil :size 20 :color #f(1 0 0)) ;; nearest point on *b0* | ||
(send (caddr ret) :draw-on :flush nil :size 20 :color #f(1 0 0)) ;; nearest point on *b1* | ||
(send *irtviewer* :viewer :draw-line (cadr ret) (caddr ret)) | ||
(send *irtviewer* :viewer :viewsurface :flush)) | ||
\end{verbatim} | ||
} | ||
|
||
\begin{figure}[htb] | ||
\begin{center} | ||
\includegraphics[width=0.50\columnwidth]{fig/collision.jpg} | ||
\caption{Collision detection} | ||
\end{center} | ||
\end{figure} | ||
|
||
\subsubsection{ロボット動作と干渉計算} | ||
ハンドで物体をつかむ,という動作の静的なシミュレーションを行う場合に手(指)のリンクと対象物体の干渉を調べ,これが起こるところで物体をつかむ動作を停止させるということが出来る. | ||
|
||
{\baselineskip=10pt | ||
\begin{verbatim} | ||
(load "irteus/demo/sample-arm-model.l") | ||
(setq *sarm* (instance sarmclass :init)) | ||
(send *sarm* :reset-pose) | ||
(setq a 42) | ||
(send *sarm* :move-fingers a) | ||
(setq *target* (make-cube 30 30 30)) | ||
(send *target* :translate #f(350 200 400)) | ||
(objects (list *sarm* *target*)) | ||
|
||
(send *sarm* :inverse-kinematics *target* :move-target (send *sarm* :end-coords) :debug-view t) | ||
(while (> a 0) | ||
(if (collision-check-objects | ||
(list (send *sarm* :joint-fr :child-link) | ||
(send *sarm* :joint-fl :child-link)) | ||
(list *target*)) | ||
(return)) | ||
(decf a 0.1) | ||
(send *irtviewer* :draw-objects) | ||
(send *sarm* :move-fingers a)) | ||
(send *sarm* :end-coords :assoc *target*) | ||
|
||
(dotimes (i 100) | ||
(send *sarm* :joint0 :joint-angle 1 :relative t) | ||
(send *irtviewer* :draw-objects)) | ||
(send *sarm* :end-coords :dissoc *target*) | ||
(dotimes (i 100) | ||
(send *sarm* :joint0 :joint-angle -1 :relative t) | ||
(send *irtviewer* :draw-objects)) | ||
\end{verbatim} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This demo does not work, and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, merged. Checked that demo works. |
||
|
||
\subsection{irteusからPQPの呼び出し} | ||
同様の機能が,"irteus/demo/sample-arm-model.l"ファイルの:open-hand, | ||
:close-handというメソッドで提供されている. | ||
|
||
\subsection{PQPによる干渉計算} | ||
|
||
PQPはノースカロライナ大学のLin氏らのグループにより開発された干渉計算ライブラリである. | ||
PQPソフトウェアパッケージの使い方はirteus/PQP/README.txtに | ||
書いてあり,irteus/PQP/src/PQP.hを読むことで理解できるようになっている. | ||
|
||
irteusでPQPを使うためのファイルは | ||
CPQP.C, euspqp.c, pqp.l | ||
からなる. | ||
2つの幾何モデルが衝突してしるか否かを判定するためには, | ||
|
||
{\baselineskip=10pt | ||
\begin{verbatim} | ||
(defun pqp-collision-check (model1 model2 | ||
|
@@ -90,74 +185,20 @@ \subsection{irteusからPQPの呼び出し} | |
る以降,(pqpbeginmodel m)でPQPの幾何モデルのインスタンスを作成し, | ||
(pqpaddtri m v1 v2 v3 id)として面情報を登録している. | ||
|
||
\subsubsection{物体形状モデル同士の干渉計算例} | ||
pqp-collision-checkやpqp-collision-distanceを利用した例を示す. | ||
{\baselineskip=10pt | ||
\begin{verbatim} | ||
;; Make models | ||
(setq *b0* (make-cube 100 100 100)) | ||
(setq *b1* (make-cube 100 100 100)) | ||
|
||
;; Case 1 : no collision | ||
(send *b0* :newcoords (make-coords :pos #f(100 100 -100) | ||
:rpy (list (deg2rad 10) (deg2rad -20) (deg2rad 30)))) | ||
(objects (list *b0* *b1*)) | ||
(print (pqp-collision-check *b0* *b1*)) ;; Check collision | ||
(let ((ret (pqp-collision-distance *b0* *b1*))) ;; Check distance and nearest points | ||
(print (car ret)) ;; distance | ||
(send (cadr ret) :draw-on :flush nil :size 20 :color #f(1 0 0)) ;; nearest point on *b0* | ||
(send (caddr ret) :draw-on :flush nil :size 20 :color #f(1 0 0)) ;; nearest point on *b1* | ||
(send *irtviewer* :viewer :draw-line (cadr ret) (caddr ret)) | ||
(send *irtviewer* :viewer :viewsurface :flush)) | ||
|
||
;; Case 2 : collision | ||
(send *b0* :newcoords (make-coords :pos #f(50 50 -50) | ||
:rpy (list (deg2rad 10) (deg2rad -20) (deg2rad 30)))) | ||
(objects (list *b0* *b1*)) | ||
(print (pqp-collision-check *b0* *b1*)) ;; Check collision | ||
(let ((ret (pqp-collision-distance *b0* *b1*))) ;; Check distance and nearest points | ||
(print (car ret)) ;; distance | ||
;; In case of collision, nearest points are insignificant values. | ||
(send (cadr ret) :draw-on :flush nil :size 20 :color #f(1 0 0)) ;; nearest point on *b0* | ||
(send (caddr ret) :draw-on :flush nil :size 20 :color #f(1 0 0)) ;; nearest point on *b1* | ||
(send *irtviewer* :viewer :draw-line (cadr ret) (caddr ret)) | ||
(send *irtviewer* :viewer :viewsurface :flush)) | ||
\end{verbatim} | ||
} | ||
|
||
\subsection{ロボット動作と干渉計算} | ||
|
||
ハンドで物体をつかむ,という動作の静的なシミュレーションを行う場合に | ||
手(指)のリンクと対象物体の干渉を調べ,これが起こるところで物体をつか | ||
む動作を停止させるということが出来る. | ||
\input{pqp-func} | ||
|
||
{\baselineskip=10pt | ||
\begin{verbatim} | ||
(objects (list *sarm* *target*)) | ||
\subsection{Bulletによる干渉計算} | ||
|
||
(send *sarm* :solve-ik *target* :debug-view t) | ||
(while (> a 0) | ||
(if (pqp-collision-check-objects | ||
(list (send *sarm* :joint-fr :child-link) | ||
(send *sarm* :joint-fl :child-link)) | ||
(list *target*)) | ||
(return)) | ||
(decf a 0.1) | ||
(send *irtviewer* :draw-objects) | ||
(send *sarm* :move-fingers a)) | ||
(send *sarm* :end-coords :assoc *target*) | ||
|
||
(dotimes (i 100) | ||
(send *sarm* :joint0 :joint-angle 1 :relative t) | ||
(send *irtviewer* :draw-objects)) | ||
(send *sarm* :end-coords :dissoc *target*) | ||
(dotimes (i 100) | ||
(send *sarm* :joint0 :joint-angle -1 :relative t) | ||
(send *irtviewer* :draw-objects)) | ||
\end{verbatim} | ||
} | ||
Bulletは物理演算エンジンであり,その一部として干渉計算機能が提供されている. | ||
irteusでBulletを使うためのファイルは | ||
CBULLET.cpp, eusbullet.c, bullet.l | ||
からなる. | ||
関数内部の呼び出し順序はPQPと同様である. | ||
|
||
同様の機能が,"irteus/demo/sample-arm-model.l"ファイルの:open-hand, | ||
:close-handというメソッドで提供されている. | ||
PQPとBulletの違いとして以下が挙げられる. | ||
\begin{itemize} | ||
\item 干渉が生じているときにcollision-distanceを呼ぶと,PQPでは,距離として0が返り,最近点として意味のない点が返される.一方Bulletでは,距離として干渉をなくすために動かすべき最短距離(penetration depthと呼ばれる)が返る.また,最近点としては,干渉をなくすための最短距離の両端の点が返される. | ||
\item PQPは非凸のメッシュモデルをそのまま扱うことができるが,Bulletでは非凸のモデルの凸包を内部で計算しそれを扱っている. | ||
\end{itemize} | ||
|
||
\input{pqp-func} | ||
\input{bullet-func} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add comment why we have to skip this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added comment: 1f4da2f#diff-b4553af39acae935d505c76e139d4aa3R54-R55
(rebase commit into previous)