Skip to content

Add eusbullet for using bullet collision function #538

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

Closed
wants to merge 15 commits into from

Conversation

mmurooka
Copy link
Member

From jsk-ros-pkg/jsk_roseus#604 (comment).

Call bullet collision function from euslisp. Bullet can calculate penetration depth, which cannot be calculated by PQP.
Eusbullet module is added to irteusg, which is same target with PQP.

irteus/test/test-eusbullet-collision.l is called in travis, which compares collision distance result with analytical result for two spheres.
(same with jsk-ros-pkg/jsk_roseus#604 's test: https://user-images.githubusercontent.com/6636600/53302044-7d04d380-389d-11e9-8350-e9d392714962.gif )

BulletCollision/NarrowPhaseCollision/btGjkCollisionDescription.h is contained in libbullet-dev (2.83) of xenial (16.04):
https://packages.ubuntu.com/xenial/amd64/libbullet-dev/filelist
but not contained in libbullet-dev (2.81) of trusty (14.04):
https://packages.ubuntu.com/trusty/amd64/libbullet-dev/filelist
So, eusbullet is build only when pkg-config bullet --modversion is greater or equal to 2.83,
and test-eusbullet-collision.l is not called for travis test of Ubuntu trusty and Debian jessie.
4196ad6

@mmurooka
Copy link
Member Author

mmurooka commented Mar 31, 2019

Travis test No.5 (DOCKER_IMAGE=osrf/ubuntu_armhf:xenial) fails when doing eusbullet test:
https://travis-ci.org/euslisp/jskeus/jobs/513473705
When doing source test-eusbullet-collision.l:

�[0Ktraivs_fold:start:jskeus.source.test-eusbullet-collision.l.test
�[0Ktraivs_time:start:r5dk8dyi
+ irteusgl irteus/test/test-eusbullet-collision.l
configuring by "/home/travis/build/euslisp/jskeus/eus/lib/eusrt.l"
;; readmacro ;; object ;; packsym ;; common ;; constants ;; stream ;; string ;; loader ;; pprint ;; process ;; hashtab ;; array ;; mathtran ;; eusdebug ;; eusforeign ;; coordinates ;; tty ;; history ;; toplevel ;; trans ;; comp ;; builtins ;; par ;; intersection ;; geoclasses ;; geopack ;; geobody ;; primt ;; compose ;; polygon ;; viewing ;; viewport ;; viewsurface ;; hid ;; shadow ;; bodyrel ;; dda ;; helpsub ;; eushelp ;; xforeign ;; Xdecl ;; Xgraphics ;; Xcolor ;; Xeus ;; Xevent ;; Xpanel ;; Xitem ;; Xtext ;; Xmenu ;; Xscroll ;; Xcanvas ;; Xtop ;; Xapplwin 
;; pixword ;; RGBHLS ;; convolve ;; piximage ;; pbmfile ;; image_correlation ;; oglforeign ;; gldecl ;; glconst ;; glforeign ;; gluconst ;; gluforeign ;; glxconst ;; glxforeign ;; eglforeign ;; eglfunc ;; glutil ;; gltexture ;; glprim ;; gleus ;; glview ;; toiv-undefined ;; fstringdouble irtmath irtutil irtc irtgeoc irtgraph ___time ___pgsql irtgeo euspqp pqp irtscene irtmodel irtdyna irtrobot irtsensor irtbvh irtcollada irtpointcloud 
;; extending gcstack 0x2126610[16374] --> 0x235eb30[32748] top=3ca4
eusbullet irtx eusjpeg euspng png irtimage irtglrgb irtgl irtglc irtviewer �[34m
EusLisp 9.26(9cfd655 e52b37f) for Linux created on df671dadf751(Sun Mar 31 09:11:10 UTC 2019)�[0m
TEST-NAME: test-eusbullet-collision-sphere-analytical
  now testing...
�[32mstart testing [test-eusbullet-collision-sphere-analytical]
�[0m;; (make-irtviewer) executed
�[31m;; no display is found. exit from (make-irtviewer)
�[0m;; Segmentation Fault.
+ export TMP_EXIT_STATUS=11
+ TMP_EXIT_STATUS=11
++ expr 32 - 11
+ travis_time_end 21
+ set +x
traivs_time:end:r5dk8dyi:start=1554025318256291017,finish=1554025319527265838,duration=1270974821
�[0K
traivs_fold:end:jskeus.source.test-eusbullet-collision.l.test
�[0K�[21mFunction jskeus.source.test-eusbullet-collision.l.test takes 0 min 1 sec�[0m

When doing compiled test-eusbullet-collision.l:

KFunction jskeus.source.test-eusbullet-collision.l.test takes 0 min 1 secm
Ktraivs_fold:start:jskeus.compiled.test-eusbullet-collision.l.test
Ktraivs_time:start:9ykmto2b
+ irteusgl '(let ((o (namestring (merge-pathnames ".o" "irteus/test/test-eusbullet-collision.l"))) (so (namestring (merge-pathnames ".so" "irteus/test/test-eusbullet-collision.l")))) (compile-file "irteus/test/test-eusbullet-collision.l" :o o) (if (probe-file so) (load so) (exit 1))))'
configuring by "/home/travis/build/euslisp/jskeus/eus/lib/eusrt.l"
;; readmacro ;; object ;; packsym ;; common ;; constants ;; stream ;; string ;; loader ;; pprint ;; process ;; hashtab ;; array ;; mathtran ;; eusdebug ;; eusforeign ;; coordinates ;; tty ;; history ;; toplevel ;; trans ;; comp ;; builtins ;; par ;; intersection ;; geoclasses ;; geopack ;; geobody ;; primt ;; compose ;; polygon ;; viewing ;; viewport ;; viewsurface ;; hid ;; shadow ;; bodyrel ;; dda ;; helpsub ;; eushelp ;; xforeign ;; Xdecl ;; Xgraphics ;; Xcolor ;; Xeus ;; Xevent ;; Xpanel ;; Xitem ;; Xtext ;; Xmenu ;; Xscroll ;; Xcanvas ;; Xtop ;; Xapplwin
;; pixword ;; RGBHLS ;; convolve ;; piximage ;; pbmfile ;; image_correlation ;; oglforeign ;; gldecl ;; glconst ;; glforeign ;; gluconst ;; gluforeign ;; glxconst ;; glxforeign ;; eglforeign ;; eglfunc ;; glutil ;; gltexture ;; glprim ;; gleus ;; glview ;; toiv-undefined ;; fstringdouble irtmath irtutil irtc irtgeoc irtgraph ___time ___pgsql irtgeo euspqp pqp irtscene irtmodel irtdyna irtrobot irtsensor irtbvh irtcollada irtpointcloud
;; extending gcstack 0x2126610[16374] --> 0x235eb30[32748] top=3ca4
eusbullet irtx eusjpeg euspng png irtimage irtglrgb irtgl irtglc irtviewer
EusLisp 9.26(9cfd655 e52b37f) for Linux created on df671dadf751(Sun Mar 31 09:11:10 UTC 2019)m
compiling file: irteus/test/test-eusbullet-collision.l
gcc -g -c -o irteus/test/test-eusbullet-collision.o -DARM -DLinux -Wimplicit -falign-functions=4 -DGCC3  -DGCC  -DTHREADED -DPTHREAD -fpic  -I/home/travis/build/euslisp/jskeus/eus/include -O2 irteus/test/test-eusbullet-collision.c; ld -shared -build-id -o irteus/test/test-eusbullet-collision.so irteus/test/test-eusbullet-collision.o
TEST-NAME: test-eusbullet-collision-sphere-analytical
now testing...
start testing [test-eusbullet-collision-sphere-analytical]
m;; (make-irtviewer) executed
m;; no display is found. exit from (make-irtviewer)
mCall Stack (max depth: 20):
0: at (funcall func)
1: at (funcall func)
2: at (let ((func (symbol-function func-sym)) tm) (send *unit-test* :init-result func-sym) (format t "TEST-NAME: ~A~%" func-sym) (format t "  now testing...~%") (send *unit-test* :increment-test func-sym) (setq tm (now)) (funcall func) (send *unit-test* :set-time-to-current-result (send (now) :elapsed tm)))
3: at (run-test u)
4: at (while #:dolist83 (setq u (pop #:dolist83)) (run-test u))
5: at (let ((u nil) (#:dolist83 (send *unit-test* :functions))) nil (while #:dolist83 (setq u (pop #:dolist83)) (run-test u)) nil)
6: at (dolist (u (send *unit-test* :functions)) (run-test u))
7: at run-all-tests
8: at (load so)
9: at (if (probe-file so) (load so) (exit 1))
10: at (let ((o (namestring (merge-pathnames ".o" "irteus/test/test-eusbullet-collision.l"))) (so (namestring (merge-pathnames ".so" "irteus/test/test-eusbullet-collision.l")))) (compiler:compile-file "irteus/test/test-eusbullet-collision.l" :o o) (if (probe-file so) (load so) (exit 1)))
m/home/travis/build/euslisp/jskeus/eus/LinuxARM/bin/irteusgl unittest-error: float vector expected in (funcall func), exitting...m
m[ERROR] test (funcall func) failed ... (float vector expected 53).m
ALL RESULTS:
TEST-NUM: 2
PASSED:   1
m    FAILURE:  1

@HiroIshida
Copy link

I use this

@@ -25,7 +25,7 @@ if [ "$(which sudo)" == "" ]; then apt-get update && apt-get install -y sudo; el
travis_time_end

travis_time_start setup.apt-get_install
sudo apt-get install -qq -y git make gcc g++ libjpeg-dev libxext-dev libx11-dev libgl1-mesa-dev libglu1-mesa-dev libpq-dev libpng-dev xfonts-100dpi xfonts-75dpi # msttcorefonts could not install on 14.04 travis
sudo apt-get install -qq -y git make gcc g++ libjpeg-dev libxext-dev libx11-dev libgl1-mesa-dev libglu1-mesa-dev libpq-dev libpng-dev xfonts-100dpi xfonts-75dpi pkg-config libbullet-dev # msttcorefonts could not install on 14.04 travis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also update README.md

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated: 7aa804f

}

long callCalcCollisionDistance(long modelAddrA, long modelAddrB,
double *posA, double *quatA, double *posB, double *quatB,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I wrote in mmurooka#1 's commit, I you could not pass (float-vector 0 0 0) to the double * in 32bit machine, it has to be float *. Please check this and if it is not clearly described in manual, we should update.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my understanding, before updating defforein document, more basic Data Types manual is totally incorrect for 64bit machine (especially the following figure), is it right?
pointer

@@ -0,0 +1,33 @@
include Makefile.$(ARCHDIR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irteus/PQP contains all PQP sources, and if we create irteus "BULLET`, then we should include all source.

Otherwise, I think we'd better to create CBULLETC.C and eusbullet.c, which solves float/double issue more cleaner approach -> https://github.com/euslisp/jskeus/blob/master/irteus/euspqp.c#L76-L78

please also consider creating irtcollision.l file that includes

(defmethod cascaded-coords
  (:make-collisionmodel ))
 (defun collision-check)
(defun collision-distance)
(defun collision-check-objects)

and add something like (defun select-collision-algorithm) or `collision-algorithm,

please also remove 'eusbullet' from demo/eusbullet-collision.l, and enable user to compare pqp and bullet

Please consider updating https://jskeus.readthedocs.io/ja/latest/pqp.html, in the first section (call PQP from irteus) is mainly explaining implementation so you can put the end of the document and that of bullet library is not necessary. update pqp-collision-check and other to collision-check version, add collision-check-objects example, and also need explanation of the difference between pqp and bullet.

test code should be run on both pqp/bullet and also we'd like to check for cube/matrix cases.

CC += -m32
LD += -m32
EXELD += -m32
endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently we do not check i386 on travis, but do you need this? do we still running euslisp on 32bit intel machine?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, we do not need intel 32bit. This Makefile.Linux is just copied from PQP/Makefile.Linux.
If these lines should be removed, I can. But it may be beyond this PR, and we can discuss this in new Issue.

irteus/Makefile Outdated
# check bullet version
BULLET_VER_MAJOR:=$(shell pkg-config bullet --modversion | cut -f1 -d.)
BULLET_VER_MINOR:=$(shell pkg-config bullet --modversion | cut -f2 -d.)
export BULLET_GE_2_83=$(shell [ $(BULLET_VER_MAJOR) -gt 2 -o \( $(BULLET_VER_MAJOR) -eq 2 -a $(BULLET_VER_MINOR) -ge 83 \) ] && echo true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand exactly but if we do not have bullet it outputs too many 1: [: -gt: unexpected operator

HOGE=$(shell echo "ng")

all:
        echo "ok"
        echo $(HOGE)
        echo $(HOGE)
        echo $(HOGE)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -31,6 +31,8 @@

(comp:compile-file-if-src-newer "irtgeo.l" user::*objdir*)
(comp:compile-file-if-src-newer "pqp.l" user::*objdir*)
(if (string= (unix:getenv "BULLET_GE_2_83") "true")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think compile eusbullet.l for all cases is ok. just to

void BulletcalcCollisionDistance() {
#if HAVE_BULLET
#else
    fpritnf(stderr, "jskeus is compile without bullet, so you can not use function %s, Please install bullet > 2.83\n", __PRETTY_FUNCTION__); or something
#endif
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2a89385.

Now, compile eusbullet.l and BulletCollision.cpp even if bullet is not installed, and check bullet installed as follows:

#if HAVE_BULLET
#define CALL_WITH_BULLET_CHECK(X) X
#else
#define CALL_WITH_BULLET_CHECK(X) fprintf(stderr, "jskeus is compiled without bullet, so you can not use function %s, Please install bullet >= 2.83\n", __PRETTY_FUNCTION__); return -1;
#endif

Not smart point is that I should comment out some parts with macro's if to avoid compile error of undefined function:

#if HAVE_BULLET
double _posA[3], _quatA[4], _posB[3], _quatB[4];
double _dist[1], _dir[3], _pA[3], _pB[3];
eusinteger_t ret;
for (int i = 0; i < 3; i++ ) {_posA[i] = posA[i]; _posB[i] = posB[i]; }
for (int i = 0; i < 4; i++ ) {_quatA[i] = quatA[i]; _quatB[i] = quatB[i]; }
_dist[0] = dist[0];
for (int i = 0; i < 3; i++ ) {_dir[i] = dir[i]; _pA[i] = pA[i]; _pB[i] = pB[i];}
ret = calcCollisionDistance(modelAddrA, modelAddrB,
_posA, _quatA, _posB, _quatB,
_dist, _dir, _pA, _pB);
dist[0] = _dist[0];
for (int i = 0; i < 3; i++ ) {dir[i] = _dir[i]; pA[i] = _pA[i]; pB[i] = _pB[i];}
#endif

@mmurooka
Copy link
Member Author

Move to #555. Please review when you have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants