ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

ROSSerializationException: field data exceeds specified width [int32]

asked 2020-09-30 05:00:20 -0500

Alessandro Melino gravatar image


The following error is appearing in my terminal:

[ERROR] [1601452123.044766]: bad callback: <bound method LECTURA_CLASS.callback of <__main__.LECTURA_CLASS instance at 0x7f55f2b772d8>>
Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/", line 750, in _invoke_callback
  File "/home/sara/catkin_ws/src/canusb/script/", line 285, in callback
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/", line 886, in publish
    raise ROSSerializationException(str(e))
ROSSerializationException: field data exceeds specified width [int32]

I print the data value and it is 4294967234, but his type is int32 so the real meaning is -62.

var_enc is an structure like this:

int8 encID
int32 time
int32 data

So the data field is wanted to be int32, but I write it on this line: = int(encB)

So, what type of cast must I do to avoid this error?

If you require another extra information please ask me.

I am working on Ubuntu 16.04, with ROS Kinetic, so the version of python is 2.7.

Best regards. Alessandro

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-10-23 06:06:23 -0500

Alessandro Melino gravatar image

Solved substracting 2^32 to the data, so is now an integer of 32 bits.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools



Asked: 2020-09-30 05:00:20 -0500

Seen: 1,040 times

Last updated: Oct 23 '20