From bd8d761bdcbeab2bb7fca6a2b048dfe062f2d156 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 13 Apr 2011 11:05:52 +0200 Subject: [PATCH 01/26] [Client] Makefile: fix static target --- owlps-client/Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/owlps-client/Makefile b/owlps-client/Makefile index dd00660..cfd82c2 100644 --- a/owlps-client/Makefile +++ b/owlps-client/Makefile @@ -45,17 +45,17 @@ dynamic : $(TARGET) static : $(TARGET).static all : dynamic static -% : %.o +# Cancel implicit make rule +%: %.c + +%: %.o $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) -%.o : %.c $(HEADER) +%.static: %.o + $(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ \ + $(LDFLAGS) $(LIBS) $(STATIC_LIBS) -static +%.o: %.c $(HEADER) $(CC) $(XCFLAGS) $(OWLPSFLAGS) -c $< -# Compilation du programme -$(TARGET) : $(TARGET).o $(HEADER) - -$(TARGET).static : $(TARGET).c $(HEADER) - $(CC) $(LDFLAGS) -static $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) $(STATIC_LIBS) - ## Installation / désinstallation ## From 8d2a2b3e5abcca4bf0cc12c944aa3fd5f174eba4 Mon Sep 17 00:00:00 2001 From: Florian Taillard Date: Mon, 18 Apr 2011 13:52:43 +0200 Subject: [PATCH 02/26] [Positioning] Fix accesspoint reading frequency Change long to unsigned long in accesspointsreadercsv.cc. The frequency value exceed a long lenght in arch 32bits. --- owlps-positioning/src/accesspointsreadercsv.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/owlps-positioning/src/accesspointsreadercsv.cc b/owlps-positioning/src/accesspointsreadercsv.cc index b6c7508..a33aa52 100644 --- a/owlps-positioning/src/accesspointsreadercsv.cc +++ b/owlps-positioning/src/accesspointsreadercsv.cc @@ -38,7 +38,7 @@ void AccessPointsReaderCSV::process_access_point_line() if (! file.read_point3d(coord)) throw malformed_input_data("Cannot read access point coordinates!") ; - long frequency ; + unsigned long frequency ; if (! file.read_field(frequency)) throw malformed_input_data("Cannot read access point frequency!") ; From 08a407e0f3e8b5db200a952c2eb9d7aa54282809 Mon Sep 17 00:00:00 2001 From: Florian Taillard Date: Mon, 18 Apr 2011 16:31:10 +0200 Subject: [PATCH 03/26] [Positioning] Fix reading csv calibration file Add uint16_t into inputcsv to fix read type packet. The uint8_t is detected as a char. --- owlps-positioning/src/inputcsv.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/owlps-positioning/src/inputcsv.cc b/owlps-positioning/src/inputcsv.cc index fc4a6ff..0882d14 100644 --- a/owlps-positioning/src/inputcsv.cc +++ b/owlps-positioning/src/inputcsv.cc @@ -45,12 +45,14 @@ const Request& InputCSV::get_next_request() // Read request type uint8_t type ; - if (! file.read_field(type)) + uint16_t type_r ; + if (! file.read_field(type_r)) { // Wrong number of fields: blank current request current_request->clear() ; return *current_request ; } + type = type_r ; current_request->set_type(type) ; // Read Timestamp field From 3196e5a2e00d97ebf4cdb4caf34fef7ff28f193e Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 13 Apr 2011 13:32:11 +0200 Subject: [PATCH 04/26] Makefiles: resolve OWLPS_VERSION earlier --- owlps-aggregator/Makefile | 2 +- owlps-client/Makefile | 2 +- owlps-client/Makefile_atheros | 2 +- owlps-client/Makefile_atheros_openwrt-10.03 | 2 +- owlps-listener/Makefile | 2 +- owlps-listener/Makefile_atheros | 2 +- owlps-positioning/Makefile | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/owlps-aggregator/Makefile b/owlps-aggregator/Makefile index 74abb2a..e2d6985 100644 --- a/owlps-aggregator/Makefile +++ b/owlps-aggregator/Makefile @@ -1,6 +1,6 @@ # Source version ifndef OWLPS_VERSION - OWLPS_VERSION = $$(git describe || echo 'UNKNOWN_VERSION') + OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') endif # Répertoire d'installation diff --git a/owlps-client/Makefile b/owlps-client/Makefile index cfd82c2..accff24 100644 --- a/owlps-client/Makefile +++ b/owlps-client/Makefile @@ -1,6 +1,6 @@ # Source version ifndef OWLPS_VERSION - OWLPS_VERSION = $$(git describe || echo 'UNKNOWN_VERSION') + OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') endif # Répertoire d'installation diff --git a/owlps-client/Makefile_atheros b/owlps-client/Makefile_atheros index 8cb08e9..89fbb3c 100644 --- a/owlps-client/Makefile_atheros +++ b/owlps-client/Makefile_atheros @@ -1,6 +1,6 @@ # Source version ifndef OWLPS_VERSION - OWLPS_VERSION = $$(git describe || echo 'UNKNOWN_VERSION') + OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') endif # Emplacement de la suite de cross-compilation diff --git a/owlps-client/Makefile_atheros_openwrt-10.03 b/owlps-client/Makefile_atheros_openwrt-10.03 index 9b57248..27545d2 100644 --- a/owlps-client/Makefile_atheros_openwrt-10.03 +++ b/owlps-client/Makefile_atheros_openwrt-10.03 @@ -1,6 +1,6 @@ # Source version ifndef OWLPS_VERSION - OWLPS_VERSION = $$(git describe || echo 'UNKNOWN_VERSION') + OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') endif # Emplacement de la suite de cross-compilation diff --git a/owlps-listener/Makefile b/owlps-listener/Makefile index fd217dd..1c7f66b 100644 --- a/owlps-listener/Makefile +++ b/owlps-listener/Makefile @@ -1,6 +1,6 @@ # Source version ifndef OWLPS_VERSION - OWLPS_VERSION = $$(git describe || echo 'UNKNOWN_VERSION') + OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') endif # Répertoire d'installation diff --git a/owlps-listener/Makefile_atheros b/owlps-listener/Makefile_atheros index 2604b04..bf5260e 100644 --- a/owlps-listener/Makefile_atheros +++ b/owlps-listener/Makefile_atheros @@ -1,6 +1,6 @@ # Source version ifndef OWLPS_VERSION - OWLPS_VERSION = $$(git describe) + OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') endif # Emplacement de la suite de cross-compilation diff --git a/owlps-positioning/Makefile b/owlps-positioning/Makefile index 5545c48..0e02bb2 100644 --- a/owlps-positioning/Makefile +++ b/owlps-positioning/Makefile @@ -1,6 +1,6 @@ # Source version ifndef OWLPS_VERSION - OWLPS_VERSION = $$(git describe || echo 'UNKNOWN_VERSION') + OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') endif # Directories & files From 810a29cec38675d97354a7500fa60f91c7ab0a1c Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 26 Apr 2011 10:28:51 +0200 Subject: [PATCH 05/26] [Positioning] Translate READMEs --- owlps-positioning/csv/README | 6 +++--- owlps-positioning/log/README | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/owlps-positioning/csv/README b/owlps-positioning/csv/README index 2a16689..56bc5e2 100644 --- a/owlps-positioning/csv/README +++ b/owlps-positioning/csv/README @@ -1,5 +1,5 @@ -Ce répertoire sert à stocker les fichiers d'entrée de GuiNuMo-server. -Vous pouvez trouver des fichiers d'exemple sur : +This directory is for storing the owlps-positioning input files. +You can find example data files at: http://pif.pu-pm.univ-fcomte.fr/~mcyprian/mesures/ --- Vous pouvez supprimer ce fichier sans danger. -- +-- You can safely delete this file. -- diff --git a/owlps-positioning/log/README b/owlps-positioning/log/README index 36d2b8f..083529a 100644 --- a/owlps-positioning/log/README +++ b/owlps-positioning/log/README @@ -1,3 +1,3 @@ -Ce répertoire sert à stocker les fichiers de destination de GuiNuMo-server. +This directory is for storing the owlps-positioning output files. --- Vous pouvez supprimer ce fichier sans danger. -- +-- You can safely delete this file. -- From a54b8ab06b8cb5880ff87ab431dbb41c0910c89d Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 26 Apr 2011 14:14:01 +0200 Subject: [PATCH 06/26] [Positioning] Timestamp: update operator bool() Test tv_sec and tv_usec independently instead of using operator uint64_t(). --- owlps-positioning/src/timestamp.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/owlps-positioning/src/timestamp.hh b/owlps-positioning/src/timestamp.hh index d1a8e5b..de2ae8e 100644 --- a/owlps-positioning/src/timestamp.hh +++ b/owlps-positioning/src/timestamp.hh @@ -228,7 +228,7 @@ inline bool Timestamp::operator>=(const uint64_t source) const inline Timestamp::operator bool() const { - return static_cast(*this) > 0 ; + return timestamp.tv_sec > 0 || timestamp.tv_nsec > 0 ; } From 77c66bf194c9d3d034a27b6a9dc174a1c04b5537 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 26 Apr 2011 16:34:58 +0200 Subject: [PATCH 07/26] [Positioning] CalibrationRequest: default args in .cc Move default argument declaration from .hh to .cc. --- owlps-positioning/src/calibrationrequest.cc | 7 ++++--- owlps-positioning/src/calibrationrequest.hh | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/owlps-positioning/src/calibrationrequest.cc b/owlps-positioning/src/calibrationrequest.cc index bfd1bb4..cb33471 100644 --- a/owlps-positioning/src/calibrationrequest.cc +++ b/owlps-positioning/src/calibrationrequest.cc @@ -6,7 +6,8 @@ /* *** Constructors *** */ -CalibrationRequest::CalibrationRequest(uint_fast8_t _type): +CalibrationRequest:: +CalibrationRequest(uint_fast8_t _type = OWL_REQUEST_AUTOCALIBRATION): reference_point(NULL), direction(Direction()) { type = _type ; @@ -16,8 +17,8 @@ CalibrationRequest::CalibrationRequest(uint_fast8_t _type): CalibrationRequest:: CalibrationRequest(const Request &source, ReferencePoint *_reference_point = NULL, - const Direction &_direction, - uint_fast8_t _type): + const Direction &_direction = Direction(), + uint_fast8_t _type = OWL_REQUEST_AUTOCALIBRATION): Request(source), reference_point(_reference_point), direction(_direction) { diff --git a/owlps-positioning/src/calibrationrequest.hh b/owlps-positioning/src/calibrationrequest.hh index 4d85529..d0a26eb 100644 --- a/owlps-positioning/src/calibrationrequest.hh +++ b/owlps-positioning/src/calibrationrequest.hh @@ -16,14 +16,16 @@ protected: Direction direction ; public: - CalibrationRequest(uint_fast8_t _type = OWL_REQUEST_AUTOCALIBRATION) ; + CalibrationRequest(uint_fast8_t _type) ; + CalibrationRequest(const CalibrationRequest &source): Request(source), reference_point(source.reference_point), direction(source.direction) {} + CalibrationRequest(const Request &source, ReferencePoint *_reference_point, - const Direction &_direction = Direction(), - uint_fast8_t _type = OWL_REQUEST_AUTOCALIBRATION) ; + const Direction &_direction, + uint_fast8_t _type) ; ~CalibrationRequest(void) {} From c9d26033e9a87d8a484ec770dfdeb2893c8c40f7 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 26 Apr 2011 16:37:11 +0200 Subject: [PATCH 08/26] [Positioning] InputCSV: add debug info --- owlps-positioning/src/inputcsv.cc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/owlps-positioning/src/inputcsv.cc b/owlps-positioning/src/inputcsv.cc index 0882d14..d38a5c9 100644 --- a/owlps-positioning/src/inputcsv.cc +++ b/owlps-positioning/src/inputcsv.cc @@ -10,6 +10,8 @@ using namespace std ; using std::tr1::unordered_map ; +#define DEBUG + /* *** Operations *** */ @@ -39,7 +41,12 @@ const Request& InputCSV::get_next_request() // Read Mobile MAC field string mac_mobile ; if (! file.read_field(mac_mobile)) // Wrong number of fields - return *current_request ; + { +#ifdef DEBUG + cerr << "InputCSV: cannot read mac_mobile.\n" ; +#endif // DEBUG + return *current_request ; + } const Mobile &mobile = Stock::find_create_mobile(mac_mobile) ; current_request->set_mobile(&mobile) ; @@ -50,6 +57,9 @@ const Request& InputCSV::get_next_request() { // Wrong number of fields: blank current request current_request->clear() ; +#ifdef DEBUG + cerr << "InputCSV: cannot read type.\n" ; +#endif // DEBUG return *current_request ; } type = type_r ; @@ -61,6 +71,9 @@ const Request& InputCSV::get_next_request() { // Wrong number of fields: blank current request current_request->clear() ; +#ifdef DEBUG + cerr << "InputCSV: cannot read timestamp.\n" ; +#endif // DEBUG return *current_request ; } current_request->set_time_sent(timestamp) ; @@ -71,6 +84,9 @@ const Request& InputCSV::get_next_request() { // Wrong number of fields: blank current request current_request->clear() ; +#ifdef DEBUG + cerr << "InputCSV: cannot read coordinates.\n" ; +#endif // DEBUG return *current_request ; } @@ -81,6 +97,9 @@ const Request& InputCSV::get_next_request() { // Wrong number of fields: blank current request current_request->clear() ; +#ifdef DEBUG + cerr << "InputCSV: cannot read direction.\n" ; +#endif // DEBUG return *current_request ; } if (direction_int != 0) @@ -97,6 +116,9 @@ const Request& InputCSV::get_next_request() { // Wrong number of fields: blank current request current_request->clear() ; +#ifdef DEBUG + cerr << "InputCSV: cannot read mac_ap.\n" ; +#endif // DEBUG return *current_request ; } const AccessPoint &ap = Stock::find_create_ap(mac_ap) ; From ea8da6d8ecd78a6521349d205c06d9cc4a8d986f Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 26 Apr 2011 16:42:35 +0200 Subject: [PATCH 09/26] =?UTF-8?q?[Positioning]=20Fix=20InputMedium::?= =?UTF-8?q?=E2=80=A6=5Fto=5Fcalibration=5Frequest()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix InputMedium::current_request_to_calibration_request(), that was resulting in a blank request. --- owlps-positioning/src/inputcsv.cc | 7 ++----- owlps-positioning/src/inputmedium.cc | 19 ++++++++++++++----- owlps-positioning/src/inputmedium.hh | 7 ++++++- owlps-positioning/src/inputudpsocket.cc | 10 +++------- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/owlps-positioning/src/inputcsv.cc b/owlps-positioning/src/inputcsv.cc index d38a5c9..8dc0dd4 100644 --- a/owlps-positioning/src/inputcsv.cc +++ b/owlps-positioning/src/inputcsv.cc @@ -132,14 +132,11 @@ const Request& InputCSV::get_next_request() if (type == OWL_REQUEST_CALIBRATION || type == OWL_REQUEST_AUTOCALIBRATION) { - current_request_to_calibration_request(type) ; - CalibrationRequest *request = - static_cast(current_request) ; - request->set_direction(direction) ; ReferencePoint position(pos) ; const ReferencePoint &reference_point = Stock::find_create_reference_point(position) ; - request->set_reference_point(&reference_point) ; + current_request_to_calibration_request(&reference_point, + direction, type) ; } return *current_request ; diff --git a/owlps-positioning/src/inputmedium.cc b/owlps-positioning/src/inputmedium.cc index 4fa7d56..e424633 100644 --- a/owlps-positioning/src/inputmedium.cc +++ b/owlps-positioning/src/inputmedium.cc @@ -24,18 +24,27 @@ InputMedium::~InputMedium() void InputMedium:: -current_request_to_calibration_request(uint_fast8_t request_type) +current_request_to_calibration_request( + const ReferencePoint *const reference_point, + const Direction &direction, + const uint_fast8_t request_type) { - if (dynamic_cast(current_request) != NULL) + CalibrationRequest *calibration_request = + dynamic_cast(current_request) ; + if (calibration_request != NULL) { - current_request->set_type(request_type) ; + calibration_request->set_reference_point(reference_point) ; + calibration_request->set_direction(direction) ; + calibration_request->set_type(request_type) ; return ; } Request *tmp = current_request ; current_request = NULL ; - current_request = new CalibrationRequest(*tmp) ; - current_request->set_type(request_type) ; + current_request = + new CalibrationRequest(*tmp, + const_cast(reference_point), + direction, request_type) ; delete tmp ; } diff --git a/owlps-positioning/src/inputmedium.hh b/owlps-positioning/src/inputmedium.hh index a08d26c..c4a7571 100644 --- a/owlps-positioning/src/inputmedium.hh +++ b/owlps-positioning/src/inputmedium.hh @@ -1,6 +1,9 @@ #ifndef _OWLPS_POSITIONING_INPUTMEDIUM_HH_ #define _OWLPS_POSITIONING_INPUTMEDIUM_HH_ +class ReferencePoint ; +class Direction ; + #include "request.hh" /// Super class of all input media @@ -51,7 +54,9 @@ public: /// Converts #current_request into a CalibrationRequest void current_request_to_calibration_request( - uint_fast8_t request_type = OWL_REQUEST_CALIBRATION) ; + const ReferencePoint *const reference_point, + const Direction &direction, + uint_fast8_t request_type) ; /// Clears (reallocates to Request if needed) #current_request void clear_current_request(void) ; diff --git a/owlps-positioning/src/inputudpsocket.cc b/owlps-positioning/src/inputudpsocket.cc index d2028bf..7f4080a 100644 --- a/owlps-positioning/src/inputudpsocket.cc +++ b/owlps-positioning/src/inputudpsocket.cc @@ -144,18 +144,14 @@ const Request& InputUDPSocket::get_next_request() if (request.type == OWL_REQUEST_CALIBRATION || request.type == OWL_REQUEST_AUTOCALIBRATION) { - current_request_to_calibration_request(request.type) ; - CalibrationRequest *calib_request = - static_cast(current_request) ; - - calib_request->set_direction(Direction(request.direction)) ; - ReferencePoint position(owl_ntohf(request.x_position), owl_ntohf(request.y_position), owl_ntohf(request.z_position)) ; const ReferencePoint &reference_point = Stock::find_create_reference_point(position) ; - calib_request->set_reference_point(&reference_point) ; + current_request_to_calibration_request(&reference_point, + Direction(request.direction), + request.type) ; } return *current_request ; From 1cebc82bfdc82afeb0df4f49e9cb9d4e8da510c4 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 26 Apr 2011 16:43:46 +0200 Subject: [PATCH 10/26] [Positioning] Minor edits InputDataReader: minor refactoring. Request: fix a comment. --- owlps-positioning/src/inputdatareader.cc | 6 +++--- owlps-positioning/src/request.hh | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/owlps-positioning/src/inputdatareader.cc b/owlps-positioning/src/inputdatareader.cc index 4ca8062..cec622c 100644 --- a/owlps-positioning/src/inputdatareader.cc +++ b/owlps-positioning/src/inputdatareader.cc @@ -175,12 +175,12 @@ void InputDataReader::read_from_reference_points_media() { while (! (*i)->eof()) { - Request &request = - const_cast((*i)->get_next_request()) ; + const Request &request = (*i)->get_next_request() ; if (! request) continue ; CalibrationRequest *calibration_request = - dynamic_cast(&request) ; + dynamic_cast( + const_cast(&request)) ; if (calibration_request == NULL) cerr << "Warning! Invalid calibration request at line " diff --git a/owlps-positioning/src/request.hh b/owlps-positioning/src/request.hh index 59fb421..282af2f 100644 --- a/owlps-positioning/src/request.hh +++ b/owlps-positioning/src/request.hh @@ -164,7 +164,8 @@ inline bool Request::operator!=(const Request &comp) const /** * @return \em false if the Request is empty. - * @return \em true if at least one attribute is initialised. + * @return \em true if at least one attribute (other than #type) is + * initialised. */ inline Request::operator bool() const { From 38c3402a15eb7662ecc4e9225e7612cdfb577b08 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 27 Apr 2011 16:36:36 +0200 Subject: [PATCH 11/26] [Positioning] Update/clean configuration files --- owlps-positioning/cfg/listerers.csv | 10 ++ owlps-positioning/cfg/minipc.csv | 20 --- owlps-positioning/cfg/owlps-positioning.cfg | 22 ++- owlps-positioning/cfg/topo.csv | 48 ------- owlps-positioning/cfg/topology.csv | 31 +++++ owlps-positioning/cfg/waypoints.csv | 141 +++----------------- 6 files changed, 76 insertions(+), 196 deletions(-) create mode 100644 owlps-positioning/cfg/listerers.csv delete mode 100644 owlps-positioning/cfg/minipc.csv delete mode 100644 owlps-positioning/cfg/topo.csv create mode 100644 owlps-positioning/cfg/topology.csv diff --git a/owlps-positioning/cfg/listerers.csv b/owlps-positioning/cfg/listerers.csv new file mode 100644 index 0000000..f773f5d --- /dev/null +++ b/owlps-positioning/cfg/listerers.csv @@ -0,0 +1,10 @@ +# Listeners' physical description file. +# +# Each line follows this format: +# MAC address;X;Y;Z;Channel (Hz);Antenna gain (dBi);Trx power (dBm) +# +# Blank lines are ignored. Commented lines must have a sharp (#) as +# their FIRST character. + +# Example listener: +#00:11:22:33:44:55;4;0.5;7.95;2417000000;5.0;20.0 diff --git a/owlps-positioning/cfg/minipc.csv b/owlps-positioning/cfg/minipc.csv deleted file mode 100644 index 0422be5..0000000 --- a/owlps-positioning/cfg/minipc.csv +++ /dev/null @@ -1,20 +0,0 @@ -# Fichier de configuration pour les AP. -# Chaque ligne est de la forme : -# MAC;X;Y;Z;Fréquence d'émission (Hz);Gain d'antenne (dBi);Puissance d'émission (dBm) -# Les lignes vides ou commençant par un # sont ignorées. Les -# commentaires doivent obligatoirement être en début de ligne. - -# mini5 (Laseldi) -00:13:CE:95:E1:6F;4.93;25.81;3.55;2417000000;5.0;20.0 - -# mini6 (Laurent / Wassim) -00:13:CE:95:DE:7E;4.83;10.88;3.78;2417000000;5.0;20.0 - -# mini4 (Incubateur) -00:13:CE:97:78:79;20.05;28.31;3.74;2417000000;5.0;20.0 - -# mini3 (Dominique) -00:13:CE:8F:77:43;4.13;7.085;0.80;2417000000;5.0;20.0 - -# mini1 (Adrien) -00:13:CE:8F:78:D9;5.74;30.35;2.04;2417000000;5.0;20.0 diff --git a/owlps-positioning/cfg/owlps-positioning.cfg b/owlps-positioning/cfg/owlps-positioning.cfg index 02f555e..3ee1204 100644 --- a/owlps-positioning/cfg/owlps-positioning.cfg +++ b/owlps-positioning/cfg/owlps-positioning.cfg @@ -1,15 +1,21 @@ # Sample configuration file for OWLPS Positioning -# Miscellaneous options +# [Miscellaneous options] + #flush-output-files = true [data-input] -#ap-medium = CSV -ap-csv-file = cfg/access_points.csv +# Description of the machines running the listeners. +ap-medium = CSV +ap-csv-file = cfg/listeners.csv -topology-medium = CSV -areas-csv-file = cfg/topo.csv +# Description of deployment area topology. +# You probably don't need a full description of the topology, see the +# topology example file for details. +# Uncomment the following line to activate the topology reading. +#topology-medium = CSV +areas-csv-file = cfg/topology.csv waypoints-csv-file = cfg/waypoints.csv #reference-points-medium = CSV @@ -32,10 +38,16 @@ csv-file = /tmp/owlps-positioning.log [positioning] +# Uncomment lines to activate one or more algorithm. +#algorithm = Real +#algorithm = InterlinkNetworks +#algorithm = FBCM +#algorithm = RADAR #algorithm = FRBHMBasic [output] +# This is the default output if none is specified. #medium = Terminal #medium = CSV diff --git a/owlps-positioning/cfg/topo.csv b/owlps-positioning/cfg/topo.csv deleted file mode 100644 index 2c606d2..0000000 --- a/owlps-positioning/cfg/topo.csv +++ /dev/null @@ -1,48 +0,0 @@ -# Liste des bâtiments et de leurs zones homogènes (pièces). -# Chaque ligne définit une zone, de la forme : -# Nom du bâtiment;Nom de la pièce;X1;Y1;X2;Y2;Z1;Z2 - - -### Rez-de-chaussée ### -# -Numerica;0140;1.00;7.28;6.05;3.70;0.00;2.99 -Numerica;0130;1.00;10.88;6.05;7.28;0.00;2.99 -Numerica;0120;1.00;14.48;6.05;10.88;0.00;2.99 -Numerica;0110;1.00;18.12;6.05;14.48;0.00;2.99 -Numerica;0100;1.00;21.66;6.05;18.12;0.00;2.99 -Numerica;0090;1.00;25.32;6.05;21.66;0.00;2.99 -Numerica;0080;1.00;29.00;6.05;25.32;0.00;2.99 -Numerica;0070;1.00;32.00;6.05;29.00;0.00;2.99 -Numerica;WC N0;8.20;5.30;10.00;0.50;0.00;2.99 -Numerica;0085;8.20;9.00;10.00;5.30;0.00;2.99 -Numerica;0075;8.20;10.88;10.00;9.00;0.00;2.99 -Numerica;Palier N0;5.00;3.70;8.20;0.50;0.00;2.99 -Numerica;Couloir N0 A;6.05;30.00;8.20;3.70;0.00;2.99 -Numerica;Couloir N0 B;8.20;16.50;10.00;10.88;0.00;2.99 -Numerica;Couloir N0 C;8.20;24.80;10.00;22.60;0.00;2.99 - - -### Escaliers N0 / N1 ### -# -# TODO : affiner la hauteur, etc. -Numerica;Escalier N0-N1 A;8.20;22.60;10.00;16.50;0.00;6.00 -Numerica;Escalier N0-N1 B1;2.50;2.00;5.00;0.50;0.00;6.00 -Numerica;Escalier N0-N1 B palier;1.00;3.70;2.50;0.50;1.50;6.00 -Numerica;Escalier N0-N1 B2;2.50;3.70;5.00;2.00;1.50;6.00 - - -### Premier étage ### -# -Numerica;1100;1.00;7.28;6.05;3.70;3.00;6.00 -Numerica;0190;1.00;10.88;6.05;7.28;3.00;6.00 -Numerica;0180;1.00;14.48;6.05;10.88;3.00;6.00 -Numerica;1070;1.00;18.12;6.05;14.48;3.00;6.00 -Numerica;1060;1.00;25.32;6.05;18.12;3.00;6.00 -Numerica;1050;1.00;31.40;6.05;25.32;3.00;6.00 -Numerica;WC N1;8.20;9.00;10.00;0.50;3.00;6.00 -Numerica;1105;8.20;10.88;10.00;9.00;3.00;6.00 -Numerica;1095;8.20;29.30;10.00;24.80;3.00;6.00 -Numerica;Palier N1;5.00;3.70;8.20;0.50;3.00;6.00 -Numerica;Couloir N1 A;6.05;29.50;8.20;3.70;3.00;6.00 -Numerica;Couloir N1 B;8.20;16.50;10.00;10.88;3.00;6.00 -Numerica;Couloir N1 C;8.20;24.80;10.00;22.60;3.00;6.00 diff --git a/owlps-positioning/cfg/topology.csv b/owlps-positioning/cfg/topology.csv new file mode 100644 index 0000000..6c5d32c --- /dev/null +++ b/owlps-positioning/cfg/topology.csv @@ -0,0 +1,31 @@ +# Description of deployment area topology (rooms). +# +# IMPORTANT: +# You need a precise topology description if you use algorithms that +# handle it. Since none of them are currenty implemented, you probably +# can save a lot of time by only providing a pseudo-area containing +# the whole deployment area in this file (in this case you will not +# declare any waypoint in the waypoints' definition file). +# +# This file lists the buildings and their "homogeneous areas" (rooms). +# +# Each line defines an area, using the following format: +# Building name;Room name;X1;Y1;Z1;X2;Y2;Z2 + + +### First floor ### +# +#My Building;Entrance;1.00;7.28;6.05;3.70;0.00;2.99 +#My Building;Corridor A;6.05;30.00;8.20;3.70;0.00;2.99 + + +### 1st/2nd floor staircase ### +# +#My Building;Staircase;2.50;2.00;0.00;5.00;0.50;6.00 +#My Building;Staircase landing;1.00;3.70;1.50;2.50;0.50;6.00 +#My Building;Staircase;2.50;3.70;1.50;5.00;2.00;6.00 + + +### Second floor ### +# +#My Building;My desk;1.00;7.28;6.05;3.70;3.00;6.00 diff --git a/owlps-positioning/cfg/waypoints.csv b/owlps-positioning/cfg/waypoints.csv index a53bc24..42f8a09 100644 --- a/owlps-positioning/cfg/waypoints.csv +++ b/owlps-positioning/cfg/waypoints.csv @@ -1,124 +1,19 @@ -# Liste des points de passage. -# Chaque ligne définit les trois coordonnées d'un point, de la forme : -# X;Y;Z;Nom du bâtiment 1;…;Nom du bâtiment n -# Chaque point doit appartenir au moins à un bâtiment. +# Description of deployment area topology (waypoints). +# +# IMPORTANT: +# Maybe you don't want to define any waypoint. Please read the +# topology example file before losing time. +# +# This file lists the waypoints linking the areas defined in the +# topology file (doors, etc.). +# +# Each line defines a waypoint, using the following format: +# X;Y;Z;Building1 name;…;BuildingN name +# Each point must belong to at least one building. +# +# Note: for the non-convex rooms (which are defined by several areas in +# the topology file), and for wide gates, you should define one waypoint +# each 1m or 1.5m. -# Note : pour les zones appartenant à la même pièce non-convexe (ex : -# Couloir N0 A et Couloir N0 B), on définit un point tous les 1,50 m. -# Idem pour les portes très larges. - -### Rez-de-chaussée ### - -# 0140 -6.05;6.50;0.00;Numerica - -# 0130 -6.05;7.50;0.00;Numerica - -# 0120 -6.05;13.50;0.00;Numerica - -# 0130 / 0120 -3.00;10.88;0.00;Numerica - -# 0110 -6.05;14.50;0.00;Numerica - -# 0100 -6.05;21.00;0.00;Numerica - -# 0090 -6.05;22.25;0.00;Numerica - -# 0080 -6.05;28.50;0.00;Numerica - -# 0070 -6.05;29.50;0.00;Numerica - -# WC N0 -8.20;5.00;0.00;Numerica - -# 0085 -8.20;8.50;0.00;Numerica - -# 0075 -8.20;9.50;0.00;Numerica - -# Couloir N0 A / B -8.20;11.50;0.00;Numerica -8.20;13.00;0.00;Numerica -8.20;14.50;0.00;Numerica -8.20;16.00;0.00;Numerica - -# Couloir N0 A / C -8.20;23.70;0.00;Numerica - -# Palier N0 -7.50;3.70;0.00;Numerica - - -### Escaliers N0 / N1 ### - -# Couloir N0 C / Escalier NO-N1 A -8.95;22.60;0.00;Numerica - -# Escalier NO-N1 A / Couloir N1 B -8.95;16.50;3.00;Numerica - -# Palier NO / Escalier N0-N1 B1 -5.00;1.25;0.00;Numerica - -# Escalier N0-N1 B1 / Escalier N0-N1 B palier -2.50;1.25;1.50;Numerica - -# Escalier N0-N1 B palier / Escalier N0-N1 B2 -2.50;2.75;1.50;Numerica - -# Escalier N0-N1 B2 / Palier N1 -5.00;2.75;3.00;Numerica - - -### Premier étage ### - -# 1100 -6.05;6.50;3.00;Numerica - -# 0190 -6.05;7.50;3.00;Numerica - -# 0180 -6.05;13.50;3.00;Numerica - -# 0190 / 0180 -3.00;10.88;3.00;Numerica - -# 1070 -6.05;14.50;3.00;Numerica - -# 1060 -6.05;21.00;3.00;Numerica - -# 1050 -6.05;27.75;3.00;Numerica - -# WC N1 -8.20;5.00;3.00;Numerica - -# 1105 -8.20;9.50;3.00;Numerica - -# 1095 -8.20;26.00;3.00;Numerica - -# Couloir N1 A / B -8.20;11.50;3.00;Numerica -8.20;13.00;3.00;Numerica -8.20;14.50;3.00;Numerica -8.20;16.00;3.00;Numerica - -# Couloir N1 A / C -8.20;23.70;3.00;Numerica - -# Palier N1 -7.50;3.70;3.00;Numerica +# Example waypoint: +#1.5;4;0;My Building From ceb035ed197a1ff17a5f999de6ee7bf0c8d90c09 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 27 Apr 2011 17:48:33 +0200 Subject: [PATCH 12/26] [Positioning] Change default configuration file UserInterface: default configuration file is now in /usr/local/etc/owlps instead of ./cfg. --- owlps-positioning/src/userinterface.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/owlps-positioning/src/userinterface.cc b/owlps-positioning/src/userinterface.cc index 4e96d09..5ac3f73 100644 --- a/owlps-positioning/src/userinterface.cc +++ b/owlps-positioning/src/userinterface.cc @@ -14,7 +14,8 @@ namespace po = boost::program_options ; /* *** Default value definitions *** */ -#define DEFAULT_CONFIG_FILE_NAME "cfg/owlps-positioning.cfg" +#define DEFAULT_CONFIG_FILE_NAME \ + "/usr/local/etc/owlps/owlps-positioning.cfg" From ccb57c86ecd495dbc4411cbda8f9768091be68ff Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 27 Apr 2011 18:47:56 +0200 Subject: [PATCH 13/26] [Positioning] Add Point3D::Point3D(string) --- owlps-positioning/Makefile | 2 ++ owlps-positioning/src/point3d.cc | 31 ++++++++++++++++++++++++++++--- owlps-positioning/src/point3d.hh | 3 +++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/owlps-positioning/Makefile b/owlps-positioning/Makefile index 0e02bb2..09aaef1 100644 --- a/owlps-positioning/Makefile +++ b/owlps-positioning/Makefile @@ -133,6 +133,8 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cc $(SRC_DIR)/%.hh $(LD) $(LDFLAGS) -o $@ $^ # Dependencies +$(OBJ_DIR)/point3d.o: \ + $(OBJ_DIR)/posexcept.o $(OBJ_DIR)/posutil.o: \ $(OBJ_DIR)/posexcept.o $(OBJ_DIR)/owlps-positioning.o: \ diff --git a/owlps-positioning/src/point3d.cc b/owlps-positioning/src/point3d.cc index aff35bf..bde831b 100644 --- a/owlps-positioning/src/point3d.cc +++ b/owlps-positioning/src/point3d.cc @@ -1,8 +1,33 @@ #include "point3d.hh" +#include "posexcept.hh" #include #include +using namespace std ; + + + +/* *** Constructors *** */ + + +Point3D::Point3D(const string &source) +{ + float pos[3] ; + istringstream iss(source) ; + + for (int i = 0 ; i < 2 ; ++i) + { + iss >> pos[i] ; + if (iss.get() != ';') + throw malformed_input_data( + "Point3D(string): cannot extract coordinates!") ; + } + iss >> pos[2] ; + + set_coordinates(pos) ; +} + /* *** Distance operations *** */ @@ -84,16 +109,16 @@ bool Point3D::operator<(const Point3D &source) const } -Point3D::operator std::string(void) const +Point3D::operator string(void) const { - std::ostringstream oss ; + ostringstream oss ; oss << *this ; return oss.str() ; } -std::ostream& operator<<(std::ostream &os, const Point3D &p) +ostream& operator<<(ostream &os, const Point3D &p) { os << "(" << p.x << ";" << p.y << ";" << p.z << ")" ; return os ; diff --git a/owlps-positioning/src/point3d.hh b/owlps-positioning/src/point3d.hh index f3f5652..c1a4751 100644 --- a/owlps-positioning/src/point3d.hh +++ b/owlps-positioning/src/point3d.hh @@ -1,6 +1,7 @@ #ifndef _OWLPS_POSITIONING_POINT3D_HH_ #define _OWLPS_POSITIONING_POINT3D_HH_ +#include #include #include @@ -22,6 +23,8 @@ public: Point3D(const float source[3]): x(source[0]), y(source[1]), z(source[2]) {} + Point3D(const std::string &source) ; + virtual ~Point3D(void) {} /** @name Read accessors */ From eb61dfc0e0e3c9954691486ff2e8d96c34bd62c4 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 27 Apr 2011 18:57:00 +0200 Subject: [PATCH 14/26] [Positioning] Add minmax-start & minmax-stop opts. The start and stop coordinates for the MinMax multilateration method used to be hard-coded. One should now provide the good coordinates using the new options positioning.minmax-start and positioning.minmax-stop. --- owlps-positioning/Makefile | 4 +++- owlps-positioning/TODO | 1 - owlps-positioning/cfg/owlps-positioning.cfg | 8 ++++++++ owlps-positioning/cfg/topology.csv | 13 ++++++++---- .../src/multilaterationalgorithm.cc | 20 +++++++++++++++---- owlps-positioning/src/userinterface.cc | 6 ++++++ 6 files changed, 42 insertions(+), 10 deletions(-) diff --git a/owlps-positioning/Makefile b/owlps-positioning/Makefile index 09aaef1..669bca9 100644 --- a/owlps-positioning/Makefile +++ b/owlps-positioning/Makefile @@ -245,7 +245,9 @@ $(OBJ_DIR)/output.o: \ $(OBJ_DIR)/multilaterationalgorithm.o: \ $(SRC_DIR)/positioningalgorithm.hh \ $(OBJ_DIR)/minmax.o \ - $(OBJ_DIR)/mobile.o + $(OBJ_DIR)/mobile.o \ + $(OBJ_DIR)/configuration.o \ + $(OBJ_DIR)/posexcept.o $(OBJ_DIR)/cartographyalgorithm.o: \ $(SRC_DIR)/positioningalgorithm.hh \ $(OBJ_DIR)/referencepoint.o diff --git a/owlps-positioning/TODO b/owlps-positioning/TODO index edec94a..363af60 100644 --- a/owlps-positioning/TODO +++ b/owlps-positioning/TODO @@ -33,7 +33,6 @@ - MinMax ° Différencier le pas pour X, Y et Z ? - ° Régler le start & stop dans MultilaterationAlgorithm. - Renommages de membres ° InputMedium : diff --git a/owlps-positioning/cfg/owlps-positioning.cfg b/owlps-positioning/cfg/owlps-positioning.cfg index 3ee1204..5ad76b5 100644 --- a/owlps-positioning/cfg/owlps-positioning.cfg +++ b/owlps-positioning/cfg/owlps-positioning.cfg @@ -45,6 +45,14 @@ csv-file = /tmp/owlps-positioning.log #algorithm = RADAR #algorithm = FRBHMBasic +# Start and stop coordinates for the MinMax multilateration method. +# Since MinMax is currently the only multilateration method implemented +# in OwlPS, you should define these parameters if you use any of the +# multilateration-based algorithms (InterlinkNetworks, FBCM, FRBHM). +# They are declared as strings (X;Y;Z). Do not quote! +#minmax-start = -2;-2;0 +#minmax-stop = 20;30;6 + [output] # This is the default output if none is specified. diff --git a/owlps-positioning/cfg/topology.csv b/owlps-positioning/cfg/topology.csv index 6c5d32c..9eac23f 100644 --- a/owlps-positioning/cfg/topology.csv +++ b/owlps-positioning/cfg/topology.csv @@ -2,10 +2,15 @@ # # IMPORTANT: # You need a precise topology description if you use algorithms that -# handle it. Since none of them are currenty implemented, you probably -# can save a lot of time by only providing a pseudo-area containing -# the whole deployment area in this file (in this case you will not -# declare any waypoint in the waypoints' definition file). +# handle it. Since none of them are currently implemented, you +# probably can save a lot of time by skipping the topology (and +# waypoints) description. +# +# ALSO IMPORTANT (EVEN IF YOU DON'T DESCRIBE THE TOPOLOGY): +# If you use the MinMax multilateration method, you should provide +# minmax-start and minmax-stop parameters that match the deployment +# area. That is, the cuboid formed by these two points should include +# the whole deployment area. # # This file lists the buildings and their "homogeneous areas" (rooms). # diff --git a/owlps-positioning/src/multilaterationalgorithm.cc b/owlps-positioning/src/multilaterationalgorithm.cc index 3dae101..85d5fba 100644 --- a/owlps-positioning/src/multilaterationalgorithm.cc +++ b/owlps-positioning/src/multilaterationalgorithm.cc @@ -1,6 +1,8 @@ #include "multilaterationalgorithm.hh" #include "minmax.hh" #include "mobile.hh" +#include "configuration.hh" +#include "posexcept.hh" using namespace std ; using std::tr1::unordered_map ; @@ -14,10 +16,20 @@ MultilaterationAlgorithm::MultilaterationAlgorithm(): request(NULL) { // Will be changed when other multilateration methods will be - // implemented - multilateration_method = new MinMax(Point3D(-0.5, -0.5, 0), - Point3D(10, 31.5, 6)) ; - // FIXME: minmax start and stop + // implemented. + + if (! Configuration::is_configured("positioning.minmax-start") || + ! Configuration::is_configured("positioning.minmax-stop")) + throw missing_configuration( + "You want to use MinMax, but either positioning.minmax-start or" + " positioning.minmax-stop is not defined!") ; + + Point3D minmax_start( + Configuration::string_value("positioning.minmax-start")) ; + Point3D minmax_stop( + Configuration::string_value("positioning.minmax-stop")) ; + + multilateration_method = new MinMax(minmax_start, minmax_stop) ; } diff --git a/owlps-positioning/src/userinterface.cc b/owlps-positioning/src/userinterface.cc index 5ac3f73..ed1c7e5 100644 --- a/owlps-positioning/src/userinterface.cc +++ b/owlps-positioning/src/userinterface.cc @@ -172,6 +172,12 @@ void UserInterface::fill_positioning_options() "Algorithms used to compute positions. You can specify \ this option more than once (but at least once). Allowed: Real, FBCM, \ FRBHMBasic, InterlinkNetworks, RADAR.") + ("positioning.minmax-start", po::value(), + "Coordinates of the start point of the MinMax multilateration \ +method (string format: \"X;Y;Z\").") + ("positioning.minmax-stop", po::value(), + "Coordinates of the stop point of the MinMax multilateration \ +method (string format: \"X;Y;Z\").") ; file_options->add(options) ; From be784c8ec04a5712113fb8a86f95b61427d4ddd5 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 3 May 2011 13:38:50 +0200 Subject: [PATCH 15/26] [Listener] Check SS field before to print it --- owlps-listener/owlps-listenerd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/owlps-listener/owlps-listenerd.c b/owlps-listener/owlps-listenerd.c index e26898a..63dc322 100644 --- a/owlps-listener/owlps-listenerd.c +++ b/owlps-listener/owlps-listenerd.c @@ -1065,7 +1065,8 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, owl_mac_bytes_to_string(request.mobile_mac_addr_bytes), request_time_str, start_time_str, - request.antenna_signal_dbm - 0x100, + check[RTAP_ANTENNASIGNALDBM] ? + request.antenna_signal_dbm - 0x100 : 0, owl_ntohf(request.x_position), owl_ntohf(request.y_position), owl_ntohf(request.z_position), From cc66eb7c5902f5ce4fb3ed1b3df51fb58e278aaf Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 3 May 2011 13:44:08 +0200 Subject: [PATCH 16/26] [Listener] read_packet(): blank the whole request Blank the whole request with memset() instead of setting to zero each field. --- owlps-listener/owlps-listenerd.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/owlps-listener/owlps-listenerd.c b/owlps-listener/owlps-listenerd.c index 63dc322..dd9f4e4 100644 --- a/owlps-listener/owlps-listenerd.c +++ b/owlps-listener/owlps-listenerd.c @@ -741,7 +741,8 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, owl_bool uses_autocalibration_request_port = FALSE ; int i ; // Iterator - memset(request.mobile_ip_addr_bytes, 0, 4) ; // Blank the IP + // Blank the request: + memset(&request, 0, sizeof(request)) ; /* Common treatements */ @@ -837,14 +838,6 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, memcpy(request.ap_mac_addr_bytes, my_mac_bytes, ETHER_ADDR_LEN) ; // Capture time is in the pcap header (net-endian): request.start_time = owl_timeval_to_timestamp(header->ts) ; - // Transmission time on the mobile is unknown (unless the packet is - // an explicit request): - memset(&request.request_time, 0, sizeof(owl_timestamp)) ; - // Blank position data: - request.direction = 0 ; - request.x_position = 0 ; - request.y_position = 0 ; - request.z_position = 0 ; /* Active mode */ if (is_explicit_packet From b1d706bf9c0828f81f9a4e4db4f06aa233b34373 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 3 May 2011 13:53:33 +0200 Subject: [PATCH 17/26] Update TODOs --- TODO | 5 ++++- owlps-positioning/TODO | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index 970004d..a20adb3 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,9 @@ * Global -- Use -D DEBUG in makefiles instead of #defines. +- Makefiles: + ° Use -D DEBUG instead of #defines. + ° Use echo instead of echo -e. + ° Translate comments & help. - Use string for network exchanges? - Mark arguments as const in function headers if needed That is done in the owlps-positioning C++ code, but not constantly diff --git a/owlps-positioning/TODO b/owlps-positioning/TODO index 363af60..f61eaa2 100644 --- a/owlps-positioning/TODO +++ b/owlps-positioning/TODO @@ -1,20 +1,24 @@ +- Multithread algorithm calls. + - Write a class for Request::type? CalibrationRequest::direction uses a dedicated class Direction, why not Request::type? That would simplify writing of the type to streams (no need to cast each time anymore). -- Interface utilisateur - ° Pour plus de souplesse, comparer les chaînes sans tenir compte de - la casse. +- User interface + ° Case-insensitive string comparison (for algorithm names, etc.). + ° Use a prefix for configuration files (search for config files set + with relative path in owlps-positioning.cfg in the same directory). -- Tests unitaires +- Unit tests ° Update tests (currently unmaintained). - ° Finir le test de InputDataReader. - ° Finir le test de Input. - ° Finir le test de Output. - ° Finir le test de Positioning. - ° Tester InterlinkNetworks::compute() ? + ° Unfinished tests: + . InputDataReader + . Input + . Output + . Positioning + ° Test InterlinkNetworks::compute() ? - Revoir le diagramme UML ° Associations : devraient êtres représentées par des attributs From e067efb42a695993143d683f4252e5b417f6bba1 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 4 May 2011 11:31:13 +0200 Subject: [PATCH 18/26] [Positioning] Doxyfile: use $OWLPS_VERSION --- owlps-positioning/Doxyfile | 2 +- owlps-positioning/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/owlps-positioning/Doxyfile b/owlps-positioning/Doxyfile index 107a93d..1ccfe40 100644 --- a/owlps-positioning/Doxyfile +++ b/owlps-positioning/Doxyfile @@ -31,7 +31,7 @@ PROJECT_NAME = "OWLPS Positioning" # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 0.9.1 +PROJECT_NUMBER = $(OWLPS_VERSION) # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff --git a/owlps-positioning/Makefile b/owlps-positioning/Makefile index 669bca9..ba8433b 100644 --- a/owlps-positioning/Makefile +++ b/owlps-positioning/Makefile @@ -24,7 +24,7 @@ MKDIR = mkdir -pv # Other tools STYLE = astyle --style=gnu --formatted CPPCHECK = cppcheck --quiet --enable=all -DOXYGEN = doxygen >/dev/null +DOXYGEN = OWLPS_VERSION=$(OWLPS_VERSION) doxygen >/dev/null # Compilation tools COLORGCC := $(shell which colorgcc >/dev/null 2>&1 ; echo $$?) From bd992f28ed09598fe2443a0284b3026ed09c0142 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 4 May 2011 19:20:46 +0200 Subject: [PATCH 19/26] [Positioning] "Null" is a false friend --- owlps-positioning/src/accesspoint.hh | 2 +- owlps-positioning/src/area.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/owlps-positioning/src/accesspoint.hh b/owlps-positioning/src/accesspoint.hh index d5fc517..5919766 100644 --- a/owlps-positioning/src/accesspoint.hh +++ b/owlps-positioning/src/accesspoint.hh @@ -127,7 +127,7 @@ inline void AccessPoint::set_channel(const unsigned int channel) * control is done, so you should pass a correct value. * * Note that set_channel() is more secure because a wrong channel - * number will cause #frequency to be nullified. + * number will cause #frequency to be set to zero. */ inline void AccessPoint::set_frequency(const unsigned long _frequency) { diff --git a/owlps-positioning/src/area.cc b/owlps-positioning/src/area.cc index e176b85..ce02aa7 100644 --- a/owlps-positioning/src/area.cc +++ b/owlps-positioning/src/area.cc @@ -83,7 +83,7 @@ void Area::reorder_coordinates() } // First point is South-West - // (or other cases such as null coordinates) + // (or other cases such as coordinates equal to zero) else { // We swap nothing From 2d2b49947a101f1b3eb968b756c987dfcc0ccf61 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 3 May 2011 15:02:56 +0200 Subject: [PATCH 20/26] [Positioning] Add PositioningAlgorithm::get_name() --- owlps-positioning/src/positioningalgorithm.hh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/owlps-positioning/src/positioningalgorithm.hh b/owlps-positioning/src/positioningalgorithm.hh index daf8387..748cf54 100644 --- a/owlps-positioning/src/positioningalgorithm.hh +++ b/owlps-positioning/src/positioningalgorithm.hh @@ -16,7 +16,18 @@ public: name(_name) {} virtual ~PositioningAlgorithm(void) {} + const std::string& get_name(void) const ; + virtual Result compute(const Request &request) = 0 ; } ; + + +inline const std::string& PositioningAlgorithm::get_name() const +{ + return name ; +} + + + #endif // _OWLPS_POSITIONING_POSITIONINGALGORITHM_HH_ From 6c3647410df616f66096ccce6949ef3b1edc2f24 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 3 May 2011 15:16:03 +0200 Subject: [PATCH 21/26] [Positioning] Result: compute error if possible If the real coordinates are passed to the constructor, the distance error is computed. One can also use Result::compute_error() on a constructed object. --- owlps-positioning/src/result.cc | 28 +++++++++++++++++++++++++++- owlps-positioning/src/result.hh | 23 +++++++++++++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/owlps-positioning/src/result.cc b/owlps-positioning/src/result.cc index 1173b0c..7645b3e 100644 --- a/owlps-positioning/src/result.cc +++ b/owlps-positioning/src/result.cc @@ -7,6 +7,28 @@ using namespace std ; +/* *** Constructors *** */ + + +Result::Result(const Point3D &_position, const std::string &_algorithm, + const Point3D &real_position): + position(_position), algorithm(_algorithm) +{ + compute_error(real_position) ; +} + + + +/* *** Write accessors *** */ + + +void Result::compute_error(const Point3D &real_position) +{ + error = position.distance(real_position) ; +} + + + /* *** Operators *** */ @@ -42,7 +64,9 @@ const string Result::to_csv() const << algorithm << ';' << position.get_x() << ';' << position.get_y() - << ';' << position.get_z() ; + << ';' << position.get_z() + << ';' << "Error" + << ';' << error ; return csv_line.str() ; } @@ -54,5 +78,7 @@ std::ostream& operator<<(ostream &os, const Result &r) os << "The result of the algorithm " << r.algorithm << " is: " << r.position ; + if (r.error >= 0) + os << ", error = " << r.error << " m" ; return os ; } diff --git a/owlps-positioning/src/result.hh b/owlps-positioning/src/result.hh index ac7f223..5861633 100644 --- a/owlps-positioning/src/result.hh +++ b/owlps-positioning/src/result.hh @@ -9,20 +9,33 @@ class Result { protected: + /// Computed coordinates of the mobile Point3D position ; + /// Algorithm used to compute the position std::string algorithm ; + /// Distance error between the real coordinates and the computed point + /** The error is set to -1 if the real coordinates are unknown. */ + float error ; public: Result(const std::string &_algorithm = "UnknownAlgorithm"): - algorithm(_algorithm) {} + algorithm(_algorithm), error(-1) {} Result(const Point3D &_position, const std::string &_algorithm): - position(_position), algorithm(_algorithm) {} + position(_position), algorithm(_algorithm), error(-1) {} + Result(const Point3D &_position, const std::string &_algorithm, + const Point3D &real_position) ; ~Result(void) {} /** @name Read accessors */ //@{ const std::string& get_algorithm(void) const ; const Point3D& get_position(void) const ; + float get_error(void) const ; + //@} + + /** @name Write accessors */ + //@{ + void compute_error(const Point3D &real_position) ; //@} /** @name Operators */ @@ -59,6 +72,12 @@ inline const Point3D& Result::get_position() const } +inline float Result::get_error() const +{ + return error ; +} + + /* *** Operators *** */ From 1bb589b4608be83061d3893a28b746c8f79c3c00 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 4 May 2011 18:16:10 +0200 Subject: [PATCH 22/26] [Positioning] Add Point3D::operator bool() --- owlps-positioning/src/point3d.cc | 13 +++++++++++++ owlps-positioning/src/point3d.hh | 1 + 2 files changed, 14 insertions(+) diff --git a/owlps-positioning/src/point3d.cc b/owlps-positioning/src/point3d.cc index bde831b..e496f00 100644 --- a/owlps-positioning/src/point3d.cc +++ b/owlps-positioning/src/point3d.cc @@ -117,6 +117,19 @@ Point3D::operator string(void) const } +/** + * @return \em true if either #x, #y or #z is non-zero. + * @return \em false if #x, #y and #z are defined to 0. + */ +Point3D::operator bool(void) const +{ + return + x != 0 && + y != 0 && + z != 0 ; +} + + ostream& operator<<(ostream &os, const Point3D &p) { diff --git a/owlps-positioning/src/point3d.hh b/owlps-positioning/src/point3d.hh index c1a4751..c820afd 100644 --- a/owlps-positioning/src/point3d.hh +++ b/owlps-positioning/src/point3d.hh @@ -72,6 +72,7 @@ public: bool operator>(const Point3D &source) const ; bool operator<=(const Point3D &source) const ; bool operator>=(const Point3D &source) const ; + operator bool(void) const ; operator std::string(void) const ; //@} From 00bbc9c49d00e3df8b4a3e13d2d0c5e89e70a6b1 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 4 May 2011 19:02:20 +0200 Subject: [PATCH 23/26] [Positioning] Add Request::real_position --- owlps-positioning/src/request.cc | 44 +++++++++++++++++++++++++++----- owlps-positioning/src/request.hh | 21 ++++++++++++--- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/owlps-positioning/src/request.cc b/owlps-positioning/src/request.cc index 4ef2dc4..ef3afdc 100644 --- a/owlps-positioning/src/request.cc +++ b/owlps-positioning/src/request.cc @@ -22,6 +22,25 @@ Request::~Request() /* *** Write accessors *** */ +inline void Request::clear_real_position() +{ + if (real_position) + { + delete real_position ; + real_position = NULL ; + } +} + + +void Request::set_real_position(const Point3D &_real_position) +{ + if (real_position) + *real_position = _real_position ; + else + real_position = new Point3D(_real_position) ; +} + + /// Reinitialises all attributes /** * - #mobile is NULLified, but the value it pointed to is not deleted. @@ -34,6 +53,7 @@ void Request::clear() mobile = NULL ; time_sent.clear() ; measurements.clear() ; + clear_real_position() ; } @@ -51,6 +71,10 @@ const Request& Request::operator=(const Request &source) time_sent = source.time_sent ; measurements = source.measurements ; + clear_real_position() ; + if (source.real_position) + real_position = new Point3D(*source.real_position) ; + return *this ; } @@ -60,7 +84,13 @@ bool Request::operator==(const Request &source) const if (this == &source) return true ; + bool real_position_equal = + real_position && + source.real_position && + *real_position == *source.real_position ; + return + real_position_equal && type == source.type && mobile == source.mobile && time_sent == source.time_sent && @@ -72,8 +102,10 @@ bool Request::operator==(const Request &source) const ostream& operator<<(ostream &os, const Request &r) { // Timestamp - os - << "At " << r.time_sent << "; " ; + os << "At " << r.time_sent << "; " ; + + if (r.real_position) + os << " Real coordinates : " << *r.real_position << "; " ; // MAC address os @@ -88,9 +120,7 @@ ostream& operator<<(ostream &os, const Request &r) else for (unordered_map::const_iterator i = r.measurements.begin() ; i != r.measurements.end() ; ++i) - { - os << '\n' << i->first << ": " << i->second ; - } + os << '\n' << i->first << ": " << i->second ; return os ; } @@ -107,8 +137,10 @@ size_t hash_value(const Request &source) boost::hash_combine(seed, source.type) ; boost::hash_combine(seed, source.time_sent) ; - if (source.mobile != NULL) + if (source.mobile) boost::hash_combine(seed, source.mobile->get_mac_addr()) ; + if (source.real_position) + boost::hash_combine(seed, source.real_position) ; return seed ; } diff --git a/owlps-positioning/src/request.hh b/owlps-positioning/src/request.hh index 282af2f..f057162 100644 --- a/owlps-positioning/src/request.hh +++ b/owlps-positioning/src/request.hh @@ -26,6 +26,11 @@ protected: /** Note that this is not a pointer list, values are actually stored. The \em string parameter is the MAC address of the AP. */ std::tr1::unordered_map measurements ; + /// \brief Real coordinates of the request (normally unavailable for a + /// standard positioning request) + Point3D *real_position ; + + void clear_real_position(void) ; public: Request(const Mobile *_mobile = NULL, @@ -35,12 +40,12 @@ public: std::tr1::unordered_map()): type(OWL_REQUEST_UNDEFINED), mobile(const_cast(_mobile)), time_sent(_time_sent), - measurements(_measurements) {} + measurements(_measurements), real_position(NULL) {} Request(const std::tr1::unordered_map &_measurements): type(OWL_REQUEST_UNDEFINED), - mobile(NULL), measurements(_measurements) {} + mobile(NULL), measurements(_measurements), real_position(NULL) {} Request(const Timestamp &_time_sent, const std::tr1::unordered_map @@ -48,12 +53,12 @@ public: std::tr1::unordered_map()): type(OWL_REQUEST_UNDEFINED), mobile(NULL), time_sent(_time_sent), - measurements(_measurements) {} + measurements(_measurements), real_position(NULL) {} Request(const Request &source): type(source.type), mobile(source.mobile), time_sent(source.time_sent), - measurements(source.measurements) {} + measurements(source.measurements), real_position(NULL) {} virtual ~Request(void) ; @@ -64,6 +69,7 @@ public: const Timestamp& get_time_sent(void) const ; const std::tr1::unordered_map& get_measurements(void) const ; + const Point3D* get_real_position(void) const ; //@} /** @name Write accessors */ @@ -73,6 +79,7 @@ public: void set_time_sent(const Timestamp &_time_sent) ; void set_measurements(const std::tr1::unordered_map &_measurements) ; + void set_real_position(const Point3D &_real_position) ; void clear(void) ; //@} @@ -122,6 +129,12 @@ Request::get_measurements(void) const } +inline const Point3D* Request::get_real_position(void) const +{ + return real_position ; +} + + /* *** Write accessors *** */ From 17e12a9735d761e0819785c711dd9563f4cb6020 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 4 May 2011 19:56:38 +0200 Subject: [PATCH 24/26] [Positioning] Input*: initialise real_position When provided for non-calibration requests, the real position is initialised. --- owlps-positioning/src/inputcsv.cc | 5 +++++ owlps-positioning/src/inputudpsocket.cc | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/owlps-positioning/src/inputcsv.cc b/owlps-positioning/src/inputcsv.cc index 8dc0dd4..db5ebe6 100644 --- a/owlps-positioning/src/inputcsv.cc +++ b/owlps-positioning/src/inputcsv.cc @@ -139,5 +139,10 @@ const Request& InputCSV::get_next_request() direction, type) ; } + // We set the real coordinates (if found) only for non-calibration + // requests + else if (pos) + current_request->set_real_position(pos) ; + return *current_request ; } diff --git a/owlps-positioning/src/inputudpsocket.cc b/owlps-positioning/src/inputudpsocket.cc index 7f4080a..2776542 100644 --- a/owlps-positioning/src/inputudpsocket.cc +++ b/owlps-positioning/src/inputudpsocket.cc @@ -154,5 +154,16 @@ const Request& InputUDPSocket::get_next_request() request.type) ; } + // We set the real coordinates (if found) only for non-calibration + // requests + else + { + Point3D pos(owl_ntohf(request.x_position), + owl_ntohf(request.y_position), + owl_ntohf(request.z_position)) ; + if (pos) + current_request->set_real_position(pos) ; + } + return *current_request ; } From 0eef6e8577885fff93788ceed4952acbceca2710 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 4 May 2011 19:58:02 +0200 Subject: [PATCH 25/26] [Positioning] RealPosition: handle non-calib. requests RealPosition is now able to return a relevant result when called with non-calibration requests. --- owlps-positioning/src/realposition.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/owlps-positioning/src/realposition.cc b/owlps-positioning/src/realposition.cc index 98d7281..2de435f 100644 --- a/owlps-positioning/src/realposition.cc +++ b/owlps-positioning/src/realposition.cc @@ -6,16 +6,18 @@ Result RealPosition::compute(const Request &request) { + const Point3D *coordinates = NULL ; + const CalibrationRequest *calibration_request = dynamic_cast(&request) ; if (calibration_request != NULL) - { - Point3D *coordinates = - static_cast( - calibration_request->get_reference_point()) ; - return Result(*coordinates, name) ; - } + coordinates = static_cast( + calibration_request->get_reference_point()) ; + + coordinates = request.get_real_position() ; + if (coordinates) + return Result(*coordinates, name) ; return Result(name) ; } From 506917b5ec33fffc8605abf038ccf86047cfcff2 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 3 May 2011 15:33:12 +0200 Subject: [PATCH 26/26] [Positioning] Compute the error if Real is used If the pseudo-algorithm Real is used, the distance error is computed for the others algorithms. --- owlps-positioning/src/positioning.cc | 21 +++++++++++++++++++-- owlps-positioning/src/realposition.hh | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/owlps-positioning/src/positioning.cc b/owlps-positioning/src/positioning.cc index 52844a2..38480e0 100644 --- a/owlps-positioning/src/positioning.cc +++ b/owlps-positioning/src/positioning.cc @@ -51,7 +51,11 @@ void Positioning::initialise_algorithms() i != algo_names.end() ; ++i) { if (*i == "Real") - algorithms.push_back(new RealPosition) ; + /* In order to compute the errors of the other algorithms, + * Real must be the first for each request, so we add it at + * the begining. + */ + algorithms.insert(algorithms.begin(), new RealPosition) ; else if (*i == "FBCM") { @@ -87,10 +91,23 @@ void Positioning::loop() if (! request) continue ; + Point3D real_position ; + bool compute_error = false ; ResultList results(&request) ; for (algo = algorithms.begin() ; algo != algorithms.end() ; ++algo) - results.add((*algo)->compute(request)) ; + { + Result res((*algo)->compute(request)) ; + if (compute_error) + res.compute_error(real_position) ; + else if ((*algo)->get_name() == "Real") + { + compute_error = true ; + real_position = res.get_position() ; + } + results.add(res) ; + } + output.write(results) ; } } diff --git a/owlps-positioning/src/realposition.hh b/owlps-positioning/src/realposition.hh index 783d440..97dc42b 100644 --- a/owlps-positioning/src/realposition.hh +++ b/owlps-positioning/src/realposition.hh @@ -11,7 +11,7 @@ class RealPosition: public PositioningAlgorithm { public: - RealPosition(void): PositioningAlgorithm("RealPosition") {} + RealPosition(void): PositioningAlgorithm("Real") {} Result compute(const Request &request) ; } ;