ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

error when loading a mesh with ros3djs

asked 2019-09-24 05:52:42 -0600

WhatWhat gravatar image

updated 2019-09-27 08:34:52 -0600

I am trying to load a .stl 3d model of a drone in a html page using Javascript and ros3djs as follow :

 const mesh = new ROS3D.MeshResource({
      resource: 'models/3d-model-drone/octo-asm.stl',
      path: 'ws://localhost:9090/',
      warnings: true
  });

but I keep getting this object as error:

error
​bubbles: false
​cancelBubble: false
​cancelable: false
​composed: false
​currentTarget: null
​defaultPrevented: false
​eventPhase: 0
​explicitOriginalTarget: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
​isTrusted: true
​lengthComputable: false
​loaded: 0
​originalTarget: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
​returnValue: true
​srcElement: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
​target: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
​timeStamp: 601
​total: 0
​type: "error"
​<get isTrusted()>: function isTrusted()
​<prototype>: ProgressEventPrototype { lengthComputable: Getter, loaded: Getter, total: Getter, … }
ros3d.min.js:1:579846
    onError file:///home/.../script/lib/ros3djs/build/ros3d.min.js:1
    load file:///home/.../script/lib/ros3djs/build/ros3d.min.js:1

what does this mean? is my path false ? I tried different paths but I couldn't get it to work.

EDIT: I am using this modified ros3djs library (link to my merge request request) but I have tried using with the normal one and the same error pops up.

And one of the model that I m using is in this link all models that I try loading give the same error.

EDIT2/Problem2: as @Solrac3589 recommended installing Apache2 to use as a server. I used for testing the example @Solrac3589 created. After putting the code in /var/www/htmland opening the index.html by typing localhost in my browser (I couldn't open the the html files directly from the file manager) the CORS warning message does not pop up any more but I get the following new object error from ros3djs :

load
bubbles: false
cancelBubble: false
cancelable: false
composed: false
currentTarget: null
defaultPrevented: false
eventPhase: 0
explicitOriginalTarget: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
isTrusted: true
lengthComputable: true
loaded: 271
originalTarget: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
returnValue: true
srcElement: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
target: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
timeStamp: 92
total: 271
type: "load"
<get isTrusted()>: function isTrusted()
<prototype>: ProgressEventPrototype { lengthComputable: Getter, loaded: Getter, total: Getter, … }
ros3d.min.js:1:579846
    onError http://localhost/js/ros3d.min.js:1
    load http://localhost/js/ros3d.min.js:1
edit retag flag offensive close merge delete

Comments

Can you attach your mesh and a link to the library you are using so others can try and replicate your results?

kscottz gravatar image kscottz  ( 2019-09-24 14:20:45 -0600 )edit

It seems to me like there is an error in your ros3djs file. Anyway, if you do what @kscottz says, would be helptful

Solrac3589 gravatar image Solrac3589  ( 2019-09-25 08:14:02 -0600 )edit

thank you for your reply. I added a links above.

WhatWhat gravatar image WhatWhat  ( 2019-09-25 10:38:46 -0600 )edit
1

Hello, sorry for the late response. I saw your comment yesterday but i had a few issues managing the system work.

i just create an example for you working (at least for me) Anything more here I am!

Hope it helps! :)

Solrac3589 gravatar image Solrac3589  ( 2019-09-27 02:02:16 -0600 )edit

Hi thank you for your response but I still get the error even in your example. I noticed that there is always this warning before the error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost/testg/meshes/3dmodel.stl. (Reason: CORS request did not succeed).

after some reading on the issue I understood that browsers do not allow automatic reading of local files on a machine. What should I do to get around this warning, which is causing the error (I think)?

WhatWhat gravatar image WhatWhat  ( 2019-09-27 04:01:55 -0600 )edit

I just noticed that you mentioned in your README.md something about setting up an apache2 server. After some research that might be the solution to my problem. I will try following tutorials on how to set it up and making it work. I will keep you updated !

WhatWhat gravatar image WhatWhat  ( 2019-09-27 04:47:28 -0600 )edit
1

Yes exactly. What it is used to do to open something in the same computer is to do a local server . If you configure apache2 server in ubuntu, it is just as easy as leave all the code in the folder /var/www/html.

Any doubt just ask!

Solrac3589 gravatar image Solrac3589  ( 2019-09-27 04:54:23 -0600 )edit

please check EDIT2 above.

WhatWhat gravatar image WhatWhat  ( 2019-09-27 07:52:55 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-09-27 08:53:52 -0600

WhatWhat gravatar image

Credits to Solrac3589

The first error was caused by the browser blocking access to local files. Browsers do not allow client local file loading for security purposes. A possible solution, to get ride of the Cross-Origin Resource Sharing or CORS blocked warning and the error, is to install Apache HTTP Server and copy all the code and files under /var/www/html.

The cause of the second error was because I loaded my file from a wrong path. So fixing the path in the code fixes the problem

edit flag offensive delete link more

Comments

1

Great to see you managed :) Sorry for responding late!

Good luck in your project!

Solrac3589 gravatar image Solrac3589  ( 2019-09-30 01:15:47 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2019-09-24 05:52:42 -0600

Seen: 546 times

Last updated: Sep 27 '19