From 6c1b0367bf061c315266fc3df70f5ed57c0fba85 Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sun, 9 Aug 2020 15:00:20 +0200 Subject: [PATCH] =?UTF-8?q?Voil=C3=A0,=20mon=20tri=20du=20gagnant=20marche?= =?UTF-8?q?=20bien=20et=20maintenant=20j'arrive=20presque=20=C3=A0=20avoir?= =?UTF-8?q?=20un=20bon=20r=C3=A9sultat=20pour=20les=20tr=C3=A8s=20petites?= =?UTF-8?q?=20paternes=20gr=C3=A2ce=20au=20calcul=20de=20la=20d=C3=A9viati?= =?UTF-8?q?on=20de=20rssi=20entre=20le=20pet=20tracker=20et=20la=20calibra?= =?UTF-8?q?tion.=20Faudra=20juste=20tester=20s'il=20y=20a=20des=20doublons?= =?UTF-8?q?=20pour=20tout=20simplement=20ne=20pas=20en=20tenir=20compte=20?= =?UTF-8?q?lors=20de=20l'affichage=20dans=20de=20rares=20cas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../post_tracing/gpx2gpsapwifi.lua | 53 ++++++++++++------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/DeepSleep/Pet_tracker_3/post_tracing/gpx2gpsapwifi.lua b/DeepSleep/Pet_tracker_3/post_tracing/gpx2gpsapwifi.lua index aa15c81..8d12b4b 100644 --- a/DeepSleep/Pet_tracker_3/post_tracing/gpx2gpsapwifi.lua +++ b/DeepSleep/Pet_tracker_3/post_tracing/gpx2gpsapwifi.lua @@ -1,7 +1,7 @@ -- parse les données GPX avec les données des ap wifi du NodeMCU pour les -- cooréler en fonction du temps afin de pouvoir géolocaliser les ap wifi -print("\n gpx2gpsapwifi.lua zfzf200808.1512 \n") +print("\n gpx2gpsapwifi.lua zfzf200809.1500 \n") zgpx_tab = {} zidx_gpx_tab = 0 @@ -357,15 +357,17 @@ function zget_gps_ap_wifi(zidx_pet_tracker_tab1) -- print("mac2: "..zmacadresse2) -- print("J'en ai trouvée une...") zvote_tab[zidx_ap_wifi_tab1].idx = zidx_ap_wifi_tab1 - zvote_tab[zidx_ap_wifi_tab1].vote = zvote_tab[zidx_ap_wifi_tab1].vote + 1 - -- zerror_inv = ztrig_error - zap_wifi_tab[zidx_ap_wifi_tab1][zidx_ap_wifi_tab2].error - -- if zerror_inv > 0 then - -- zvote_tab[zidx_ap_wifi_tab1].sum_error = zvote_tab[zidx_ap_wifi_tab1].sum_error + zerror_inv - -- end - if zap_wifi_tab[zidx_ap_wifi_tab1][zidx_ap_wifi_tab2].error < ztrig_error then - zvote_tab[zidx_ap_wifi_tab1].sum_error = zvote_tab[zidx_ap_wifi_tab1].sum_error + zap_wifi_tab[zidx_ap_wifi_tab1][zidx_ap_wifi_tab2].error + zvote_tab[zidx_ap_wifi_tab1].vote = zvote_tab[zidx_ap_wifi_tab1].vote + 1 + zerror1 = zpet_tracker_tab[zidx_pet_tracker_tab1][zidx_pet_tracker_tab2].error + zerror2 = zap_wifi_tab[zidx_ap_wifi_tab1][zidx_ap_wifi_tab2].error + if zerror1 < zerror2 then + zdeviation = zerror1 / zerror2 + else + zdeviation = zerror2 / zerror1 end + zvote_tab[zidx_ap_wifi_tab1].sum_deviation = zvote_tab[zidx_ap_wifi_tab1].sum_deviation + zdeviation -- print("vote: "..zvote_tab[zidx_ap_wifi_tab2].vote) + -- print("deviation: "..zdeviation) end end i = i + 1 @@ -373,8 +375,6 @@ function zget_gps_ap_wifi(zidx_pet_tracker_tab1) if i > 50000 then break end end end - - end -- efface le tableau de votes des paternes @@ -382,7 +382,9 @@ for zidx_vote_tab = 1, #zap_wifi_tab do zvote_tab[zidx_vote_tab] = { idx = 0, vote = 0, - sum_error = 0} + sum_deviation = 0, + deviation = 0, + key_sort = ""} end zidx_vote_tab = 0 @@ -393,16 +395,27 @@ function zprint_vote_tab() if zvote_tab[zidx_vote_tab].idx > 0 then print("pour "..zvote_tab[zidx_vote_tab].idx.. " nombre de votes "..zvote_tab[zidx_vote_tab].vote.. - "/"..math.floor(zvote_tab[zidx_vote_tab].sum_error)) + ", déviation : "..zvote_tab[zidx_vote_tab].deviation) end end end --- A partir de ce seuil en mètre on tient compte du paramètre error de chaque ap wifi vu -ztrig_error = 9000 -zget_gps_ap_wifi(200) -zprint_vote_tab() +-- calcul les déviations +function zcalc_deviations() + for zidx_vote_tab = 1, #zvote_tab do + if zvote_tab[zidx_vote_tab].vote > 0 then + zvote_tab[zidx_vote_tab].deviation = zround(zvote_tab[zidx_vote_tab].sum_deviation / zvote_tab[zidx_vote_tab].vote, 2) + end + zvote_tab[zidx_vote_tab].key_sort = string.format("%02d",zvote_tab[zidx_vote_tab].vote)..","..string.format("%.2f",zvote_tab[zidx_vote_tab].deviation) + -- print("key sort: "..zvote_tab[zidx_vote_tab].key_sort) + end +end + + +zget_gps_ap_wifi(70) +zcalc_deviations() +-- zprint_vote_tab() print("il y a "..#zpet_tracker_tab.." paternes !") @@ -413,8 +426,12 @@ print("il y a "..#zpet_tracker_tab.." paternes !") -- table.sort(myTable, function(lhs, rhs) return lhs[2] < rhs[2] end) -- for _, v in ipairs(myTable) do print(v[1], v[2]) end -table.sort(zvote_tab, function(lhs, rhs) return lhs.vote > rhs.vote end) + + + +table.sort(zvote_tab, function(lhs, rhs) return lhs.key_sort > rhs.key_sort end) +-- table.sort(zvote_tab, function(lhs, rhs) return lhs.vote > rhs.vote end) print("#####################################################") zprint_vote_tab() - +print("et la gagnante est "..zvote_tab[1].idx)