Perl meets Real World
by
mackee
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Perl meets Real World 2014-08-29 YAPC::Asia 2014
Slide 2
Slide 2 text
@mackee_w a.k.a Ϛίϐʔ • ໘ന๏ਓΧϠοΫ ٕज़෦ • αʔόαΠυΤϯδχΞ(Perl) • ιʔγϟϧήʔϜͷ։ൃ/ӡ༻ • ࠓ࡞͍ͬͯΔήʔϜࣄલొडத
Slide 3
Slide 3 text
ͯ͞
Slide 4
Slide 4 text
WebΤϯδχΞ͕ ԿނϋʔυΣΞ͔ʁ
Slide 5
Slide 5 text
ڈগ͚ͩ͠ϋʔυΣΞͷ ࣄΛͨ͠ • ઇࢁͰϥδίϯϔϦΛඈ͢ࣄ • Webͷٕज़͔͠ແ͔ͬͨ • ௐͨΒ࠷ۙͷϋʔυ͍͢͜͝ͱʹͳͬ ͍ͯͨ
Slide 6
Slide 6 text
ٕͬͨज़ • RaspberryPi • Arduino • OpenCV • Ansible
Slide 7
Slide 7 text
ϋʔυΣΞ શ෦ҰൠతʹೖखՄೳ
Slide 8
Slide 8 text
ιϑτΣΞ “Web”ʹ௨ͣΔٕज़ͨͪ
Slide 9
Slide 9 text
ۤ࿑͚͋ͬͨΕͲ ָ͔ͬͨ͠ͷͰ”ํ๏”ͷ Ұ෦Λհ͠·͢
Slide 10
Slide 10 text
ࠓ͢͜ͱ • RaspberryPiͱArduino • ΦʔϓϯιʔεϋʔυΣΞ • Perl͚ͩͰωΪΛৼΔ • ࣗ࡞ϋʔυΣΞͱະདྷ
Slide 11
Slide 11 text
ࠓ͞ͳ͍͜ͱ • ϋϯμ͚ʢձ͔Β͓ͦΒౖ͘ΒΕΔʣ • ճ࿏ઃܭʢཁ͕͋Εผͷػձʹʣ • ΨνͷArduinoʢ͍ͨΒ࠙ձͱ͔Ͱʣ • ͦͷଞΨνిࢠ࡞
Slide 12
Slide 12 text
ୈҰষ Raspberry PiͱArduino
Slide 13
Slide 13 text
Raspberry Pi http://commons.wikimedia.org/wiki/File:Raspberry_Pi_Photo.jpg
Slide 14
Slide 14 text
• ARM 700MHz • 512MB RAM(Model B) • SD CARD • 100BASE-TX LAN • USB2.0 x 2 • HDMI and RCA VIDEO • Audio • Power by USB
Slide 15
Slide 15 text
Q. Ͱɺ͜ΕͰPerlಈ͘ͷʁ
Slide 16
Slide 16 text
A. ͪΖΜಈ͖·͢ʂ
Slide 17
Slide 17 text
ී௨ͷLinux͕ಈ͘ • Raspbian (DebianͷRasPi͚ΧελϜ) • NOOBS(for beginner) • Pidora(FedoraͷRasPi͚ΧελϜ)
Slide 18
Slide 18 text
ͦͦͷRasPiͷత • খதֶੜൃల్্ࠃ͚ͷITڭҭ • RCAϏσΦδϟοΫ͕͍͍ͯΔͷൃల్্ ࠃͷϒϥϯςϨϏͰ͏ͨΊ • MinecraftͷRasPi൛ͱ͔͋ͬͯPythonͰΧελ ϚΠζͰ͖ͨΓ͢Δ
Slide 19
Slide 19 text
kano ࢠڙ͚ͷΦʔϧΠϯϫϯͷPCΩοτ https://www.kickstarter.com/projects/alexklein/kano-a-computer-anyone-can-make
Slide 20
Slide 20 text
͔͠͠େਓ༷ͯ͠ʑͳ ϓϩδΣΫτ͕ڵͬͨ
Slide 21
Slide 21 text
RaspberryPiΛͬͨϓϩδΣΫτ
Slide 22
Slide 22 text
Raspberry Pi Կނ/׆༻͞Ε͔ͨ
Slide 23
Slide 23 text
·͍͋ΖΜͳཧ༝͋Δ • ͍҆ (B/B+͕4000ԁఔ) • ΫϨδοτΧʔυαΠζ • ଞʹطʹಉछͷͷ͋ͬͨ • ڥ͕͍ͬͯΔ(ग़͕ࣗॳ৺ऀ͚) • ࡞ྫ͕ଟ͍
Slide 24
Slide 24 text
GPIO
Slide 25
Slide 25 text
GPIO - ݱ࣮ੈքʹհೖ͢ΔͨΊͷखஈ
Slide 26
Slide 26 text
ిؾΛݟฉ͖͠ɺ͠ΌΔ • ϞʔλʔͳͲͷۦಈػثͷಈ࡞ -> ࢛ࢶ • ηϯαʔͰͷपғঢ়گͷݕ -> ޒײ
Slide 27
Slide 27 text
ిؾͱ͍͏࠷ϨΠϠʔΛ खܰʹѻ͑Δͷ͕RasPi
Slide 28
Slide 28 text
Arduinoͷ
Slide 29
Slide 29 text
• ిؾΛѻ͏͜ͱʹಛԽ • 8bit ϚΠίϯΛࡌ • ॲཧೳྗඇৗʹখ͍͞ • USBೖྗઐ༻ • ྫ֎͋Δ • LinuxͳͲ౸ఈಈ͔ͳ͍ • ϐϯΛૢ࡞͢Δ
Slide 30
Slide 30 text
Q. Ͱɺ͜ΕͰPerlಈ͘ͷʁ
Slide 31
Slide 31 text
A. (‘A`) ಈ͔ͳ͍ɻɻɻ
Slide 32
Slide 32 text
ϋʔυΣΞ୯ମͰඇྗ͕ͩ ΤίγεςϜ͕ڧྗ
Slide 33
Slide 33 text
Arduino IDE ArduinoʹඞཁͳͷΛશͯ٧ΊࠐΜͩιϑτΣΞ
Slide 34
Slide 34 text
γʔϧυ ُࢠُํࣜͰ֦ு͢ΔΞλονϝϯτ
Slide 35
Slide 35 text
ϥΠϒϥϦArduinoΛલఏͱͨ͠Ωοτ
Slide 36
Slide 36 text
͜͏͍͚Δ
Slide 37
Slide 37 text
RaspberryPiͰΓ͍ͨ͜ͱ • ը૾ॲཧͱ͔Τϯίʔυͱ͔ॏ͍ͨॲཧ • ෳࡶͳΞϧΰϦζϜΛཁ͢Δͷ • PC͚ͷϥΠϒϥϦ͕͙͢ಈ͖͍͢ • ؆୯ͳΦϯΦϑఔͷϋʔυΣΞ੍ޚ
Slide 38
Slide 38 text
ArduinoͰΓ͍ͨ͜ͱ • ࣗ࡞ͷిࢠ෦ͳͲͱ࿈ܞ͢Δέʔε • Arduino͚ϥΠϒϥϦ͕͢Ͱʹ͋Δ߹ • PWM੍ޚͳͲͷߴʹΦϯɾΦϑΛΔ߹ • RasPiͩͱ͜͏͍͏͜ͱΛΔͱCPUΛΊͬ ͪΌ৯͏
Slide 39
Slide 39 text
ීஈ2ͭΛΈ߹ΘͤΔ͜ͱ ͕ଟ͍Ͱ͕͢ɺͦΕޙͷষͰ
Slide 40
Slide 40 text
ୈೋষ ΦʔϓϯϋʔυΣΞ
Slide 41
Slide 41 text
ΦʔϓϯιʔεϥΠηϯε • ࣗ༝ͳ࠶൦͕Մೳ • ιʔείʔυ͕ೖखͰ͖Δ • ੜΛ࡞ͬͯྑ͍ • ͦͷଞϥΠηϯε͕ܧঝ͞ΕΔͱ͔
Slide 42
Slide 42 text
ϋʔυΣΞʹ͓͚Δ Φʔϓϯιʔεͱ
Slide 43
Slide 43 text
ϋʔυΣΞͷιʔε • ϑΝʔϜΣΞ • ճ࿏ਤ • ෦ใ • ج൘ஔਤ
Slide 44
Slide 44 text
Arduinoͷྫ
Slide 45
Slide 45 text
ճ࿏ਤ(Arduino Unoͷ߹) http://arduino.cc/en/Main/ArduinoBoardUno
Slide 46
Slide 46 text
ج൘ஔਤEagleͱ͍͏ ճ࿏ਤ/ج൘ΤσΟλͷܗࣜͰ ൦͞Ε͍ͯΔ
Slide 47
Slide 47 text
ͭ·Γ؆୯ʹArduinoΛ ࣗ࡞͢Δ͜ͱ͕ग़དྷΔ
Slide 48
Slide 48 text
ݱʹΫϩʔϯ͕͍ͬͺ͍ଘࡏ͢Δ
Slide 49
Slide 49 text
ArduinoΛࣗ࡞͢ΔϝϦοτ • ػೳͷՃ • Ϟʔλʔ੍ޚճ࿏ΛΈࠐΉͱ͔ • ϑοτϓϦϯτͷݮগ • ΊͬͪΌখ͍͞ػثʹੵΈ͍ͨ • ArduinoͷΤίγεςϜͷԸܙΛड͚ΒΕΔ
Slide 50
Slide 50 text
ϋʔυΛΦʔϓϯʹ͢Δ͜ͱ • ϋοΫΛଅ͢ • ΤίγεςϜ͕ൃల͍͢͠ • ྲྀߦΔͱ͕ͨ͘͞Μग़ͯ͘Δ • ArduinoRasPi໊લΛ͏ͷΛϥΠη ϯεͰ੍ݶ͍ͯ͠Δ
Slide 51
Slide 51 text
ΦʔϓϯʹͳΕϋʔυΣΞ ͰϚογϡΞοϓ(ࢮޠ) ग़དྷΔͱ͍͏͜ͱͰ͢Ͷ
Slide 52
Slide 52 text
ୈࡾষ Perl͚ͩͰωΪΛৼΔ
Slide 53
Slide 53 text
No content
Slide 54
Slide 54 text
ωΪΛৼΔͱʁʁʁ • ݩʑχίχίಈըͷॳԻϛΫಈըͰωΪΛ ৼΔͷ͕͋Δ • χίχίٕज़෦ͰೖಈըͰΑ͘ࡐʹͳ Δ • ͍ΖΜͳͷͰωΪΛৼ͍ͬͯΔ
Slide 55
Slide 55 text
ҎԼͷറΓͰ࡞Δ • ϋϯμ͚ͳ͠ ϒϨουϘʔυͳ͠ • Arduinoݴޠॻ͔ͳ͍ • Perlॻ͘(YAPCͳͷͰ)
Slide 56
Slide 56 text
ࡐྉ • Raspberry Pi Model B • Arduino Leonardo(Ոʹ͋ͬͨ) • GROVE System
Slide 57
Slide 57 text
GROVE Systemͱ
Slide 58
Slide 58 text
͜͏͍͏ͪͬͪΌ͍෦͕͋ͬͯ
Slide 59
Slide 59 text
͜͏͍͏γʔϧυΛArduinoʹࡌ͚ͬͯ
Slide 60
Slide 60 text
͜Μͳ͔Μ͡Ͱͭͳ͛ͯ͏
Slide 61
Slide 61 text
͏ͨΊͷϥΠϒϥϦطʹ උ͞Ε͍ͯΔ
Slide 62
Slide 62 text
Step 1 Raspberry PiͱArduinoͰ ͓͠ΌΓ͢Δ
Slide 63
Slide 63 text
Firmata͍ͬͯ͏ͷΛ͍·͢ • FirmataArduinoͱ͔ͷϚΠίϯͱPCؒ Ͱ͓͠ΌΓ͢ΔͨΊͷϓϩτίϧ • ͓खܰಋೖՄೳ
Slide 64
Slide 64 text
ࠓFirmataͰLEDΛޫΒ͢
Slide 65
Slide 65 text
PerlͰFirmataΛ͠ΌΔ
Slide 66
Slide 66 text
ArduinoʹFirmataͷ εέονΛॻ͖ࠐΉ
Slide 67
Slide 67 text
ϋʔυͷ΄͏ͷ४උ • ArduinoͱGROVE Base ShieldΛଓ • γʔϧυͷD4ʹLEDϞδϡʔϧΛଓ • ArduinoͱRaspberry PiΛͭͳ͛Δ
Slide 68
Slide 68 text
Step 2 αʔϘϞʔλΛ͏
Slide 69
Slide 69 text
GROVEͷαʔϘϞʔλ D3ʹͭͳ͍ͩ
Slide 70
Slide 70 text
Step 3 WebΞϓϦԽ͢Δ
Slide 71
Slide 71 text
Amon2Ͱ࡞Δ
Slide 72
Slide 72 text
WebΞϓϦͷػೳ • WebSocketͰ֯ใΛड৴ • ͦͷΛRedisʹॻ͖ࠐΉ
Slide 73
Slide 73 text
ผϓϩηεͷϫʔΧʔ • ແݶϧʔϓͰRedisͷΛࢹ • มԽ͕͋ΕFirmataͰArduinoʹૹ৴
Slide 74
Slide 74 text
σϞ
Slide 75
Slide 75 text
࠷ऴষ ࣗ࡞ϋʔυΣΞͱະདྷ
Slide 76
Slide 76 text
ϋʔυΣΞΛࣗͰ࡞ΕΔ ࣮࣌֬ʹདྷ͍ͯΔ • 3DϓϦϯλͱ͔ੲߟ͑ΒΕͳ͔ͬͨ • ᝑମΛ͔ͬ͜ྑ͘࡞Δ͕ૉૣ͘ղܾ • ϋʔυΣΞΛखചΓ͢Δ࣌ʹͳͬͨ • Make Fairͱ͔Ͷ
Slide 77
Slide 77 text
IRKit http://getirkit.com/
Slide 78
Slide 78 text
IRKit • தArduinoޓج൘ • ͯ͢Φʔϓϯ • ճ࿏ઃܭᝑମͷઃܭΛݸਓͰߦ͏
Slide 79
Slide 79 text
ϋʔυΣΞΛ͕ͬͭΓΒ ͣʹ࡞ΕΔ࣌ • ࣗͷख׳ΕͨݴޠͰهड़Ͱ͖Δ • ϋϯμ͚ෆཁ • εςοϓΞοϓ͢ΔͱϒϨουϘʔυ ϋϯμ͚͕ඞཁʹͳΔ͚ΕͲ
Slide 80
Slide 80 text
·ͩ·ͩΓͳ͍͜ͱ (͕Βͳ͍͚͔ͩ) • ΤϯδχΞϦϯάͱͯ͠ͷΈԽ • PerlͰݴ͏CPANΈ͍ͨͳͭ • ษڧձɺϫʔΫγϣοϓ • ςετڥ
Slide 81
Slide 81 text
ϋʔυΣΞͳਓͱग़ձ͍͍ͨʂ • WebͷਓͱΑ͘ձ͏͚ΕͲɺ͜͏͍͏͜ ͱ͍ͬͯΔਓͳ͔ͳ͔ग़ձΘͳ͍ • ͍ͨΒհͯ͠ཉ͍͠͠ɺ͋ͳ͕ͨͦ͏Ͱ ͋Ε༑ͩͪʹͳ͍ͬͯͩ͘͞
Slide 82
Slide 82 text
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠
Slide 83
Slide 83 text
࣭ٙԠ ͕࣌ؒ༨ͬͨΒΔ༻
Slide 84
Slide 84 text
ແઢԽ
Slide 85
Slide 85 text
γϦΞϧΛແઢԽ • XBee/XBee WiFiͦͷଞແઢLANϞδϡʔϧ • γϦΞϧΛZigBeeWiFiʹมͰ͖Δ • ٕదʹҙ • ւ֎Ϟδϡʔϧి๏ͰҾ͔͔ͬΔͱ ͔͋Δ
Slide 86
Slide 86 text
RasPi Cam
Slide 87
Slide 87 text
Raspberry Piઐ༻Χϝϥ • খ͍͍ͦͦ҆͜͜͞͠(2000ԁ) • ͨͩ͠RasPiઐ༻ • RasPiΛϥΠϒΧϝϥͱ͔ʹग़དྷΔ • ϔϦͰ͍·ͨ͠ʢখ͍͞͠USB৯Θͳ͍