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

ROSSerializationException: field data exceeds specified width [int32]

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

Alessandro Melino gravatar image

Hello.

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/topics.py", line 750, in _invoke_callback
    cb(msg)
  File "/home/sara/catkin_ws/src/canusb/script/lectura.py", line 285, in callback
    self.enc_pub.publish(var_enc)
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", 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:

var_enc.data = 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
0

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

Question Tools

2 followers

Stats

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

Seen: 1,197 times

Last updated: Oct 23 '20