roslibjs tutorials not working

asked 2017-01-02 09:37:11 -0500

Swoncen gravatar image

Hello,

I have installed ROS indigo at work and kinetic at home and with both installations the tutorials dont work properly. Here is how I start it:

1.) roscore

2.) roslaunch rosbridge_server rosbridge_websocket.launch

3.) rosrun actionlib_tutorials fibonacci_server

4.) Browser: localhost:9090

The output I get is: Can "Upgrade" only to "WebSocket".

Is there any working tutorial on how to use this framework? The tutorial seems incomplete to me: "You can open up the file directly in the browser without running a web server" - no information given which URL one has to type, so I typed localhost:9090, then tried with /fibonacci_server then other paths, with no success. It is a pain to have such a powerful tool with the tutorials not working.

Please give me a hint, this will be very appreciated. Thanks in advance!

edit retag flag offensive close merge delete

Comments

1

"open up the file directly in the browser" means (in Firefox fi): File -> Open File ..., browse to the .html file and click 'open'. There is no URL involved (well, file:// is technically a URI, but ..). Can you try to see whether that works?

gvdhoorn gravatar image gvdhoorn  ( 2017-01-02 10:13:59 -0500 )edit
1

rosbridge_server does not provide a web server to serve the HTML files. @gvdhoorn has given the correct syntax. The requirement is the browser must be running on the same machine as where the file exists. On your ROS machine, you can drag the HTML file onto your browser.

suforeman gravatar image suforeman  ( 2017-01-02 15:03:55 -0500 )edit

Thank you for your clarification, I haven't thought about this. Unfortunately I am running it on a headless raspberry pi with Ubuntu Server. To my understanding, it should work, if I install apache on it and run the html remotely within the network. I'm going to try that out now.

Swoncen gravatar image Swoncen  ( 2017-01-02 16:24:43 -0500 )edit

Ok, I can open the files now, after I copied the files to /var/www/html/ and also copied the whole roslibjs folder to it. Connecting to ip/roslibjs/examples/fibonacci.html returns: "Error in the backend! Connection closed." And connecting to ip/fibonacci.html returns: Connecting to rosbridge...

Swoncen gravatar image Swoncen  ( 2017-01-02 16:40:07 -0500 )edit

If you add a web server, you have a lot of flexibility. I did something similar (using lighttpd). The only issue I ran into was needing to set the "ws:" URL to use the IP address of the RPi.

You can see my example here: https://gitlab.com/bradanlane/touchco...

suforeman gravatar image suforeman  ( 2017-01-02 18:32:47 -0500 )edit

Strange thing happened: I did the same thing at my work PC: copy roslibjs folder to /var/www/html and called the file via apache and it works without a problem here. It's on localhost but it should be the same, when accessing it from another PC in the network. Thanks for helping!

Swoncen gravatar image Swoncen  ( 2017-01-03 05:43:47 -0500 )edit

It looks like you've mostly answered your own question. You may want to post your solution as an answer ("ROS Answers" supports contributors answering their own questions. You can give credit to those who helped.)

suforeman gravatar image suforeman  ( 2017-01-03 07:12:30 -0500 )edit