Wi-Fi RTTによる屋内測位アプリを作ろう

Wi-Fi RTTによる屋内測位アプリを作ろう

0c5e92294cc0cfba620641c589db9378?s=128

napplecomputer

February 08, 2019
Tweet

Transcript

  1. 8J'J355ʹΑΔ԰಺ଌҐΞϓϦ Λ࡞Ζ͏ !OBQQMFDPNQVUFS 1

  2. ࣗݾ঺հ • ͳͬͽʔ • !OBQQMFDPNQVUFS • גࣜձࣾσΟʔɾΤψɾΤʔॴଐ • .07ͷϢʔβʔΞϓϦ։ൃ 2

  3. ໨࣍ 3 ͖͔͚ͬ 8J'J355ͷ࢓༷ ࡞ͬͯΈͨ   ਫ਼౓Λ্͛ΔͨΊͷΞΠσΟΞ  

  4. ͖͔͚ͬ 4

  5. 5 )PXUPHFUPOFNFUFSMPDBUJPOBDDVSBDZ GSPN"OESPJEEFWJDFT (PPHMF*0`  IUUQTZPVUVCFWZX(H4S(0%6

  6. 8J'J355ͷ࢓༷ 6

  7. "OESPJEͷҐஔ৘ใऔಘํ๏ 7

  8. 'VTFE-PDBUJPO 8

  9. 'VTFE-PDBUJPOͳ͠ 9 ΞϓϦ ηϯαʔ" ΞϓϦ ηϯαʔ$ ηϯαʔ#

  10. 'VTFE-PDBUJPO͋Γ 10 ΞϓϦ ηϯαʔ" ΞϓϦ ηϯαʔ$ ηϯαʔ# (PPHMF1MBZ 4FSWJDFT

  11. 'VTFE-PDBUJPO 11 (14 8J'J 344* ΩϟϦΞج஍ہ ਫ਼౓ ϝʔτϧ ϝʔτϧ ϝʔτϧʁ

    ԰಺ ! " " ҐஔଌҐ༻ " ! ʁ
  12. 'VTFE-PDBUJPO 12 (14 8J'J 344* ΩϟϦΞج஍ہ 8J'J 355 ਫ਼౓ ϝʔτϧ

    ϝʔτϧ ϝʔτϧʁ ϝʔτϧ ԰಺ ! " " " ҐஔଌҐ༻ " ! ʁ "
  13. 'VTFE-PDBUJPO 13 (14 8J'J 344* ΩϟϦΞج஍ہ 8J'J 355 ਫ਼౓ ϝʔτϧ

    ϝʔτϧ ϝʔτϧʁ ϝʔτϧ ԰಺ ! " " " ҐஔଌҐ༻ " ! ʁ " /&8
  14. 8J'J355ͷ࢓༷ 14

  15. 8J'J355 • 355͸3PVOE5SJQ5JNFͷུ • *&&&NDͰఆٛ • *&&&NDʹରԠ͍ͯ͠ΔΞΫηεϙΠϯτͱɺ *&&&NDʹରԠ͍ͯ͠Δ୺຤͕ඞཁ • ௨৴͔࣌ؒΒڑ཭Λܭଌ͢Δ

    15
  16. ڑ཭ܭଌ 16 ΞΫηεϙΠϯτ ୺຤ ڑ཭τʔλϧ࣌ؒʷޫͷ଎͞ D ̎

  17. ڑ཭ܭଌ΋ͬͱৄ͘͠ 17 ΞΫηεϙΠϯτ ୺຤ '5.3FRVFTU '5. U U "$, U

    U U U ڑ཭ UU  UU ʷޫͷ଎͞ D  ࣌ؒ
  18. ୺຤ͷҐஔΛܭࢉ͢Δ 18

  19. ୺຤ͷҐஔΛࢉग़͢Δ • 355ͰऔΕΔͷ͸ΞΫηεϙΠϯτ·Ͱͷڑ཭͚ͩ • ୺຤ͷҐஔ৘ใͷࢉग़͸355ͷൣғ֎ • ࣗ෼Ͱܭࢉ͢Δ • ΞΫηεϙΠϯτͷҐஔ৘ใ΋355ͷൣғ֎ •

    ΞΫηεϙΠϯτ͕ͭ͋Ε͹Ґஔͷಛఆ͕Մೳ • ਫ਼౓Λग़͢ͳΒͭ΄͍͠ 19
  20. ΞΫηεϙΠϯτ͕ͭͷ৔߹ 20

  21. ΞΫηεϙΠϯτ͕ͭͷ৔߹ 21

  22. ΞΫηεϙΠϯτ͕ͭͷ৔߹ 22

  23. ࣮ࡍʹ͸׬ᘳͳ஋͸ औಘͰ͖ͳ͍ 23

  24. ݱ࣮ 24

  25. 25

  26. (PPHMF*0Ͱ঺հ͞Ε͍ͯͨํ๏ • ࣍ݩ௚ަ࠲ඪʹ୺຤ͱΞΫηεϙΠϯτΛஔ͘ • ϐλΰϥεͷఆཧΛ࢖ͬͯํఔࣜͰදݱ͢Δ • ͭͷ࣍ํఔࣜΛͭͷ࿈ཱํఔࣜʹͯ͠ղ͘ • ͭͷ࣍ํఔࣜʹͳΔ •

    ͭͷ࣍ํఔࣜͷ઀఺Ͱଟ֯ܗΛ࡞Γɺͦͷଟ֯ܗͷ த৺Λ୺຤ͷҐஔͱ͢Δ 26
  27. ࣍ݩ௚ަ࠲ඪʹ୺຤ͱΞΫηεϙΠϯτΛஔ͘ 27

  28. 28 x1 y1 r1 x, y (x − x1 )2

    + (y − y1 )2 = r2 1 ϐλΰϥεͷఆཧΛ࢖ͬͯํఔࣜͰදݱ͢Δ
  29. ϐλΰϥεͷఆཧΛ࢖ͬͯํఔࣜͰදݱ͢Δ 29 (x − x1 )2 + (y − y1

    )2 = r2 1 (x − x3 )2 + (y − y3 )2 = r2 3 (x − x2 )2 + (y − y2 )2 = r2 2 (x − x4 )2 + (y − y4 )2 = r2 4
  30. ࣍ํఔࣜΛඳը͢Δ 30 (x − x1 )2 + (y − y1

    )2 = r2 1 (x − x3 )2 + (y − y3 )2 = r2 3 (x − x2 )2 + (y − y2 )2 = r2 2 (x − x4 )2 + (y − y4 )2 = r2 4
  31. ଟ֯ܗͷਅΜதΛ୺຤ͷ৔ॴͱ͢Δ 31 (x − x1 )2 + (y − y1

    )2 = r2 1 (x − x3 )2 + (y − y3 )2 = r2 3 (x − x2 )2 + (y − y2 )2 = r2 2 (x − x4 )2 + (y − y4 )2 = r2 4
  32. "OESPJEͷ8J'J355"1* 32

  33. "OESPJEͰͷ8J'J355 • 04ͱͯ͠͸"OESPJE "1*-FWFM ͔ΒରԠ • ୺຤ͱͯ͠͸1JYFM 9-ؚΉ ͕ରԠ͍ͯ͠Δ •

    *0Ͱ͸1JYFMTͱݴͬͯͨͷͰ1JYFM΍1JYFM΋ର Ԡͯ͠Δ͔΋ 33
  34. ಛ௃ • ΞΫηεϙΠϯτʹ8J'Jͱͯ͠઀ଓ͠ͳͯ͘΋࢖͑Δ • ଞͷΞΫηεϙΠϯτʹ8J'Jͱͯ͠઀ଓதͰ΋࢖͑Δ • ̍౓ͷ"1*ͷ࣮ߦͰ'5.Λෳ਺ճ౤͛ͯɺฏۉɺඪ४ ภࠩ΍Τϥʔ཰Λฦͯ͘͠ΕΔ • كʹϚΠφεͷڑ཭͕ฦͬͯ͘Δʜ

    • ߴස౓ NT͘Β͍ʣͰ࢖͏ͱࢮ͵ 34
  35. ΍Δ͜ͱ • 8J'JΞΫηεϙΠϯτΛεΩϟϯ͢Δ • εΩϟϯͯ͠ಘΒΕͨΞΫηεϙΠϯτͷதʹ8J'J 355ରԠ͍ͯ͠ΔΞΫηεϙΠϯτ͕͋Δ͔֬ೝ͢Δ • 8J'J355ରԠΞΫηεϙΠϯτͱ8J'J355ͷ΍ ΓͱΓΛͯ݁͠ՌΛಘΔ 35

  36. ඞཁͳ1FSNJTTJPO <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 36

  37. 8J'JΞΫηεϙΠϯτΛεΩϟϯ val receiver = object: BroadcastReceiver() { override fun onReceive(context:

    Context, intent: Intent) { when(intent.action) { WifiManager.SCAN_RESULTS_AVAILABLE_ACTION -> { // Wi-FiͷεΩϟϯ͕׬ྃͨ͠ } } } } val filter = IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION) registerReceiver(receiver, filter) 37
  38. 8J'JΞΫηεϙΠϯτΛεΩϟϯ val wifiManager = getSystemService(Context.WIFI_SERVICE) as WifiManager wifiManager.startScan() 38

  39. 8J'JΞΫηεϙΠϯτΛεΩϟϯ val scanResults = wifiManager.scanResults.filter { it.is80211mcResponder } 39

  40. ΞΫηεϙΠϯτ·Ͱͷڑ཭Λऔಘ val rangingRequest = RangingRequest.Builder() .addAccessPoints(scanResults) .build() val rttManager =

    getSystemService(Context.WIFI_RTT_RANGING_SERVICE) as WifiRttManager val resultCallback = object : RangingResultCallback() { override fun onRangingResults(results: MutableList<RangingResult>) { val ragingResults = results.filter { it.status == STATUS_SUCCESS } } override fun onRangingFailure(code: Int) { } } rttManager.startRanging(rangingRequest, executor, resultCallback) 40
  41. TUBSU4DBOͷ࢓༷มߋ • 8JGJ.BOBHFSTUBSU4DBO ͕"1*-FWFM͔ Β৭ʑมߋ • ಥવͷEFQSFDBUFE • ͔͠΋୅ସखஈ͸ࠓͷͱ͜Ζͳͦ͞͏ •

    όοΫάϥ΢ϯυΞϓϦͰ͸෼ʹճ͔͠ݺ΂ͳ͍ • ϑΥΞάϥ΢ϯυΞϓϦͰ΋෼ʹճ͔͠ݺ΂ͳ͍ 41
  42. 8J'J"XBSFʹΑΔ355 42

  43. 8J'J"XBSFʹΑΔ355 • 8J'J"XBSFΛ࢖͏ͱ"OESPJE୺຤ಉ࢜Ͱ355Λ ߦ͑Δ • "1*-FWFM͔Β • 8J'J"XBSF͸͢Ε͕͍ͪ௨৴ͷΑ͏ͳػೳΛ࣮ݱ Ͱ͖Δ •

    8J'J"XBSFͰ઀ଓޙɺ355༻ͷϝιουΛݺͿ 43
  44. ࡞ͬͯΈͨ 44

  45. ࡞Δࡍʹ΍Δ͜ͱ • ΞΫηεϙΠϯτͷબఆ • ৔ॴͷબఆ • ஍ਤͷೖख • ΞΫηεϙΠϯτͷઃஔ •

    ΞΫηεϙΠϯτͷҢ౓ܦ౓ͷऔಘ • ΞϓϦͷ࡞੒ 45
  46. ΞΫηεϙΠϯτͷબఆ 46

  47. ΞΫηεϙΠϯτͷબఆ • *&&&NDʹରԠͨ͠8J'JΞΫηεϙΠϯτ • 8J'J"XBSF • ͭ·Γ1JYFM 47

  48. *&&&NDରԠΛ ᨳ͍ͬͯΔΞΫηεϙΠϯτ 48

  49. ແ͍ 49

  50. ແ͍ ˞ͳͬͽʔௐ΂ 50

  51. 51 (PPHMF8J'J

  52. (PPHMF8J'J • (PPHMF*0Ͱ͸(PPHMF8J'J͕XJMMTPPO ͰରԠ͢Δͱݴ͍ͬͯͨ • (PPHMF8J'JͷϦϦʔεϊʔτΛ൒೥Ҏ্؂ࢹ͠ଓ͚ ͕ͨ*&&&NDͷ͜ͱ͸Ұ੾ॻ͔Ε͍ͯͳ͍ • XJMMTPPOͱ͸Կͩͬͨͷ͔ 52

  53. (PPHMF8J'J • %SPJE,BJHJͷొஃ΋ܾ·ͬͨͷͰɺ(PPHMF8J'J ͕͍ͭߋ৽͞Εͯ΋͍͍Α͏ʹങ݄ͬͯʹηοςΟϯ άͨ͠ • ՈͰ8J'J355ͷ"OESPJE"1*Λࢼͨ͠Β8J'J 355ରԠ͍ͯ͠ΔΞΫηεϙΠϯτ͕ݟ͔ͭͬͨ • (PPHMF8J'J͕͠ΕͬͱରԠ͍ͯͨ͠

    53
  54. (PPHMF8J'J • ରԠ͍ͯ͠Δ΋ͷͷ(PPHMF 8J'Jͷઃఆ߲໨ʹ8J'J 355͸ͳ͍ • (PPHMF*0Ͱ͸8J'J355͸σϑΥϧτͰΦϯͱݴͬ ͍͕ͯͨΦϑʹͰ͖ͳ͍ • օ͞Μ͕͓࢖͍ͷ(PPHMF8J'J΋'5.SFRVFTUΛ

    ૹΔͱ'5.ฦͯ͘͠Ε·͢ 54
  55. ৔ॴͷબఆ 55

  56. ৔ॴͷબఆ • ී௨͸ܭଌ͍ͨ͠৔ॴ͕͋Δͱ͜Ζ͔Β࢝·ΔͷͰ৔ ॴ͕ܾ·ͬͨঢ়ଶͰ࢝·Δʢ͸ͣʣ • ࠓճ͸ܭଌ͢Δ͜ͱ͕໨తͳͷͰɺ৔ॴͷબఆ͕ඞཁ 56

  57. ৔ॴͷ৚݅ • ޿͍৔ॴ • ڱ͍৔ॴ͸ਫ਼౓తʹແཧ • ݐ෺಺ͷେ͖͕͞ਖ਼֬ͳ஍ਤ͕͋Δ • ݐ෺಺ͷҢ౓ܦ౓ΛʢϝδϟʔͰଌΔͳͲͷํ๏Ͱʣ ஌Δ͜ͱ͕Ͱ͖Δ

    • ΞΫηεϙΠϯτͷҢ౓ܦ౓ʹਖ਼֬ͳ஋͕ඞཁ 57
  58. ࠓճͷ৔ॴ • ࠓճ͸ࣗ෼ͷՈʹͨ͠ • ͋ͱ͔ΒݟΔͱ͜Ε͸ࣦഊ • ڱ͍ • σϞಈըͰΞϓϦͷը໘ͱ৔ॴΛऩΊ͔͕ͨͬͨɺ ՈͷதΛ%SPJE,BJHJͰࡽ͢༐ؾ͸ͳ͔ͬͨ

    58
  59. ஍ਤͷೖख 59

  60. ஍ਤͷೖख • ϢʔβʔʹݟͤΔͱ͖ͱΞΫηεϙΠϯτͷઃஔʹ࢖ ༻͢Δ • ԰಺ͷ஍ਤ͕ͳ͍ͳΒ԰಺ଌҐ͢Δҙຯ͸͋·Γͳ͍ • ਖ਼֬ͳ஍ਤͰͳ͚Ε͹ਖ਼֬ͳଌҐ͸Ͱ͖ͳ͍ • ࠓճ͸ؒऔΓਤΛ࢖༻

    60
  61. ΞΫηεϙΠϯτͷઃஔ 61

  62. ΞΫηεϙΠϯτͷઃஔ • ձ৔ͷେ͖͞ʹ߹Θͤͯ·Μ΂Μͳ͘ઃஔ͢Δ • ΞΫηεϙΠϯτʹғ·Ε͍ͯΔΑ͏ͳঢ়ଶʹ͢Δ • ௚ઢͰ݁΂ΔΑ͏ͳ഑ஔ͸Ͱ͸ਫ਼౓͕ग़ͳ͍ • ࢛͍֯෦԰ͳΒ࢛۱ͱਅΜத͕ྑͦ͞͏ •

    ࠓճ͸ׂͱࡶ 62
  63. ΞΫηεϙΠϯτͷҢ౓ܦ౓ 63

  64. ΞΫηεϙΠϯτͷҢ౓ܦ౓ͷऔಘ • ஍ਤͳͲΛ࢖ͬͯΞΫηεϙΠϯτͷҢ౓ܦ౓Λؤுͬ ׂͯΓग़͢ • ௒େม 64

  65. ΞϓϦͷ࡞੒ 65

  66. ΞϓϦͷ࡞੒ • (PPHMF.BQ4%,Λ࢖͏͔࢖Θͳ͍͔ΛܾΊΔ • ࢖Θͳ͍৔߹ɺ஍ਤతͳૢ࡞͸ࣗલ࣮૷͕ඞཁ • ࢖Θͳ͍৔߹ɺҢ౓ܦ౓͸ͳͯ͘΋͍͍ • Ψοͱؾ߹Ͱ࣮૷͢Δ •

    ਫ਼౓Λؾʹ͠ͳ͚Ε͹؆୯ʹ࣮૷Ͱ͖Δ • ਫ਼౓Λؾʹ͢Δͱແݶʹ͕͔͔࣌ؒΔ 66
  67. ਫ਼౓Λ্͛ΔΞΠσΟΞ 67

  68. ਫ਼౓Λ্͛Δ • ߴ͞Λ࢖͏ • ΞΫηεϙΠϯτ͕ఱҪʹ͋Δ৔߹ͳͲ͸ߟྀͨ͠ ΄͏͕ྑͦ͞͏ • ΞΫηεϙΠϯτͷઃஔ৔ॴΛݟ௚͢ • ڑ཭͔ΒҐஔ৘ใΛࢉग़͢Δํ๏Λมߋ͢Δ

    • લճऔಘͨ͠஋ͳͲΛ࢖ͬͯҟৗ஋Λແࢹ͢Δ 68
  69. ਫ਼౓Λ্͛Δ • ΞΫηεϙΠϯτͷ਺Λ૿΍͢ • ඪ४ภࠩͷେ͖ͳΞΫηεϙΠϯτΛແࢹ͢ΔͳͲ • ֤छηϯαʔΛ࢖͏ • Ճ଎౓ηϯαʔ •

    ίϯύε 69
  70. ·ͱΊ 70

  71. ·ͱΊ • ΞΫηεϙΠϯτ͸(PPHMF8J'J • ஍ਤ΍ΞΫηεϙΠϯτͷҢ౓ܦ౓ͳͲͷਖ਼͕֬͞ॏཁ • ͋Δఔ౓޻෉Λ͠ͳ͍ͱਫ਼౓͸ग़ͳ͍ • ਫ਼౓͕ѱ͍৔߹Ͳ͜ʹ໰୊͕͋Δͷ͔ಛఆ͠ʹ͍͘ 71

  72. ΋͜͠ͷ৔ͰσϞ͢ΔͳΒ 72

  73. ͜ͷ৔ͰσϞ͢Δʹ͸ • ձ৔ͷ8J'JʹӨڹΛ༩͑ΔՄೳੑ͕͋ΔͷͰӡӦʹ֬ ೝ • 8J'J"XBSFΛ࢖͏ • ઃஔָ͕ 73

  74. ͜ͷ৔ͰσϞ͢Δʹ͸ • ਖ਼֬ͳ஍ਤͷೖख͸ఘΊΔ • (PPHMF.BQΛͦͷ··࢖͍͍ͬͯͳΒਖ਼֬ͳ஍ ਤ͸ͳͯ͘΋͍͍ • ৄࡉͳ஍ਤ͕͋ͬͨ΄͏͕໘ന͍͕ɺσϞͳͷͰ໨ ͷલͰಈ͔͚ͩ͢Ͱ΋े෼ 74

  75. ͜ͷ৔ͰσϞ͢Δʹ͸ • ઃஔ৔ॴ͸࢛۱ʴձ৔ͷେ͖͞ʹԠͯ͡ਅΜதʹ • Ң౓ܦ౓͸ؤுͬͯ༧૝͢Δ • લ೔ͳͲʹਤΒͤͯ΋Β͑ͳ͍͔ަব͢Δ • 8J'J"XBSFͳΒ୺຤ஔ͚ͩ͘ͳͷͰɺΈͳ͞Μ ʹ࣋ͬͯ΋Β͏ͷ΋͋Γ

    75