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

Revision history [back]

click to hide/show revision 1
initial version

The problem is 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 for your code to work you should write:

rospy.loginfo(x.data + 2)

The problem is that std_msgs/Int16 is not a simple int type but a Python class.class. See std_msgs/Int16 for the documentation of the message type, and see wiki/msg - Message Description Specification - Field Types for how those fields map to Python types.

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

So for your code to work you should write:

rospy.loginfo(x.data + 2)

The problem is that std_msgs/Int16 is not a simple int type but a Python class. See std_msgs/Int16 for the documentation of the message type, and see wiki/msg - Message Description Specification - Field Types for how those fields map to Python types.class.

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

So for your code to work you should write:

rospy.loginfo(x.data + 2)

See std_msgs/Int16 for the documentation of the message type, and see wiki/msg - Message Description Specification - Field Types for how those fields map to Python types.