Ask Your Question
0

how to subscribe with rosbridge

asked 2015-05-03 22:28:54 -0600

minerva gravatar image

updated 2015-05-03 22:29:26 -0600

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/Tutorial...

edit retag flag offensive close merge delete

Comments

what do you see in the browser console?

corb gravatar imagecorb ( 2015-05-03 22:40:27 -0600 )edit

what do you mean by browser console? i just open html file.

minerva gravatar imageminerva ( 2015-05-04 16:15:10 -0600 )edit

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.

corb gravatar imagecorb ( 2015-05-04 16:42:52 -0600 )edit

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?

minerva gravatar imageminerva ( 2015-05-05 05:27:43 -0600 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2015-05-05 06:44:25 -0600

corb gravatar image

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;
edit flag offensive delete link more

Comments

it helped thank you! :)

minerva gravatar imageminerva ( 2015-05-05 07:13:47 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-05-03 22:28:54 -0600

Seen: 226 times

Last updated: May 05 '15