Skip to content

Commit 4817782

Browse files
committed
[irteus/irtmodel.l] support :fat option in self-collision-check (#147)
1 parent e7ca4ef commit 4817782

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

irteus/irtmodel.l

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,10 +2396,18 @@
23962396
)
23972397
pairs))
23982398
(:self-collision-check
2399-
(&key (mode :all) (pairs (send self :collision-check-pairs)) (collision-func 'pqp-collision-check))
2399+
(&key (mode :all) (pairs (send self :collision-check-pairs)) (collision-func 'pqp-collision-check) (distance-func 'pqp-collision-distance) (fat nil))
2400+
"calculate self collision chaeck
2401+
:mode (:all or :first) ; returns first collided link pair of all collided link pair
2402+
:pairs (list (cons <link1> <link2>) ....) ; linke pair to be checked
2403+
:fat (number) if number is set, any link pair that has smaller distance than this fat threshold will regard as collided"
24002404
(let ((cpairs) (col-count 0))
24012405
(dolist (p pairs)
2402-
(let ((colp (/= (funcall collision-func (car p) (cdr p)) 0)))
2406+
(let ((colp
2407+
(cond ((numberp fat)
2408+
(< (car (funcall distance-func (car p) (cdr p) :fat fat)) fat))
2409+
(t
2410+
(/= (funcall collision-func (car p) (cdr p)) 0)))))
24032411
(when colp
24042412
(incf col-count)
24052413
(if (eq mode :first)

irteus/test/robot-model-usage.l

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@
6868
))
6969
))
7070

71+
(deftest test-collision-check
72+
(let ()
73+
(send *robot* :reset-pose)
74+
(assert (null (send *robot* :self-collision-check :pairs (list (cons (send *robot* :link :lleg-link5) (send *robot* :link :rleg-link5))))) "this is saf pose")
75+
(assert (null (send *robot* :self-collision-check :pairs (list (cons (send *robot* :link :lleg-link5) (send *robot* :link :rleg-link5))) :fat 49)) "distance value is 50 > 49")
76+
(assert (send *robot* :self-collision-check :pairs (list (cons (send *robot* :link :lleg-link5) (send *robot* :link :rleg-link5))) :fat 51) "closest distance is 50 < 51")
77+
))
78+
7179

7280
(run-all-tests)
7381
(exit)

0 commit comments

Comments
 (0)