-
I am trying to get started with the mcap protobuf writer to create foxglove recordings in .mcap format. I have a very simplified file just writing a few random boxes in a scene update. But when opening the generated mcap file with foxglove studio, it shows "no messages". import random
from foxglove_schemas_protobuf.SceneUpdate_pb2 import SceneUpdate
from mcap_protobuf.writer import Writer
def main():
f = open("test.mcap", "wb")
mcap_writer = Writer(f)
for i in range(0, 10):
ts = int(i * 1e9)
pc_scene = SceneUpdate()
entity = pc_scene.entities.add()
entity.timestamp.FromNanoseconds(ts)
entity.frame_id = "base_link"
for i in range(4):
r = random.randint(0, 255) # uint8
g = random.randint(0, 255) # uint8
b = random.randint(0, 255) # uint8
cube = entity.cubes.add()
cube.size.x = 2
cube.size.y = 2
cube.size.z = 2
cube.pose.position.x = random.uniform(-20, 20) # float32
cube.pose.position.y = random.uniform(-20, 20) # float32
cube.pose.position.z = random.uniform(-2, 2) # float32
cube.color.r = r / 255
cube.color.g = g / 255
cube.color.b = b / 255
cube.color.a = 1
mcap_writer.write_message(
topic="random_boxes",
message=pc_scene,
log_time=ts,
publish_time=ts,
)
if __name__ == "__main__":
main() |
Beta Was this translation helpful? Give feedback.
Answered by
achim-k
Nov 8, 2023
Replies: 0 comments 3 replies
-
I believe you need an You can also use |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
aeon0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe you need an
mcap_writer.finish()
at the end of yourmain()
function.You can also use
mcap doctor <mcap_file>
ormcap info <mcap_file>
to see if something is wrong.