From b182f5635d7ed7c05c0043fd33014516cc4fac1f Mon Sep 17 00:00:00 2001 From: Florian Zirker Date: Tue, 8 Jan 2019 11:49:58 +0100 Subject: [PATCH] python script to export data --- src/export-data.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 src/export-data.py diff --git a/src/export-data.py b/src/export-data.py new file mode 100755 index 0000000..65af273 --- /dev/null +++ b/src/export-data.py @@ -0,0 +1,33 @@ +#!/usr/bin/python2 + +import rosbag +import sys +import os +from wlan_pioneer.msg import WlanSignalMsg +from geometry_msgs.msg import Point +import datetime + +inFileName = os.path.abspath(sys.argv[1]) +outFileName = os.path.join(os.path.dirname(inFileName), os.path.basename(inFileName).split(".")[0] + ".csv") +count = 0 +pos = Point() +bag = rosbag.Bag(inFileName) +outFile = open(outFileName, "w") +outFile.write("SecsSinceEpoch;xPos;yPos;level2G4;level5G\n") + +for topic, msg, timestamp in bag.read_messages(topics=['/wlan_signal', '/pose']): + + if (topic == "/pose"): + pos = msg.pose.pose.position + + if (topic == "/wlan_signal"): + timeStr = datetime.datetime.fromtimestamp(msg.timestamp.secs).isoformat() + outFile.write("%s;%f;%f;%d;%d\n" + % (timeStr, pos.x, pos.y, msg.level_2G4, msg.level_5G)) + + count += 1 + +print "%d rows written to %s" % (count, outFileName) + +outFile.close() +bag.close()