ROSSerializationException: field data exceeds specified width [int32]
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