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

Does rosbridge_suite support sensor_msgs/Imu ?

asked 2020-04-17 19:16:40 -0500

dawonn_haval gravatar image

updated 2020-04-18 03:44:42 -0500

gvdhoorn gravatar image

I'm trying to publish a sensor_msgs/Imu message via rosbridge_suite, but it seems that it gets hung up on the orientation_covariance field, which is of type double[9].

Here's the json that I've sent:

{
  "op": "publish",
  "topic": "/imu_raw",
  "msg": {
    "header": {
      "stamp": {
        "sec": 1587154682,
        "nanosec": 508394240
      },
      "frame_id": "imu"
    },
    "orientation": {
      "x": 0.000125964405015111,
      "y": 0.000125781516544521,
      "z": 0.707106590270996,
      "w": 0.707106947898865
    },
    "orientation_covariance": [0, 0, 0, 0, 0, 0, 0, 0, 0],
    "angular_velocity": {
      "x": 1.54979915123477e-7,
      "y": -6.26098639600059e-8,
      "z": 7.72354888378679e-11
    },
    "angular_velocity_covariance": [0, 0, 0, 0, 0, 0, 0, 0, 0],
    "linear_acceleration": {
      "x": -0.00349057815037668,
      "y": -0.00000256077805715904,
      "z": -9.80999851226807
    },
    "linear_acceleration_covariance": [0, 0, 0, 0, 0, 0, 0, 0, 0]
  }
}

I put in a debug statement here:

print("1>>> %s %s %s %s %s | %s %s " %
   (json.dumps(msg[field_name]), field_rostype, roottype, field_inst, field_stack, type(msg[field_name]), type(field_inst)))

Here's the relevant output:

1>>> [0, 0, 0, 0, 0, 0, 0, 0, 0] double[9] sensor_msgs/Imu [ 0.  0.  0.  0.  0.  0.  0.  0.  0.] ['orientation_covariance'] | <class 'list'> <class 'numpy.ndarray'>

The sensor_msgs/Imu orientation_covariance field is of type numpy.ndarray, which _to_inst doesn't handle, so it gets passed to _to_object_inst which only handles 'dict' types, and this exception gets thrown.

So I think formatted the json poorly or the rosbridge_suite doesn't support fixed-length arrays? Maybe something else? Guidance would be really appreciated. :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-04-17 21:51:57 -0500

dawonn_haval gravatar image

Added another condition to _to_inst():

# Check if this is a numpy array
if type(inst) is ndarray:
    return inst

It functions, but I don't know that it's the 'right' solution...

edit flag offensive delete link more

Comments

FYI: I have had to add a bunch of modifications to the _to_inst() functions to support ROS2 well. It seems that the ROS and ROS2 branches have diverged and the ROS2 branch is rather stale?

dawonn_haval gravatar image dawonn_haval  ( 2020-05-08 22:05:47 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-04-17 19:16:40 -0500

Seen: 131 times

Last updated: Apr 18 '20