How to create a rosbag file with messages with an header
Hi,
As I wrote on the title I'm trying to create a rosbag file from another one changing message types and using only some topics from the original one. The problem is, when I play the new rosbag the messages type is Float32, thus headerless.
Does someone know how can I write messages with an header (Float32Stamped or what else) in the new rosbag, without any error? I read that the last parameter of the write function is connection_header, but I didn't find anything that explain something about it. In the following, the code.
Thank you for the help
#!/usr/bin/env python3
import rosbag
from marti_common_msgs.msg import Float32Stamped
with rosbag.Bag('try.bag', 'w') as outbag:
for topic, msg, t in rosbag.Bag('20180810150607_bus_signals.bag').read_messages():
if '/value' in topic:
fmsg = Float32Stamped()
fmsg.header = t
fmsg.value = msg
outbag.write(topic,fmsg.value, fmsg.header if fmsg._has_header else t)
else:
continue
outbag.close()
Wouldn't fmsg._has_header have the same value for every message in the bag file?