sensor_msgs/Imu Support

26 views
Skip to first unread message

Dereck Wonnacott

unread,
Apr 17, 2020, 7:40:14 PM4/17/20
to Robot Web Tools
I'm trying to publish a sensor_msgs/Imu message, but it seems that the rosbridge gets hung up on the orientation_covariance field, which is of type double[9].

[ERROR] [rosbridge_websocket]: [Client 0] publish: sensor_msgs/Imu message requires a double[9] for field orientation_covariance, but got a <class 'list'> @ _to_object_inst

Here's the json that I've sent, is there something wrong?:
{"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-07,"y":-6.26098639600059E-08,"z":7.72354888378679E-11},"angular_velocity_covariance":[0,0,0,0,0,0,0,0,0],"linear_acceleration":{"x":-0.00349057815037668,"y":-2.56077805715904E-06,"z":-9.80999851226807},"linear_acceleration_covariance":[0,0,0,0,0,0,0,0,0]}}


Thanks for the help!

Dereck Wonnacott

unread,
Apr 17, 2020, 8:04:45 PM4/17/20
to Robot Web Tools
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 either I think i formatted the json poorly, or the rosbridge_suite doesn't support fixed-length arrays perhaps? Maybe something else? guidance would be really appreciated. :) 

Dereck Wonnacott

unread,
Apr 17, 2020, 10:52:24 PM4/17/20
to Robot Web Tools

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

David Lu!!

unread,
Apr 22, 2020, 2:59:32 PM4/22/20
to Robot Web Tools
This is probably better suited for answers.ros.org. It seems to me like your root program is how you're publishing the Imu message out of rospy, and not how it is being consumed by rosbridge.
Reply all
Reply to author
Forward
0 new messages