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

Revision history [back]

click to hide/show revision 1
initial version

It looks like your issue is likely how you're passing the topic argument. ros.js can take proper JSON strings or (in newer versions) pure Javascript objects which it will convert for you. Unfortunately, your current syntax is somewhat in-between. Either:

 '["/mav2/fcu/mag"]'

or the simpler and much preferable:

  ["/mav2/fcu/mag"]

should work.

Notice how answer.ros.org's highlighting turns the first example fully green because it's a string. The second example is preferred because its harder to mess up. It's just an array containing a single string. Also remember that Javascript has two types of quotes. So:

  "['/mav2/fcu/mag']"

and:

  ['/mav2/fcu/mag']

are also fine.

This example shows reading in all of the currently published topics and displaying their types.

It looks like your issue is likely how you're passing the topic argument. ros.js can take proper JSON strings or (in newer versions) pure Javascript objects objects, which it will convert for you. Unfortunately, your current syntax is somewhat in-between. Either:

 '["/mav2/fcu/mag"]'

or the simpler and much preferable:

  ["/mav2/fcu/mag"]

should work.

Notice how answer.ros.org's highlighting turns the first example fully green because it's a string. The second example is preferred because its harder to mess up. It's just an array containing a single string. Also remember that Javascript has two types of quotes. So:

  "['/mav2/fcu/mag']"

and:

  ['/mav2/fcu/mag']

are also fine.

This example shows reading in all of the currently published topics and displaying their types.