Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Perl meets Real World

B5582ce2d9959dfcff0384a07003e188?s=47 mackee
August 29, 2014

Perl meets Real World

YAPC::Asia 2014 2014-08-29 by @mackee_w

B5582ce2d9959dfcff0384a07003e188?s=128

mackee

August 29, 2014
Tweet

Transcript

  1. Perl meets Real World 2014-08-29 YAPC::Asia 2014

  2. @mackee_w a.k.a Ϛίϐʔ • ໘ന๏ਓΧϠοΫ ٕज़෦ • αʔόαΠυΤϯδχΞ(Perl) • ιʔγϟϧήʔϜͷ։ൃ/ӡ༻

    • ࠓ࡞͍ͬͯΔήʔϜ͸ࣄલొ࿥ड෇த
  3. ͯ͞

  4. WebΤϯδχΞ͕ Կނϋʔυ΢ΣΞ͔ʁ

  5. ڈ೥গ͚ͩ͠ϋʔυ΢ΣΞͷ ࢓ࣄΛͨ͠ • ઇࢁͰϥδίϯϔϦΛඈ͹͢࢓ࣄ • Webͷٕज़͔͠ແ͔ͬͨ • ௐ΂ͨΒ࠷ۙͷϋʔυ͸͍͢͜͝ͱʹͳͬ ͍ͯͨ

  6. ࢖ٕͬͨज़ • RaspberryPi • Arduino • OpenCV • Ansible

  7. ϋʔυ΢ΣΞ શ෦ҰൠతʹೖखՄೳ

  8. ιϑτ΢ΣΞ “Web”ʹ΋௨ͣΔٕज़ͨͪ

  9. ۤ࿑΋͚͋ͬͨΕͲ ָ͔ͬͨ͠ͷͰ”ํ๏”ͷ Ұ෦Λ঺հ͠·͢

  10. ࠓ೔࿩͢͜ͱ • RaspberryPiͱArduino • Φʔϓϯιʔεϋʔυ΢ΣΞ • Perl͚ͩͰωΪΛৼΔ • ࣗ࡞ϋʔυ΢ΣΞͱະདྷ

  11. ࠓ೔࿩͞ͳ͍͜ͱ • ϋϯμ෇͚ʢձ৔͔Β͓ͦΒౖ͘ΒΕΔʣ • ճ࿏ઃܭʢཁ๬͕͋Ε͹ผͷػձʹʣ • ΨνͷArduinoʢ͍ͨΒ࠙਌ձͱ͔Ͱʣ • ͦͷଞΨνిࢠ޻࡞

  12. ୈҰষ Raspberry PiͱArduino

  13. Raspberry Pi http://commons.wikimedia.org/wiki/File:Raspberry_Pi_Photo.jpg

  14. • ARM 700MHz • 512MB RAM(Model B) • SD CARD

    • 100BASE-TX LAN • USB2.0 x 2 • HDMI and RCA VIDEO • Audio • Power by USB
  15. Q. Ͱɺ͜ΕͰPerl͸ಈ͘ͷʁ

  16. A. ΋ͪΖΜಈ͖·͢ʂ

  17. ී௨ͷLinux͕ಈ͘ • Raspbian (DebianͷRasPi޲͚ΧελϜ) • NOOBS(for beginner) • Pidora(FedoraͷRasPi޲͚ΧελϜ)

  18. ͦ΋ͦ΋ͷRasPiͷ໨త • খதֶੜ΍ൃల్্ࠃ޲͚ͷITڭҭ • RCAϏσΦδϟοΫ͕෇͍͍ͯΔͷ΋ൃల్্ ࠃͷϒϥ΢ϯ؅ςϨϏͰ࢖͏ͨΊ • MinecraftͷRasPi൛ͱ͔΋͋ͬͯPythonͰΧελ ϚΠζͰ͖ͨΓ͢Δ

  19. kano ࢠڙ޲͚ͷΦʔϧΠϯϫϯͷPCΩοτ https://www.kickstarter.com/projects/alexklein/kano-a-computer-anyone-can-make

  20. ͔͠͠େਓ΋஫໨༷ͯ͠ʑͳ ϓϩδΣΫτ͕ڵͬͨ

  21. RaspberryPiΛ࢖ͬͨϓϩδΣΫτ

  22. Raspberry Pi͸ Կނ஫໨/׆༻͞Ε͔ͨ

  23. ·͍͋ΖΜͳཧ༝͸͋Δ • ͍҆ (B/B+͕4000ԁఔ౓) • ΫϨδοτΧʔυαΠζ • ଞʹ΋طʹಉछͷ΋ͷ͸͋ͬͨ • ؀ڥ͕੔͍ͬͯΔ(ग़͕ࣗॳ৺ऀ޲͚)

    • ࡞ྫ͕ଟ͍
  24. GPIO

  25. GPIO - ݱ࣮ੈքʹհೖ͢ΔͨΊͷखஈ

  26. ిؾΛݟฉ͖͠ɺ͠Ό΂Δ • ϞʔλʔͳͲͷۦಈػثͷಈ࡞ -> ࢛ࢶ • ηϯαʔͰͷपғঢ়گͷݕ஌ -> ޒײ

  27. ిؾͱ͍͏࠷΋௿ϨΠϠʔΛ खܰʹѻ͑Δͷ͕RasPi

  28. Arduinoͷ࿩

  29. • ిؾΛѻ͏͜ͱʹಛԽ • 8bit ϚΠίϯΛ౥ࡌ • ॲཧೳྗ͸ඇৗʹখ͍͞ • USB͸ೖྗઐ༻ •

    ྫ֎΋͋Δ • LinuxͳͲ౸ఈಈ͔ͳ͍ • ௚઀ϐϯΛૢ࡞͢Δ
  30. Q. Ͱɺ͜ΕͰPerl͸ಈ͘ͷʁ

  31. A. (‘A`) ಈ͔ͳ͍ɻɻɻ

  32. ϋʔυ΢ΣΞ୯ମͰ͸ඇྗ͕ͩ ΤίγεςϜ͕ڧྗ

  33. Arduino IDE Arduinoʹඞཁͳ΋ͷΛશͯ٧ΊࠐΜͩιϑτ΢ΣΞ

  34. γʔϧυ ਌ُࢠُํࣜͰ֦ு͢ΔΞλονϝϯτ

  35. ϥΠϒϥϦ΍ArduinoΛલఏͱͨ͠Ωοτ

  36. ๻͸͜͏࢖͍෼͚Δ

  37. RaspberryPiͰ΍Γ͍ͨ͜ͱ • ը૾ॲཧͱ͔Τϯίʔυͱ͔ॏ͍ͨॲཧ • ෳࡶͳΞϧΰϦζϜΛཁ͢Δ΋ͷ • PC޲͚ͷϥΠϒϥϦ͕͙͢ಈ͖΍͍͢ • ௒؆୯ͳΦϯΦϑఔ౓ͷϋʔυ΢ΣΞ੍ޚ

  38. ArduinoͰ΍Γ͍ͨ͜ͱ • ࣗ࡞ͷిࢠ෦඼ͳͲͱ࿈ܞ͢Δέʔε • Arduino޲͚ϥΠϒϥϦ͕͢Ͱʹ͋Δ৔߹ • PWM੍ޚͳͲͷߴ଎ʹΦϯɾΦϑΛ΍Δ৔߹ • RasPiͩͱ͜͏͍͏͜ͱΛ΍ΔͱCPUΛΊͬ ͪΌ৯͏

  39. ීஈ͸2ͭΛ૊Έ߹ΘͤΔ͜ͱ ͕ଟ͍Ͱ͕͢ɺͦΕ͸ޙͷষͰ

  40. ୈೋষ Φʔϓϯϋʔυ΢ΣΞ

  41. ΦʔϓϯιʔεϥΠηϯε • ࣗ༝ͳ࠶൦෍͕Մೳ • ιʔείʔυ͕ೖखͰ͖Δ • ೿ੜ෺Λ࡞ͬͯ΋ྑ͍ • ͦͷଞϥΠηϯε͕ܧঝ͞ΕΔͱ͔

  42. ϋʔυ΢ΣΞʹ͓͚Δ Φʔϓϯιʔεͱ͸

  43. ϋʔυ΢ΣΞͷιʔε • ϑΝʔϜ΢ΣΞ • ճ࿏ਤ • ෦඼৘ใ • ج൘഑ஔਤ

  44. Arduinoͷྫ

  45. ճ࿏ਤ(Arduino Unoͷ৔߹) http://arduino.cc/en/Main/ArduinoBoardUno

  46. ج൘഑ஔਤ΋Eagleͱ͍͏ ճ࿏ਤ/ج൘ΤσΟλͷܗࣜͰ ൦෍͞Ε͍ͯΔ

  47. ͭ·Γ؆୯ʹArduinoΛ ࣗ࡞͢Δ͜ͱ͕ग़དྷΔ

  48. ݱʹΫϩʔϯ͕͍ͬͺ͍ଘࡏ͢Δ

  49. ArduinoΛࣗ࡞͢ΔϝϦοτ • ػೳͷ௥Ճ • Ϟʔλʔ੍ޚճ࿏Λ૊ΈࠐΉͱ͔ • ϑοτϓϦϯτͷݮগ • ΊͬͪΌখ͍͞ػثʹੵΈ͍ͨ •

    ArduinoͷΤίγεςϜͷԸܙΛड͚ΒΕΔ
  50. ϋʔυΛΦʔϓϯʹ͢Δ͜ͱ • ϋοΫΛଅ͢ • ΤίγεςϜ͕ൃల͠΍͍͢ • ྲྀߦΔͱ໛଄඼͕ͨ͘͞Μग़ͯ͘Δ • Arduino΍RasPi͸໊લΛ࢖͏ͷΛϥΠη ϯεͰ੍ݶ͍ͯ͠Δ

  51. ΦʔϓϯʹͳΕ͹ϋʔυ΢ΣΞ Ͱ΋ϚογϡΞοϓ(ࢮޠ) ग़དྷΔͱ͍͏͜ͱͰ͢Ͷ

  52. ୈࡾষ Perl͚ͩͰωΪΛৼΔ

  53. None
  54. ωΪΛৼΔͱ͸ʁʁʁ • ݩʑχίχίಈըͷॳԻϛΫಈըͰωΪΛ ৼΔ΋ͷ͕͋Δ • χίχίٕज़෦Ͱೖ໳ಈըͰΑ͘୊ࡐʹͳ Δ • ͍ΖΜͳ΋ͷͰωΪΛৼ͍ͬͯΔ

  55. ҎԼͷറΓͰ࡞Δ • ϋϯμ෇͚ͳ͠ ϒϨουϘʔυͳ͠ • Arduinoݴޠ͸ॻ͔ͳ͍ • Perl͸ॻ͘(YAPCͳͷͰ)

  56. ࡐྉ • Raspberry Pi Model B • Arduino Leonardo(Ոʹ͋ͬͨ) •

    GROVE System
  57. GROVE Systemͱ͸

  58. ͜͏͍͏ͪͬͪΌ͍෦඼͕͋ͬͯ

  59. ͜͏͍͏γʔϧυΛArduinoʹࡌ͚ͬͯ

  60. ͜Μͳ͔Μ͡Ͱͭͳ͛ͯ࢖͏

  61. ࢖͏ͨΊͷϥΠϒϥϦ΋طʹ ׬උ͞Ε͍ͯΔ

  62. Step 1 Raspberry PiͱArduinoͰ ͓͠Ό΂Γ͢Δ

  63. Firmata͍ͬͯ͏ͷΛ࢖͍·͢ • Firmata͸Arduinoͱ͔ͷϚΠίϯͱPCؒ Ͱ͓͠Ό΂Γ͢ΔͨΊͷϓϩτίϧ • ͓खܰಋೖՄೳ

  64. ࠓ౓͸FirmataͰLEDΛޫΒ͢

  65. PerlͰFirmataΛ͠Ό΂Δ

  66. ArduinoʹFirmataͷ εέονΛॻ͖ࠐΉ

  67. ϋʔυͷ΄͏ͷ४උ • ArduinoͱGROVE Base ShieldΛ઀ଓ • γʔϧυͷD4ʹLEDϞδϡʔϧΛ઀ଓ • ArduinoͱRaspberry PiΛͭͳ͛Δ

  68. Step 2 αʔϘϞʔλΛ࢖͏

  69. GROVEͷαʔϘϞʔλ D3ʹͭͳ͍ͩ

  70. Step 3 WebΞϓϦԽ͢Δ

  71. Amon2Ͱ࡞Δ

  72. WebΞϓϦͷػೳ • WebSocketͰ֯౓৘ใΛड৴ • ͦͷ஋ΛRedisʹॻ͖ࠐΉ

  73. ผϓϩηεͷϫʔΧʔ • ແݶϧʔϓͰRedisͷ஋Λ؂ࢹ • มԽ͕͋Ε͹FirmataͰArduinoʹૹ৴

  74. σϞ

  75. ࠷ऴষ ࣗ࡞ϋʔυ΢ΣΞͱະདྷ

  76. ϋʔυ΢ΣΞΛࣗ෼Ͱ࡞ΕΔ ࣌୅͸࣮֬ʹདྷ͍ͯΔ • 3DϓϦϯλͱ͔ੲ͸ߟ͑ΒΕͳ͔ͬͨ • ᝑମΛ͔ͬ͜ྑ͘࡞Δ໰୊͕ૉૣ͘ղܾ • ϋʔυ΢ΣΞΛखചΓ͢Δ࣌୅ʹͳͬͨ • Make

    Fairͱ͔Ͷ
  77. IRKit http://getirkit.com/

  78. IRKit • த਎͸Arduinoޓ׵ج൘ • ͢΂ͯΦʔϓϯ • ճ࿏ઃܭ΍ᝑମͷઃܭΛݸਓͰߦ͏

  79. ϋʔυ΢ΣΞΛ͕ͬͭΓ΍Β ͣʹ࡞ΕΔ࣌୅ • ࣗ෼ͷख׳ΕͨݴޠͰهड़Ͱ͖Δ • ϋϯμ෇͚ෆཁ • εςοϓΞοϓ͢ΔͱϒϨουϘʔυ΍ ϋϯμ෇͚͕ඞཁʹͳΔ͚ΕͲ

  80. ·ͩ·ͩ଍Γͳ͍͜ͱ (๻͕஌Βͳ͍͚͔ͩ΋) • ΤϯδχΞϦϯάͱͯ͠ͷ࢓૊ΈԽ • PerlͰݴ͏CPANΈ͍ͨͳ΍ͭ • ษڧձɺϫʔΫγϣοϓ • ςετ؀ڥ

  81. ϋʔυ΢ΣΞͳਓͱग़ձ͍͍ͨʂ • Webͷਓͱ͸Α͘ձ͏͚ΕͲɺ͜͏͍͏͜ ͱ΍͍ͬͯΔਓͳ͔ͳ͔ग़ձΘͳ͍ • ͍ͨΒ঺հͯ͠ཉ͍͠͠ɺ͋ͳ͕ͨͦ͏Ͱ ͋Ε͹༑ͩͪʹͳ͍ͬͯͩ͘͞

  82. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠

  83. ࣭ٙԠ౴΍ ͕࣌ؒ༨ͬͨΒ΍Δ༻

  84. ແઢԽ

  85. γϦΞϧΛແઢԽ • XBee/XBee WiFi΍ͦͷଞແઢLANϞδϡʔϧ • γϦΞϧΛZigBee΍WiFiʹม׵Ͱ͖Δ • ٕదʹ஫ҙ • ւ֎੡Ϟδϡʔϧ͸ి೾๏ͰҾ͔͔ͬΔͱ

    ͔͋Δ
  86. RasPi Cam

  87. Raspberry Piઐ༻Χϝϥ • খ͍͍ͦͦ҆͜͜͞͠(2000ԁ୆) • ͨͩ͠RasPiઐ༻ • RasPiΛϥΠϒΧϝϥͱ͔ʹग़དྷΔ • ϔϦͰ΋࢖͍·ͨ͠ʢখ͍͞͠USB৯Θͳ͍