data_dump.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 #  data_dump dumps wifi scans into a csv file.
00004 #  Copyright (C) 2013  Rafael Berkvens rafael.berkvens@ua.ac.be
00005 #
00006 #  This program is free software: you can redistribute it and/or modify
00007 #  it under the terms of the GNU General Public License as published by
00008 #  the Free Software Foundation, either version 3 of the License, or
00009 #  (at your option) any later version.
00010 #
00011 #  This program is distributed in the hope that it will be useful,
00012 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 #  GNU General Public License for more details.
00015 #
00016 #  You should have received a copy of the GNU General Public License
00017 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 
00019 import rospy
00020 from wifi_scan.msg import Fingerprint
00021 from std_msgs.msg import Header
00022 
00023 def fingerprintCallback(fingerprint, f):
00024   rospy.loginfo(rospy.get_name() + ": I heard something")
00025   f.write(str(fingerprint.header.stamp) + ',')
00026   for address_rssi in fingerprint.list:
00027     values = address_rssi.address
00028     values += ','
00029     values += str(address_rssi.rssi)
00030     values +=','
00031     f.write(values)
00032   f.write('\n')
00033 
00034 def groundTruthCallback(data, f):
00035   rospy.loginfo(rospy.get_name() + ": I heard something")
00036   f.write(str(data.stamp) + ',' + data.frame_id)
00037   f.write('\n')
00038 
00039 def data_dump():
00040   rospy.init_node('data_dump')
00041   f = open('dump.csv', 'w')
00042   f.write('')
00043   f.close()
00044   f = open('dump.csv', 'a')
00045   rospy.Subscriber("/wifi_fp", Fingerprint, fingerprintCallback, f)
00046   rospy.Subscriber("/gt_nfc", Header, groundTruthCallback, f)
00047   rospy.spin()
00048 
00049 if __name__ == '__main__':
00050   data_dump()


wifi_scan
Author(s): Rafael Berkvens
autogenerated on Fri Aug 28 2015 13:41:23