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

rosbridge /rosjs/typeStringFromTopic does not work

asked 2012-04-19 02:16:55 -0600

BeuBeu gravatar image

I call this service (/rosjs/typeStringFromTopic) with the following code:

var types=[];
con.callService('/rosjs/typeStringFromTopic', '[/mav2/fcu/mag]', function(rsp) {
alert("here");
alert(rsp);
types.push(rsp); });

My topic is not empty but I "here" is never alerted. There is the following error in my rosbridge terminal

Problem Problem Problem Problem Problem Problem Problem Problem Problem Problem
Traceback (most recent call last):
File "/data/my_ros/rosbridge/bin/rosbridge.py", line 39, in handleFrameHelper call = json.loads(frame)
File "/usr/lib/python2.7/json/__init__.py", line 326, in loads return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Problem Problem Problem Problem Problem Problem Problem Problem Problem Problem

Thank you for your help :)

Benoît

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2012-04-19 06:16:42 -0600

tjay gravatar image

updated 2012-04-19 06:17:22 -0600

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.

edit flag offensive delete link more
0

answered 2012-04-19 22:16:07 -0600

BeuBeu gravatar image

Thank you a lot

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-04-19 02:16:55 -0600

Seen: 366 times

Last updated: Apr 19 '12