Custom ROS message with unit8[] in python!
I have a PacketMsg.msg
as follows in my package:
uint8[] buf
I would like to decode /topic
with this sample python script;
import rospy
from ouster_ros.msg import PacketMsg
def cb(msg):
rospy.loginfo('len_msg: {}, type_msg: {}'.format(len(msg.buf), type(msg.buf)))
rospy.loginfo('msg: {}'.format(msg.buf))
def main():
rospy.init_node("my_sub")
rospy.Subscriber('/topic', PacketMsg,cb)
rospy.spin()
if __name__ == "__main__":
main()
This is the output printed in terminal:
[INFO] [1579270050.540915]: len_msg: 49, type_msg: <type 'str'>
[INFO] [1579270050.541343]: msg: ��H?�~�a�B��`����g=��?M��
whereas, $ rostopic echo /topic
returns:
buf: [47, 185, 250, 245, 155, 0, 0, 0, 54, 238, 166, ....................... , 23, 154, 0, 0]
Does anybody know how to change such <type 'str'>
to a list for further usages?
Cheers,