jsk-ros-pkg / jsk_model_tools

JSK model utilities
https://github.com/jsk-ros-pkg/jsk_model_tools
BSD 3-Clause "New" or "Revised" License
5 stars 27 forks source link

[eus_assimp] need to set faces before calling gl::make-glvertices-fro… #208

Closed eisoku9618 closed 6 years ago

eisoku9618 commented 6 years ago

…m-faces

dump-to-meshfile did not work because faces in (funcall #'gl::make-glvertices-from-faces faces :material mat) was not set and it was nil.

(progn                                                                          
  (load "package://pr2eus/pr2.l")                                               
  (load "package://eus_assimp/euslisp/eus-assimp.l")                            
  (setq *robot* (pr2))                                                          
  (objects (list *robot*))                                                      
  (dump-to-meshfile "/tmp/robot.stl" *robot*)                                   
  (unix::system "meshlab /tmp/robot.stl"))

image


By the way,,, Could you suggest some ideas about how to get a fine/detailed single whole-body STL file (pr2_whole_body.stl) from a URDF robot model having multiple links (pr2.urdf). For example, if we want to create a PR2 key holder by 3D printer, we need to generate one fine/detailed STL file.

After JSK conventional urdf -> collada -> euslisp conversion, I tried to convert the euslisp model to a STL file with this PR, but the output STL files looks like convex hull and it is not a fine/detailed STL file. Also, I tried to convert collada -> STL with meshlab, but meshlab does not understand translation information and all the links are located at world origin as follows.

image

k-okada commented 6 years ago

@eisoku9618 how about

(load "irteus/demo/sample-robot-model.l")
(setq *r* (instance sample-robot :init))
(eus2stl "robot.stl" (instance bodyset :init (make-cascoords) :bodies (mapcar #'(lambda (b) (body-to-faces b)) (send *r* :bodies))))

using https://github.com/euslisp/jskeus/pull/248

YoheiKakiuchi commented 6 years ago

(send-all (send *robot* :bodies) :faces) returns convex-hull. It's defined at euscollada. You can use glvertices(mesh description for drawing) directly, like this.

(let (glv-lst)
  (dolist (bd (send *pr2* :bodies))
    (let (glv)
      (cond
       ((and (boundp 'gl::glbody) (classp gl::glbody) (derivedp bd gl::glbody))
        (setq glv (send bd :glvertices))
        )
       (t
        (setq glv (cdr (assoc 'glvertices (send bd :slots)))))
       )
      (when glv
        (push glv glv-lst))
      ))
  (apply #'save-mesh-file "/tmp/pr2.stl" (append-glvertices glv-lst :use-coordinate t) nil)
  )
eisoku9618 commented 6 years ago

@k-okada sensei, @YoheiKakiuchi san, Thank you very much. Now I can get a detailed whole-body STL file !

With okada-sensei way, I could not get a detailed STL file as kakiuchi-san comment

(send-all (send *robot* :bodies) :faces) returns convex-hull

In kakiuchi-san way, :use-coordinate option is used, but append-glvertices does not have this option, so I added it at https://github.com/jsk-ros-pkg/jsk_model_tools/pull/210