[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [4745]
From: |
antoine drouin |
Subject: |
[paparazzi-commits] [4745] |
Date: |
Mon, 29 Mar 2010 14:13:22 +0000 |
Revision: 4745
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=4745
Author: poine
Date: 2010-03-29 14:13:21 +0000 (Mon, 29 Mar 2010)
Log Message:
-----------
Modified Paths:
--------------
paparazzi3/trunk/sw/tools/calibration/calibrate.py
paparazzi3/trunk/sw/tools/calibration/sensor_calibration.py
Added Paths:
-----------
paparazzi3/trunk/sw/tools/calibration/calibrate_gui.py
Modified: paparazzi3/trunk/sw/tools/calibration/calibrate.py
===================================================================
--- paparazzi3/trunk/sw/tools/calibration/calibrate.py 2010-03-29 09:33:47 UTC
(rev 4744)
+++ paparazzi3/trunk/sw/tools/calibration/calibrate.py 2010-03-29 14:13:21 UTC
(rev 4745)
@@ -1,5 +1,28 @@
#! /usr/bin/env python
+# $Id$
+# Copyright (C) 2010 Antoine Drouin
+#
+# This file is part of Paparazzi.
+#
+# Paparazzi is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# Paparazzi is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Paparazzi; see the file COPYING. If not, write to
+# the Free Software Foundation, 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+
+
+
import os
from optparse import OptionParser
import scipy
@@ -28,6 +51,10 @@
else:
print args[0] + " not found"
sys.exit(1)
+ ac_ids = sensor_calibration.get_ids_in_log(filename)
+# import code; code.interact(local=locals())
+ if options.ac_id == None and len(ac_ids) == 1:
+ options.ac_id = ac_ids[0]
if options.verbose:
print "reading file "+filename+" for aircraft "+options.ac_id+" and
sensor "+options.sensor
measurements = sensor_calibration.read_log(options.ac_id, filename,
options.sensor)
Added: paparazzi3/trunk/sw/tools/calibration/calibrate_gui.py
===================================================================
--- paparazzi3/trunk/sw/tools/calibration/calibrate_gui.py
(rev 0)
+++ paparazzi3/trunk/sw/tools/calibration/calibrate_gui.py 2010-03-29
14:13:21 UTC (rev 4745)
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+
+# $Id$
+# Copyright (C) 2010 Antoine Drouin
+#
+# This file is part of Paparazzi.
+#
+# Paparazzi is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# Paparazzi is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Paparazzi; see the file COPYING. If not, write to
+# the Free Software Foundation, 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+import os
+
+import sensor_calibration
+
+class CalibrateGui:
+
+ #
+ # loads a log
+ #
+ def on_load_log(self, widget, data=None):
+ print "Loading log"
+ dialog = gtk.FileChooserDialog("Open..",
+ None,
+ gtk.FILE_CHOOSER_ACTION_OPEN,
+ (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+ dialog.set_default_response(gtk.RESPONSE_OK)
+ pprz_home = os.environ.get("PAPARAZZI_HOME")
+ if pprz_home != None:
+ dialog.set_current_folder(pprz_home+"/var/logs")
+
+ filter = gtk.FileFilter()
+ filter.set_name("Logs")
+ filter.add_mime_type("paparazzi/logs")
+ filter.add_pattern("*.data")
+ dialog.add_filter(filter)
+
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ dialog.add_filter(filter)
+
+ response = dialog.run()
+ if response == gtk.RESPONSE_OK:
+ print dialog.get_filename(), 'selected'
+ ac_ids = sensor_calibration.get_ids_in_log(dialog.get_filename())
+ elif response == gtk.RESPONSE_CANCEL:
+ print 'Closed, no files selected'
+ dialog.destroy()
+
+ def delete_event(self, widget, event, data=None):
+ print "delete event occurred"
+ return False
+
+ def destroy(self, widget, data=None):
+ print "destroy signal occurred"
+ gtk.main_quit()
+
+ #
+ # build gui
+ #
+ def build_gui(self):
+ self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window.connect("delete_event", self.delete_event)
+ self.window.connect("destroy", self.destroy)
+ self.window.set_title("Paparazzi Sensor Calibration")
+ self.window.set_border_width(10)
+ table = gtk.Table(2, 2, True)
+ self.window.add(table)
+ table.attach(gtk.Label("Log :"), 0, 1, 0, 1)
+ self.label_log = gtk.Label("None")
+ table.attach(self.label_log, 1, 2, 0, 1)
+ self.button_load_log = gtk.Button("Load log")
+ self.button_load_log.connect("clicked", self.on_load_log, None)
+ table.attach(self.button_load_log, 1, 2, 1, 2)
+ self.window.show_all()
+
+
+ def __init__(self):
+ self.build_gui();
+
+ def main(self):
+ gtk.main()
+
+if __name__ == "__main__":
+ app = CalibrateGui()
+ app.main()
Property changes on: paparazzi3/trunk/sw/tools/calibration/calibrate_gui.py
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:keywords
+ id
Modified: paparazzi3/trunk/sw/tools/calibration/sensor_calibration.py
===================================================================
--- paparazzi3/trunk/sw/tools/calibration/sensor_calibration.py 2010-03-29
09:33:47 UTC (rev 4744)
+++ paparazzi3/trunk/sw/tools/calibration/sensor_calibration.py 2010-03-29
14:13:21 UTC (rev 4745)
@@ -1,12 +1,52 @@
+# $Id$
+# Copyright (C) 2010 Antoine Drouin
+#
+# This file is part of Paparazzi.
+#
+# Paparazzi is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# Paparazzi is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Paparazzi; see the file COPYING. If not, write to
+# the Free Software Foundation, 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+
import re
import scipy
from scipy import linalg
from pylab import *
+
#
-# parse a log and extracts raw sensor measurements
+# returns available ac_id from a log
#
+def get_ids_in_log(filename):
+ f = open(filename, 'r')
+ ids = []
+ pattern = re.compile("\S+ (\S+)")
+ while 1:
+ line = f.readline().strip()
+ if line == '':
+ break
+ m=re.match(pattern, line)
+ if m:
+ id = m.group(1)
+ if not id in ids:
+ ids.append(id)
+ return ids
+
+#
+# extracts raw sensor measurements from a log
+#
def read_log(ac_id, filename, sensor):
f = open(filename, 'r')
pattern = re.compile("(\S+) "+ac_id+" IMU_"+sensor+"_RAW (\S+) (\S+)
(\S+)")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [4745],
antoine drouin <=