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

Is it possible to convert std_msgs/Int8 to a binary number?

asked 2016-10-31 12:49:43 -0500

215 gravatar image

I am currently trying to convert a std_msgs/Int8 messsage that I receive from a topic to a binary number in python.

The way I am currently doing it is by doing this dirty hack.


but isn't there any nice way to do this? I mean this is python so something clever should be there...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-10-31 12:56:36 -0500

ahendrix gravatar image

I'm not sure why you're converting to a string and then back to an int.

If you have an Int8, you should be able to call bin() on the data member directly:

# Import the Int8 message definition
from std_msgs.msg import Int8

# create an Int8 message and assign 32 to it
num = Int8() = 32

# call bin() on our Int8 data and print the result
print bin(
edit flag offensive delete link more

Question Tools



Asked: 2016-10-31 12:49:43 -0500

Seen: 1,317 times

Last updated: Oct 31 '16