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-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-ardrone/owlps-drone.c b/owlps-ardrone/owlps-drone.c index 355da1c..8fdea39 100644 --- a/owlps-ardrone/owlps-drone.c +++ b/owlps-ardrone/owlps-drone.c @@ -711,7 +711,7 @@ void string2data(char* string_data) int count_algo= 0 ; int count_print = 0 ; int onetime = 0 ; - + int error = 0 ; while(onetime<1) { @@ -761,6 +761,8 @@ void string2data(char* string_data) ptr = strtok(NULL, delims) ; if(ptr==NULL) break ; sscanf(ptr, "%s", results[count_algo].algo) ; + if(!strcmp(results[count_algo].algo,"Real")) + error=1; //Lecture du point X ptr = strtok(NULL, delims) ; @@ -815,10 +817,50 @@ void string2data(char* string_data) } } results[count_algo].z = atof(ptr) ; + if(error==1) + { + //Lecture du message Error + ptr = strtok(NULL, delims) ; + if(ptr==NULL) + { + if(count_algo==0) + { + print_error ("trame"); + break ; + } + else + { + print_error ("algo"); + count_algo--; + break ; + } + } + results[count_algo].check = ptr ; + + //Lecture valeur Error + ptr = strtok(NULL, delims) ; + if(ptr==NULL) + { + if(count_algo==0) + { + print_error ("trame"); + break ; + } + else + { + perror ("algo"); + count_algo--; + break ; + } + } + results[count_algo].err = atof(ptr) ; - count_algo++; + count_algo++; + } + else + count_algo++; } for(count_print=0;count_print/dev/null || echo 'UNKNOWN_VERSION') endif # Répertoire d'installation @@ -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 ## 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-listener/owlps-listenerd.c b/owlps-listener/owlps-listenerd.c index e26898a..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 @@ -1065,7 +1058,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), 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 5545c48..ba8433b 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 @@ -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 $$?) @@ -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: \ @@ -243,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..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 @@ -33,7 +37,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/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..5ad76b5 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,24 @@ 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 +# 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. #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..9eac23f --- /dev/null +++ b/owlps-positioning/cfg/topology.csv @@ -0,0 +1,36 @@ +# 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 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). +# +# 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 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. -- 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/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!") ; 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 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) {} diff --git a/owlps-positioning/src/inputcsv.cc b/owlps-positioning/src/inputcsv.cc index fc4a6ff..db5ebe6 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,18 +41,28 @@ 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) ; // 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() ; +#ifdef DEBUG + cerr << "InputCSV: cannot read type.\n" ; +#endif // DEBUG return *current_request ; } + type = type_r ; current_request->set_type(type) ; // Read Timestamp field @@ -59,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) ; @@ -69,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 ; } @@ -79,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) @@ -95,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) ; @@ -108,15 +132,17 @@ 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) ; } + // 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/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/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..2776542 100644 --- a/owlps-positioning/src/inputudpsocket.cc +++ b/owlps-positioning/src/inputudpsocket.cc @@ -144,18 +144,25 @@ 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) ; + } + + // 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 ; 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/point3d.cc b/owlps-positioning/src/point3d.cc index aff35bf..e496f00 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,29 @@ 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() ; } +/** + * @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 ; +} -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..c820afd 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 */ @@ -69,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 ; //@} 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/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_ 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) ; } 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) ; } ; 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 59fb421..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 *** */ @@ -164,7 +177,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 { 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 *** */ 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 ; } diff --git a/owlps-positioning/src/userinterface.cc b/owlps-positioning/src/userinterface.cc index 4e96d09..ed1c7e5 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" @@ -171,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) ;