Skip to content

Commit

Permalink
[irteus/irtmodel.l] support :fat option in self-collision-check (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-okada committed Jul 20, 2015
1 parent e7ca4ef commit bde2fee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 10 additions & 2 deletions irteus/irtmodel.l
Original file line number Diff line number Diff line change
Expand Up @@ -2396,10 +2396,18 @@
)
pairs))
(:self-collision-check
(&key (mode :all) (pairs (send self :collision-check-pairs)) (collision-func 'pqp-collision-check))
(&key (mode :all) (pairs (send self :collision-check-pairs)) (collision-func 'pqp-collision-check) (distance-func 'pqp-collision-distance) (min-distance nil))
"calculate self collision chaeck
:mode (:all or :first) ; returns first collided link pair of all collided link pair
:pairs (list (cons <link1> <link2>) ....) ; linke pair to be checked
:min-distance (number) if number is set, any link pair that has smaller distance than this fat threshold will regard as collided"
(let ((cpairs) (col-count 0))
(dolist (p pairs)
(let ((colp (/= (funcall collision-func (car p) (cdr p)) 0)))
(let ((colp
(cond ((numberp min-distance)
(< (car (funcall distance-func (car p) (cdr p) :fat fat)) min-distance))
(t
(/= (funcall collision-func (car p) (cdr p)) 0)))))
(when colp
(incf col-count)
(if (eq mode :first)
Expand Down
8 changes: 8 additions & 0 deletions irteus/test/robot-model-usage.l
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
))
))

(deftest test-collision-check
(let ()
(send *robot* :reset-pose)
(assert (null (send *robot* :self-collision-check :pairs (list (cons (send *robot* :link :lleg-link5) (send *robot* :link :rleg-link5))))) "this is saf pose")
(assert (null (send *robot* :self-collision-check :pairs (list (cons (send *robot* :link :lleg-link5) (send *robot* :link :rleg-link5))) :min-distance 49)) "distance value is 50 > 49")
(assert (send *robot* :self-collision-check :pairs (list (cons (send *robot* :link :lleg-link5) (send *robot* :link :rleg-link5))) :min-distance 51) "closest distance is 50 < 51")
))


(run-all-tests)
(exit)

0 comments on commit bde2fee

Please sign in to comment.