Skip to content
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

Incorrect results given by bt-collision-distance when small object cases #616

Open
HiroIshida opened this issue Jun 17, 2019 · 1 comment

Comments

@HiroIshida
Copy link
Contributor

I am using bt-collision-distance introduced here. When object size is small, it does not seem to work correctly. For instance, the test code below compares the result of pqp and bt ones, and the results suggest that as size get smaller, the resulting error increases.

(defun test (size)
  (setq *c1* (make-cube size size size))
  (setq *c2* (make-cube size size size))
  (send *c2* :translate #f(100000 0 0))
  (setq err (- (car (pqp-collision-distance *c1* *c2*))
               (car (bt-collision-distance *c1* *c2*))))
  (print err))

test(1000) returns 0.007629
test(100) returns 0.006104
test(50) returns 29.9866
test(10) returns 69.9789

@mmurooka
Copy link
Member

BULLET uses 0.04m margin to make the computation fast.
So, the collision distance of the objects smaller than 0.04m cannot be calculated correctly.
https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=11920#p40155

以下のようにするとだいぶ良くなりました.
(この対処法がBULLET的に正しいか確認してみます.)

(defun test (size)
  (setq *c1* (make-cube size size size))
  (setq *c2* (make-cube size size size))
  (send *c2* :translate #f(100000 0 0))

  ;;;;;;;;;;;;;;;;;;;;;;;;
  ;; 1. Make bullet model beforehand for overwrite margin.
  ;; (Ordinally, this is called in bt-collision-distance automatically.)
  (send *c1* :make-btmodel)
  (send *c2* :make-btmodel)
  ;; 2. Overwrite margin. (Consider the default margin, 0.04 [m])
  ;; ref. https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=11920#p40155
  (geo::_bt-set-margin (send *c1* :get :btmodel) -0.04)
  (geo::_bt-set-margin (send *c2* :get :btmodel) -0.04)
  ;;;;;;;;;;;;;;;;;;;;;;;;

  (setq err (- (car (pqp-collision-distance *c1* *c2*))
               (car (bt-collision-distance *c1* *c2*))))
  (print err))
13.irteusgl$ (test 1000)
0.0 ;; [mm]
14.irteusgl$ (test 100)
0.006104 ;; [mm]
15.irteusgl$ (test 50)
-0.012207 ;; [mm]
16.irteusgl$ (test 10)
-0.013123 ;; [mm]

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

No branches or pull requests

2 participants