Search code examples
pythonintros

How to change Int64 to something usefull, ROS node


I have this problem that I subscribe to ros node and i get Int64. Then I'm trying to substract it from other int but i get this error:

TypeError: unsupported operand type(s) for -: 'int' and 'Int64'

what I'm trying to do is

diff = old_tick - tick

which is basically int = int - Int64. Previously I did

old_tick = 0

How can I change this Int64 to something that will work.


Solution

  • I think that there is confusion the fact that std_msgs/Int16 is not a simple int type but a Python class.

    It contains a single field data that contains the actual int.

    So if the tick is Int64 to gain access in the value, you need to use tick.data (std_msgs/Int64 Message)