0
$\begingroup$

Rosanswers logo

hello guys, i'm new at ros. i want to subscribe a topic to a webpage. i tried to do the following tutorial but subscribe part doesnt work. Should i add a label or something to view the subscription to the html file? here is the tutorial: http://wiki.ros.org/roslibjs/Tutorials/BasicRosFunctionality


Originally posted by minerva on ROS Answers with karma: 18 on 2015-05-03

Post score: 0


Original comments

Comment by corb on 2015-05-03:
what do you see in the browser console?

Comment by minerva on 2015-05-04:
what do you mean by browser console? i just open html file.

Comment by corb on 2015-05-04:
You need to save the html code to a file, like "ros_test.html". Then open that file in your browser. You should see "Simple roslib Example. Check your Web Console for output". To see the console (in the Chrome browser): menu/more tools/javascript console. Other browsers will be similar.

Comment by minerva on 2015-05-05:
oh "Received message on /listener: Hello wold" is written there thank you :) so the code is ok but how can i write it to a label?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You need to save the html code to a file, like ros_test.html. Then open that file in your browser. You should see Simple roslib Example. Check your Web Console for output. To see the console (in the Chrome browser): menu, more tools, javascript console. Other browsers will have something similar.

To have the HTML update: In the body section, add something with an Id:

  <body>
  <h1>Simple roslib Example</h1>
  <p id="abc">Test</p>
</body>

In listener.subscribe(function(message), add

document.getElementById("abc").innerHTML = message.data; 

Originally posted by corb with karma: 339 on 2015-05-05

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by minerva on 2015-05-05:
it helped thank you! :)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.