Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

extract topic to csv file

import rosbag
from geometry_msgs.msg import Point
import pandas as pd

# The bag file should be in the same directory as your terminal
bag = rosbag.Bag('./recorded-data.bag')
topic = '/your_topic'
column_names = ['x', 'y']
df = pd.DataFrame(columns=column_names)

for topic, msg, t in bag.read_messages(topics=topic):
    x = msg.x
    y = msg.y

    df = df.append(
        {'x': x,
         'y': y},
        ignore_index=True
    )

df.to_csv('out.csv')
 
PREVIOUS NEXT
Tagged: #extract #topic #csv #file
ADD COMMENT
Topic
Name
8+7 =