how to import mesh (one with obj, mtl and png files) using lua API

Typically: "How do I... ", "How can I... " questions
st2yang
Posts: 7
Joined: 23 Mar 2019, 21:04

how to import mesh (one with obj, mtl and png files) using lua API

Post by st2yang » 25 Mar 2019, 16:16

Hi all,

I am new to vrep and I found it's a great tool. I am using it to import models from YCB dataset (a object and model set). It's providing mtl and texture_map png for every obj mesh file. But I have some problem with importing.

I can import the model (with texture) successfully with the GUI mode, I mean just clicking file-import-mesh using the software.

But I really couldn't find a way to do this with lua API. I can import only the obj file easily by

Code: Select all

sim.importShape(0, string_of_the_path_to_obj_file, 0, 0, 1)
. On manual page, it says I can turn on the bit4 of the options parameter (3-rd parameter) to preserve textures. I tried

Code: Select all

sim.importShape(0, string_of_the_path_to_obj_file, 16, 0, 1)
. But it fails and get the following error.
Lua runtime error: [string "CHILD SCRIPT remoteApiCommandServer"]:9: Not enough shapes specified. (sim.importShape)
stack traceback:
[C]: in function 'importShape'
[string "CHILD SCRIPT remoteApiCommandServer"]:9: in function <[string "CHILD SCRIPT remoteApiCommandServer"]:2>
Error: [string -unknown location]:?: Call failed. (simCallScriptFunctionEx on importShape@remoteApiCommandServer)
Could anyone points out the function I should look at? I hope I can get some help from you and the forum. I would really appreciate any suggestion.

Thanks,
st2yang

coppelia
Site Admin
Posts: 7150
Joined: 14 Dec 2012, 00:25

Re: how to import mesh (one with obj, mtl and png files) using lua API

Post by coppelia » 27 Mar 2019, 14:08

Did you try with simAssimp.importShapes? This is available since V-REP V3.6.1

Cheers

st2yang
Posts: 7
Joined: 23 Mar 2019, 21:04

Re: how to import mesh (one with obj, mtl and png files) using lua API

Post by st2yang » 28 Mar 2019, 16:17

Hi coppelia,

Thanks for your reply.

I updated vrep to v3.6.1 and tried to use simAssimp.importShapes. This is how I use it

Code: Select all

shapeHandle = simAssimp.importShapes(string_of_the_path_to_obj_file)
I assume this should be fine. But vrep would crash automatically if I try to run the program. And I got the following error message from the linux terminal. Do you have an idea where I made the mistake? Thank you in advance!
Assimp: importing '/home/marsyang/Documents/banana/011_banana.obj'


Error: signal 11:

libv_rep.so(_Z11_segHandleri+0x28)[0x7f42b1929ff8]
/lib/x86_64-linux-gnu/libc.so.6(+0x354b0)[0x7f42b576b4b0]
/home/marsyang/Documents/workspace/V-REP_PRO_EDU_V3_6_1_Ubuntu16_04/libv_repExtAssimp.so(_Z18assimpImportShapesPKcifiiRSt6vectorIiSaIiEE+0xdc9)[0x7f42806cef92]
/home/marsyang/Documents/workspace/V-REP_PRO_EDU_V3_6_1_Ubuntu16_04/libv_repExtAssimp.so(_Z12importShapesP15SScriptCallBackPKcP15importShapes_inP16importShapes_out+0x1eb)[0x7f42806cfdcc]
/home/marsyang/Documents/workspace/V-REP_PRO_EDU_V3_6_1_Ubuntu16_04/libv_repExtAssimp.so(_Z21importShapes_callbackP15SScriptCallBack+0x2f9)[0x7f4280702fdd]
libv_rep.so(_Z27_genericFunctionHandler_newPvP18CLuaCustomFunctionRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1b0)[0x7f42b1983260]
libv_rep.so(_Z26_simGenericFunctionHandlerPv+0x271)[0x7f42b19843a1]
liblua5.1.so(+0xc1d4)[0x7f42b69311d4]
liblua5.1.so(+0x1590f)[0x7f42b693a90f]
liblua5.1.so(+0xc61e)[0x7f42b693161e]


Error: signal 11:

libv_rep.so(_Z11_segHandleri+0x28)[0x7f42b1929ff8]
/lib/x86_64-linux-gnu/libc.so.6(+0x354b0)[0x7f42b576b4b0]
libQt5Core.so.5(_ZN6QMutex4lockEv+0x15)[0x7f42b613e0b5]
libQt5Gui.so.5(+0x379f7e)[0x7f42b057ff7e]
libQt5Gui.so.5(+0x37183f)[0x7f42b057783f]
libQt5Gui.so.5(_ZN18QRasterPaintEngine11updateBrushERK6QBrush+0x87)[0x7f42b057acd7]
libQt5Gui.so.5(_ZN18QRasterPaintEngine8fillRectERK6QRectFRK6QBrush+0x2a)[0x7f42b057b7aa]
libQt5Gui.so.5(_ZN8QPainter8fillRectERK5QRectRK6QBrush+0xc5)[0x7f42b058e5d5]
libQt5Widgets.so.5(_ZNK12QFusionStyle18drawComplexControlEN6QStyle14ComplexControlEPK19QStyleOptionComplexP8QPainterPK7QWidget+0x31a7)[0x7f42b0c67ea7]
libQt5Widgets.so.5(+0x202bdb)[0x7f42b0c2ebdb]
QMutex: destroying locked mutex
Last edited by st2yang on 11 Apr 2019, 19:20, edited 1 time in total.

coppelia
Site Admin
Posts: 7150
Joined: 14 Dec 2012, 00:25

Re: how to import mesh (one with obj, mtl and png files) using lua API

Post by coppelia » 29 Mar 2019, 14:46

Hmmm, can you send us the incriminating files so that we can try this here?
Please send to this email.

Cheers

st2yang
Posts: 7
Joined: 23 Mar 2019, 21:04

Re: how to import mesh (one with obj, mtl and png files) using lua API

Post by st2yang » 29 Mar 2019, 18:46

Hi,

I just sent you an email titled "mesh files causing crep crash" with the mesh file attached.

I just found that, vrep v3.6.1 would also crash if I try to import it with software GUI. But v3.5.0 would just work nicely. So I guess this could be a bug with the new version?

st2yang
Posts: 7
Joined: 23 Mar 2019, 21:04

Re: how to import mesh (one with obj, mtl and png files) using lua API

Post by st2yang » 08 Apr 2019, 20:28

Hi,

I'm wondering if the functionality (of importing textured mesh using api) will be achieved in a quick updated version? I really would like to have this functionality, but the current version seems to have a bug with this.

Anyone who has some ideas about this problem? Thank you in advance.

Best,
st2yang

coppelia
Site Admin
Posts: 7150
Joined: 14 Dec 2012, 00:25

Re: how to import mesh (one with obj, mtl and png files) using lua API

Post by coppelia » 09 Apr 2019, 06:57

Did you try to download V-REP V3.6.1 rev2? It is working here...

Cheers

st2yang
Posts: 7
Joined: 23 Mar 2019, 21:04

Re: how to import mesh (one with obj, mtl and png files) using lua API

Post by st2yang » 11 Apr 2019, 19:29

Hi coppelia,

Thanks for your reply.

Are you trying to import mesh using software GUI or API?

I just tried the newest release V3.6.1 rev3, and I think it's still not working. When I use GUI to import mesh, it would crash with the following error in the terminal if I keep default default options. If I choose to drop texture in options, it can import. It would also crash if I can API.

FYI, I tried on both Mac and Ubuntu (16.04) platforms.

So I might think there are still some problems. Could you please let me know how can I solve it? Thank you in advance!

Best
Checking for an updated V-REP version...
This V-REP version is up-to-date.
Assimp: importing '/home/marsyang/Documents/banana/011_banana.obj'


Error: signal 11:

libv_rep.so(_Z11_segHandleri+0x28)[0x7fe6f0629f68]
/lib/x86_64-linux-gnu/libc.so.6(+0x354b0)[0x7fe6f446c4b0]
/home/marsyang/Documents/workspace/V-REP_PRO_EDU_V3_6_1_Ubuntu16_04/libv_repExtAssimp.so(_Z18assimpImportShapesPKcifiiRSt6vectorIiSaIiEE+0xdc9)[0x7fe6c0312f92]
/home/marsyang/Documents/workspace/V-REP_PRO_EDU_V3_6_1_Ubuntu16_04/libv_repExtAssimp.so(_Z12importShapesP15SScriptCallBackPKcP15importShapes_inP16importShapes_out+0x1eb)[0x7fe6c0313dcc]
/home/marsyang/Documents/workspace/V-REP_PRO_EDU_V3_6_1_Ubuntu16_04/libv_repExtAssimp.so(_Z21importShapes_callbackP15SScriptCallBack+0x2f9)[0x7fe6c0346fdd]
libv_rep.so(_Z27_genericFunctionHandler_newPvP18CLuaCustomFunctionRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1b0)[0x7fe6f06834b0]
libv_rep.so(_Z26_simGenericFunctionHandlerPv+0x271)[0x7fe6f06845f1]
liblua5.1.so(+0xc1d4)[0x7fe6f56321d4]
liblua5.1.so(+0x1590f)[0x7fe6f563b90f]
liblua5.1.so(+0xc61e)[0x7fe6f563261e]
QObject::~QObject: Timers cannot be stopped from another thread

coppelia
Site Admin
Posts: 7150
Joined: 14 Dec 2012, 00:25

Re: how to import mesh (one with obj, mtl and png files) using lua API

Post by coppelia » 15 Apr 2019, 14:55

hum... then there must be a bug somewhere...
In the mean time you can simply convert your file into a different format. The other format will hopefully not cause problems.

Cheers

st2yang
Posts: 7
Joined: 23 Mar 2019, 21:04

Re: how to import mesh (one with obj, mtl and png files) using lua API

Post by st2yang » 15 Apr 2019, 22:06

Hi coppelia,

Thanks for your reply and suggestion. I'll try that.

Can I ask for one more clarification? You mention "it's working here", Are you trying to import mesh using software GUI or API? If API, are you using simAssimp.importShapes ?

Thanks,
st2yang

Post Reply