Skip to content

Commit 377c574

Browse files
authored
Merge pull request #571 from k-okada/error-check
[:self-collision-check] ignore links which do not have :faces
2 parents 2b71745 + f8f46f9 commit 377c574

File tree

4 files changed

+62
-14
lines changed

4 files changed

+62
-14
lines changed

irteus/CBULLET.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ long BT_MakeCapsuleModel(double radius, double height)
117117
long BT_MakeMeshModel(double *verticesPoints, long numVertices)
118118
{
119119
btConvexHullShape* pshape = new btConvexHullShape();
120+
if (numVertices == 0) {
121+
fprintf(stderr, "BT_MakeMeshModel with numVertices == 0\n");
122+
}
120123
#define SHRINK_FOR_MARGIN false
121124
if (SHRINK_FOR_MARGIN) {
122125
// Shrink vertices for default margin CONVEX_DISTANCE_MARGIN,

irteus/bullet.l

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
(setq m
5656
(btmakemeshmodel
5757
(scale 1e-3 ;; [m]
58-
(apply #'concatenate float-vector
59-
(mapcar #'(lambda (v) (send b :inverse-transform-vector v)) (send b :vertices))))
58+
(apply #'float-vector (apply #'concatenate cons
59+
(mapcar #'(lambda (v) (send b :inverse-transform-vector v)) (send b :vertices)))))
6060
(length (send b :vertices))
6161
))
6262
(if (> margin 0) (btsetmargin m (* 1e-3 margin)))
@@ -74,8 +74,8 @@
7474
(setq m
7575
(btmakemeshmodel
7676
(scale 1e-3 ;; [m]
77-
(apply #'concatenate float-vector
78-
(mapcar #'(lambda (v) (send self :inverse-transform-vector v)) vs)))
77+
(apply #'float-vector (apply #'concatenate cons
78+
(mapcar #'(lambda (v) (send self :inverse-transform-vector v)) vs))))
7979
(length vs)
8080
))
8181
(btsetmargin m fat)
@@ -89,8 +89,8 @@
8989
(setq m
9090
(btmakemeshmodel
9191
(scale 1e-3 ;; [m]
92-
(apply #'concatenate float-vector
93-
(mapcar #'(lambda (v) (send self :inverse-transform-vector v)) vs)))
92+
(apply #'float-vector (apply #'concatenate cons
93+
(mapcar #'(lambda (v) (send self :inverse-transform-vector v)) vs))))
9494
(length vs)
9595
))
9696
(btsetmargin m fat)

irteus/irtmodel.l

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,15 +2661,25 @@
26612661
pairs))
26622662
(:self-collision-check
26632663
(&key (mode :all) (pairs (send self :collision-check-pairs)) (collision-func 'collision-check))
2664-
(let ((cpairs) (col-count 0))
2664+
(let ((cpairs) (col-count 0) (invalid-links))
26652665
(dolist (p pairs)
2666-
(let ((colp (/= (funcall collision-func (car p) (cdr p)) 0)))
2667-
(when colp
2668-
(incf col-count)
2669-
(if (eq mode :first)
2670-
(return-from :self-collision-check p)
2671-
(push p cpairs)))
2672-
))
2666+
(if (and (send (car p) :faces) (send (cdr p) :faces))
2667+
(let ((colp (/= (funcall collision-func (car p) (cdr p)) 0)))
2668+
(when colp
2669+
(incf col-count)
2670+
(if (eq mode :first)
2671+
(return-from :self-collision-check p)
2672+
(push p cpairs))))
2673+
(progn
2674+
(when (and (null (send (car p) :faces)) (null (member (car p) invalid-links)))
2675+
(warning-message 3 "skip collision between ~A (~A) because of no faces~%"
2676+
(send (car p) :name) (length (send (car p) :faces)))
2677+
(push (car p) invalid-links))
2678+
(when (and (null (send (cdr p) :faces)) (null (member (cdr p) invalid-links)))
2679+
(warning-message 3 "skip collision between ~A (~A) because of no faces~%"
2680+
(send (cdr p) :name) (length (send (cdr p) :faces)))
2681+
(push (cdr p) invalid-links)))
2682+
))
26732683
cpairs))
26742684
(:calc-grasp-matrix
26752685
(contact-points

irteus/test/test-collision.l

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,22 @@
194194
)
195195
))
196196

197+
(load "models/darwin.l")
198+
;; use add no-face link for euscollada-robot, use darwin-robot to override
199+
(defmethod darwin-robot
200+
;; make collision model from faces or gl-vertices
201+
(:make-collision-model-for-links
202+
(&key (fat 0) ((:links ls) (send self :links)))
203+
;;
204+
;; for append camera links for test code
205+
(let (l)
206+
(setq l (instance bodyset-link :init (make-cascoords) :name "dummy-link"))
207+
(send (car links) :add-child-links l)
208+
(setq links (append links (list l)))
209+
(setq ls (send self :links)))
210+
)
211+
)
212+
197213
(when *collision-algorithm-pqp*
198214

199215
(deftest test-collision-sphere-analytical-pqp
@@ -249,6 +265,7 @@
249265
(test-collision-distance-fat
250266
(body+ (make-cube 200 200 100) (make-cube 100 100 300))
251267
(body+ (make-cube 200 200 100) (make-cube 100 100 300))))
268+
252269
)
253270

254271
(when *collision-algorithm-bullet*
@@ -309,6 +326,24 @@
309326

310327
)
311328

329+
;; not sure why, but put this function within (when *collision-algorithm-pqp* causes errors...
330+
(deftest test-self-collision-check-pqp
331+
(when *collision-algorithm-pqp*
332+
(setq *collision-algorithm* *collision-algorithm-pqp*)
333+
(let (robot)
334+
(setq robot (instance darwin-robot :init))
335+
(send robot :self-collision-check)
336+
)))
337+
338+
339+
(deftest test-self-collision-check-bullet
340+
(when *collision-algorithm-bullet*
341+
(setq *collision-algorithm* *collision-algorithm-bullet*)
342+
(let (robot)
343+
(setq robot (instance darwin-robot :init))
344+
(send robot :self-collision-check)
345+
)))
346+
312347
(eval-when (load eval)
313348
(run-all-tests)
314349
(exit 0))

0 commit comments

Comments
 (0)