Cov txheej txheem:

Alexa Lub Suab Tswj Raspberry Pi Drone Nrog IoT thiab AWS: 6 Cov Kauj Ruam (nrog Duab)
Alexa Lub Suab Tswj Raspberry Pi Drone Nrog IoT thiab AWS: 6 Cov Kauj Ruam (nrog Duab)

Video: Alexa Lub Suab Tswj Raspberry Pi Drone Nrog IoT thiab AWS: 6 Cov Kauj Ruam (nrog Duab)

Video: Alexa Lub Suab Tswj Raspberry Pi Drone Nrog IoT thiab AWS: 6 Cov Kauj Ruam (nrog Duab)
Video: 10 самых АТМОСФЕРНЫХ мест Дагестана. БОЛЬШОЙ ВЫПУСК #Дагестан #ПутешествиеПоДагестану 2024, Hlis ntuj nqeg
Anonim
Image
Image
Alexa Lub Suab Tswj Raspberry Pi Drone Nrog IoT thiab AWS
Alexa Lub Suab Tswj Raspberry Pi Drone Nrog IoT thiab AWS
Alexa Lub Suab Tswj Raspberry Pi Drone Nrog IoT thiab AWS
Alexa Lub Suab Tswj Raspberry Pi Drone Nrog IoT thiab AWS

Nyob zoo! Kuv lub npe yog Armaan. Kuv yog menyuam yaus 13 xyoos los ntawm Massachusetts. Cov ntawv qhia no qhia, raws li koj tuaj yeem pom los ntawm lub npe, yuav tsim Raspberry Pi Drone li cas. Cov qauv no qhia pom tias drones tab tom hloov pauv thiab qhov loj npaum li cas lawv yuav ua si yav tom ntej. Kuv tuaj yeem pom kuv tus kheej sawv hauv 10 xyoo thiab nug lub drone kom tau noj tshais rau kuv. Lub drone siv Amazon Alexa, Amazon Web Services, IoT (Internet of Things), thiab qhov tseem ceeb tshaj yog Raspberry Pi kom khiav. Nws yog lub ntsiab lus los qhia thiab qhia txog drones thiab seb lawv txhim kho txhua hnub li cas. Vam tias koj ua tiav thiab kawm paub txog drones hauv tus txheej txheem. Hmoov zoo thiab ua tsaug rau kev nyeem. -Armaan

Khoom siv

Txhawm rau tsim tus qauv muaj ntau yam khoom siv kho vajtse thiab software xav tau. Kuv siv kev qhia online los ntawm The Drone Dojo los tsim lub drone thiab suav nrog cov thev naus laus zis uas tau teev tseg.

Drone Qhov Npe

Yuav tsum tau Software:

  • Amazon Web Services
  • Lub Laptop
  • Lub Hom Phiaj Planer Software
  • Balena Etcher
  • MicroSD Card nrog Raspbian File pom ntawm no
  • Amazon Alexa, lub cev lossis virtual

Kauj Ruam 1: Sib Sau thiab Nkag Siab Qhov Chaw

Sib Sau thiab Nkag Siab Qhov Chaw
Sib Sau thiab Nkag Siab Qhov Chaw

Txhua feem uas tau hais hauv cov npe khoom yog qhov tsim nyog, thiab yog li nkag siab meej ntawm txhua feem. Koj tuaj yeem pom cov ntu hauv online thiab sau ua ke ib zaug, nyeem txuas ntxiv. Daim ntawv teev npe los ntawm The Drone Dojo kom nkag siab tag nrho ntawm cov ntu tuaj yeem pom ntawm no. Kev piav qhia 4-feeb ntawm kuv tus youtube channel tuaj yeem pom ntawm no. Thaum nws los txog rau drones tsuas yog ib feem, txawm li cas los xij tib neeg feem ntau xav, tsis yog lub cav thiab cov kiv cua. Hauv qab no yog lub hom phiaj yooj yim ntawm txhua ntu.

Raspberry Pi nrog Emlid Navio2

Ib feem no zoo nkauj npaum li lub hauv paus txheej txheem thiab lub ntsiab lus tseem ceeb ntawm lub drone. Raspberry Pi ua zoo li CPU ntawm lub khoos phis tawj uas xa cov lus txib mus rau Navio2 kom ua los ntawm PWM (Pulse Width Modulation Signals) mus rau lwm qhov ntawm lub drone.

2. ESC's (Cov Tswj Hluav Taws Xob)

Cov xim daj no pom nyob hauv qab tus ncej. Lawv yog 4 txuas rau Navio, ib qho rau txhua lub cav. Thaum tau txais PWM cov cim, lawv tig lub cav thiab pib ya.

3. Tsav tsheb

Cov motors tsis xav tau kev piav qhia ntau dhau vim tias tej zaum koj yuav paub nrog lawv. Lawv tig thiab tig cov kiv cua los tsim lub zog.

4. Cov kiv cua

Cov kiv cua tsim lub zog rau lub drone ya. Lawv tig mus rau tib qho kev taw qhia raws li lub cav kom nqa lub tsheb.

5. Lub Roj Teeb thiab Lub Hwj Huam Module

Lub LiPo Roj teeb ua rau tag nrho drone los ntawm tus ncej siv lub zog ntsuas. Nws muab sijhawm li 15-20 feeb ntawm lub sijhawm ya dav hlau thiab ua lub zog siv zog.

6. GPS

GPS sib txuas lus nrog lub hnub qub los txiav txim siab lub drone txoj haujlwm. Nws txiav txim siab qhov siab, latitude, thiab ntev. Nws tuaj yeem siv rau Geofencing, cov ntsiab lus, thiab tseem txav mus rau qee txoj haujlwm lossis cov lus qhia.

7. Telemetry Module

Lub xov tooj cua sib txuas txuas peb lub drone mus rau qhov chaw tswj chaw hauv av, hauv peb cov ntaub ntawv Lub Hom Phiaj Npaj, kom raug saib xyuas.

8. Tus Tswj RC thiab Tus Qauv nrog rau PPM Encoder

Tus Tswj Xyuas RC siv lub xov tooj cua los xa cov cim thiab cov lus txib rau RC Module los sim tsav lub dav hlau. PPM Encoder txhais cov cim no rau Navio + RPI los ua thiab ua.

9. Tus ncej

Cov kab liab thiab dawb no ua raws lub hauv paus lossis lub hauv paus rau lwm qhov kom muab tso rau. Lub thav duab yog aerodynamic thiab lub teeb, yog li ntawd zoo meej rau peb cov drone tsim.

Tam sim no nrog kev paub ntawm txhua feem, peb thaum kawg tuaj yeem tsim lub drone! Mus rau kauj ruam tom ntej!

Kauj Ruam 2: Sib dhos Drone

Sib dhos Drone
Sib dhos Drone

Cov kauj ruam no yog qhov nyuaj tshaj plaws ntawm kev siv lub cev. Kuv pom zoo kom muaj lwm tus neeg los pab lossis sim siv tes pab hauv cov npe khoom. Cov txheej txheem ntev dhau los ua pov thawj ntawm no, yog li kuv yuav muab lwm qhov txuas uas kuv siv los ntawm The Drone Dojo.

Tsim lub Raspberry Pi Drone

Ib zaug ntxiv, raws li kuv yuav tsis nkag mus rau ntau yam ntxaws, Kuv yuav cia li hais qhia qhov pib ntawm txhua qib.

1. Npaj Koj Cov Khoom Siv - Sau peb cov ntaub ntawv thiab xyuas kom lawv nkag tau yooj yim

2. Npaj Koj Tsim - Npaj koj qhov chaw ntawm tus ncej txhawm rau ua qauv txheej txheem ntawm yam koj yuav tsim

3. Soldering Work - Nov yog txoj haujlwm uas nyuaj me ntsis ua ib leeg. Koj yuav tsum tau muab cov khoom sib txuas mos txwv kub uas tuaj nrog lub cav mus rau ESC. Tom ntej no, koj yuav tsum ua ntu ntu hauv qab ntawm tus thav duab thiab muab lub ESC txuas rau hauv qab kab lossis Lub Rooj Sib Tham Fais Fab. Lub Roj Teeb Module tseem yuav muab muag rau ntawm Pawg Tswj Fais Fab

4. Teeb Ncej - Koj yuav tsum ntsia hlau rau sab saum toj ntawm tus ncej nrog rau caj npab. Tom qab ntawd koj tuaj yeem txuas Raspberry Pi nyob rau sab saum toj txhua txoj kev uas koj xav tau. (Kuv siv cov kab xev). Tom qab ntawd koj tuaj yeem ruaj ntseg ESC rau caj npab nrog zip-ties. Tam sim no peb yuav luag tiav.

5. Txhim Kho Tus Tswj Xyuas RC rau Tus Txais - Sim ua raws cov lus qhia hauv daim ntawv teev npe saum toj no txhawm rau txhawm rau Tswj Tus Tswj Xyuas RC siv ESC.

6. Qhov kawg ntawm Qhov Cuam Tshuam - Cov kab xev lossis cov hlua khi ntawm cov qauv siv xov tooj cua rau ntawm tus ncej. Ciav kab xev PPM Encoder rau ntawm caj npab ib yam nkaus. Tam sim no koj tuaj yeem xaim ESC's thiab PPM Encoder rau Navio.

7. GPS Mount + Roj teeb - Sib dhos GPS Mount nrog ntau yam ntsia hlau thiab daim. Siv zip-ties, txuas lub GPS rau Tus Qauv. Kuv tsis tas yuav siv GPS Mount vim nws qhov tsis yooj yim, tab sis nws nyob ntawm koj. Tom ntej no, koj tuaj yeem tso lub roj teeb nruab nrab ntawm Lub Hwj Chim Dist. Pawg Thawj Coj. Kuv strapped thiab kaw rau ntawm lub zog module rau tus ncej ib yam. Tam sim no koj kho vajtse tau teeb tsa zoo nkauj heev. Tam sim no rau feem peb tau tos!

8. Txhim kho lub Propellers !!! - Koj tuaj yeem nruj cov kiv cua siv daim ntawv qhia hauv daim ntawv teev npe. Tom qab ntawd koj tuaj yeem ntsaws ESC rau lub cav thiab peb thaum kawg ua tiav lub drone.

Software txuas ntxiv mus, yog li ntawd mus!

Kauj Ruam 3: Kho Kho Raspberry Pi thiab GCS (Lub Hom Phiaj Npaj)

Configuring Raspberry Pi thiab GCS (Lub Hom Phiaj Npaj)
Configuring Raspberry Pi thiab GCS (Lub Hom Phiaj Npaj)

Ib zaug ntxiv, koj tuaj yeem pom cov lus qhia ntxaws ntxiv hauv daim ntawv teev npe los ntawm cov kauj ruam kawg. Txawm li cas los xij, koj yuav paub yuav teeb tsa RasPi li cas. Tab sis lub sijhawm no, peb tab tom ua nws lub taub hau. Siv Balena Etcher los hlawv OS los ntawm Navio OS lub vev xaib rau hauv daim npav MicroSD. Thaum nws ntsaws rau hauv koj lub khoos phis tawj, nkag mus rau hauv wpa tus thov siv notepad ++. Tom qab ntawd, nkag mus rau ssid thiab tus password rau Raspberry Pi txuas rau koj li WiFi. Tom qab ntawd koj yuav tsum ntxiv cov ntaub ntawv hu ua SSH. Qhov no tuaj yeem dhau los ntawm kab hais kom ua lossis lwm txoj hauv kev. Tam sim no peb tuaj yeem SSH. Koj tuaj yeem siv qhov hais kom ua sai lossis Putty. Kuv siv cov lus txib tam sim thiab ntaus "ssh pi@navio" txhawm rau txuas hauv kuv rooj plaub, lossis koj tuaj yeem pom tus IP chaw nyob thiab ssh li ntawd. Thaum txuas, siv cov vis dis aus no los teeb tsa thiab teeb tsa Navio. Txhawm rau teeb tsa lub xov tooj cua koj yuav tsum xub ua qhov hloov pauv ntawm Raspberry Pi. Ua raws qhov no txhawm rau hloov kho thiab sim txuas rau Lub Hom Phiaj Npaj. Yog tias kev siv xov tooj cua tsis ua haujlwm, koj tuaj yeem thim qhov kev hloov pauv thiab txuas nrog siv UDB txuas los ntawm kev nkag mus rau koj li GCS (Chaw Tswj Chaw Hauv av xws li lub khoos phis tawj) IP. Thaum txuas nrog Lub Hom Phiaj Npaj, koj tuaj yeem siv teeb tsa tus tsim kom ntsuas txhua qhov ntawm lub drone. Yog tias koj xav tau kev pab xa rov mus rau daim ntawv teev npe. Feem ntau, thaum twg koj teeb tsa, yuav luag ib txwm ua yuam kev. Kev daws teeb meem yog ib qhov loj tshaj ntawm txoj haujlwm no. Kuv tsis tuaj yeem pab koj nyob ntawd vim kuv tsis paub txog koj qhov ua yuam kev, tab sis feem ntau yuam kev tuaj yeem kho nrog kev pab los ntawm internet. Tom qab txhua yam npaj txhij, tom qab ntawd lub drone tau npaj los ya! Koj tuaj yeem teeb tsa koj tus tswj hwm RC thiab hom davhlau ntawm Lub Hom Phiaj Npaj. Sim tuav tus pas sab laug mus rau hauv qab-sab xis rau tsib vib nas this los tuav lub drone. Kuv tsis hais kom ya mus yam tsis tau saib kev qhia vim tias lub drone tsis yooj yim thiab tawg yooj yim. Rau kuv, thawj zaug uas kuv ya nws, kuv tsoo GPS Mount thiab qee lub cav. Yog tias koj tsis xav tau kev tswj lub suab, ces koj tuaj yeem nres ntawm no. Txhawm rau kawm paub txog AWS thiab kev tsim lub drone txuas ntxiv!

Kauj Ruam 4: Ua lub Drone kom ya nrog nab hab sej

Kev ua haujlwm Drone kom ya nrog nab hab sej
Kev ua haujlwm Drone kom ya nrog nab hab sej

Ua ntej nkag mus rau AWS, peb yuav tsum xub nkag siab tias yuav ua haujlwm li cas lub drone kom ya. Tom qab pib teeb tsa, ua ke tswj lub suab yuav tsum tsis txhob nyuaj. Thawj qhov uas peb tuaj yeem sim ua kom nkag siab txog nws yog ua kom yooj yim nqa mus thiab thaj av. Tom qab teeb tsa Raspberry Pi, peb tuaj yeem SSH rau hauv nws dua. Koj tuaj yeem saib daim ntawv teev npe dua lossis ua raws kuv cov lus qhia.

1. Ua ntej cia peb rub ArduPilot Source Code hauv phau ntawv teev npe ntawm Raspberry Pi

mkdir swb

Tom qab ntawd, tau txais cov ntaub ntawv los ntawm GitHub siv git clone

git clone -b Copter -3.6.11

Tam sim no, wb mus rau /src /ardupilot

cd csy

cd ardupilot

Tam sim no, cia pib ua cov ntaub ntawv los

git submodule hloov tshiab --init --recursive

2. Ntxiv mus, peb yuav tsum suav sau cov firmware ntawm Raspberry Pi

Nco ntsoov mus rau/src/ardupilot/nrog cd ua ntej ua cov kauj ruam tom ntej

Tom qab ntawd txhawm rau teeb tsa tshwj xeeb rau Navio siv

./waf teeb tsa -board = navio2

Tom qab ntawd koj tuaj yeem suav nrog

./waf --targets bin/arducopter

3. Tam sim no peb tuaj yeem teeb tsa qhov chaws rau Navio

Ua ntej cia taug kev mus rau cov npe raug.

cd/thiab/systemd/system

Tom qab ntawv kho cov ntaub ntawv

sudo vi arducopter.service

Qhov twg nws hais tias ExecStart, ntxig cov hauv qab no hloov qhov uas twb muaj lawm

ExecStart =/bin/sh -c "/home/pi/src/arducopter/build/navio2/bin/arducopter $ {ARDUPILOT_OPTS}"

Tam sim no, txhawm rau muab qhov chaws tso rau hauv kev ua haujlwm, peb tuaj yeem siv

sudo systemctl daemon-reload

Tom qab ntawd peb tuaj yeem rov pib dua nrog

sudo systemctl rov pib dua arducopter

Nrog cov kauj ruam kawg, thaum kawg peb tau teeb tsa ArduPilot ntawm peb lub drone

4. Txhim kho DroneKit

DroneKit yog software uas peb yuav siv los ua haujlwm rau drone kom ya. Txhawm rau nkag siab qee cov cai koj tuaj yeem nrhiav cov ntaub ntawv ntawm no. Ua ntej peb yuav tsum teeb tsa pob ntawm peb lub drone ua ntej sau tsab ntawv.

Peb tuaj yeem nruab pob sej nrog

pip nruab dronekit == 2.9.1

Qhov no yuav, lossis yuav tsis yog qhov tshiab tshaj plaws, tab sis nws yog qhov kuv tau siv yog li kuv tuaj yeem pab daws teeb meem.

Txhawm rau txheeb xyuas yog tias teeb tsa, peb tuaj yeem ua a

pib khov | grep dronekit cov

Tam sim no peb thaum kawg tau npaj los ua peb thawj tsab ntawv nab nab

5. takeoff_and_land.py

CEEB TOOM! Kuv hais kom tsim kev nkag siab yooj yim ntawm nab, yog li koj tuaj yeem kawm thiab nkag siab cov cai. Yog koj xav sau qhov program koj tus kheej ua raws daim vis dis aus no.

## Thawj zaug tsis txhob tsim cov npe khaws cov cai no

cd dk ## Yog tias koj xav ua nws koj tus kheej ces siv vi takeoff_and_land.py ## los tsim qhov program

Txwv tsis pub, koj tuaj yeem saib lossis siv cov ntawv txuas nrog thiab siv cov ntaub ntawv xa tawm raws tu qauv. Peb tuaj yeem sim qhov program no tom qab. Ua ntej qhia meej tias nws yog cov ntaub ntawv nab nab peb yuav tsum siv

chmod +x takeoff_and_land.py

Tom qab ntawd, sim siv cov cai hauv qab no los khiav

nab hab sej takeoff_and_land.py -txuas 127.0.0.1:14550

Thawj zaug nws tsis ua haujlwm rau kuv ib yam. Yog tias muaj qhov txuas txuas sijhawm, tom qab ntawd tsis txhob txhawj xeeb muaj qee yam uas koj tuaj yeem ua. Qhib lwm qhov sai thiab ssh. Koj tuaj yeem sim txhim kho qee yam hu ua mavproxy thiab sim ua nws. Tom qab ntawd, koj tuaj yeem khiav ob qho tib si ib txhij. Qhov no yuav tsum pab txuas lub drone. Thaum qhov ntawd ua tiav, Kuv muaj kev sib tw rau koj. Sim xam seb lwm txoj haujlwm twg (set_velocity_body.py) ua thiab yuav ua li cas thiaj ua haujlwm. Yog koj ua, txoj haujlwm zoo.

6.; Lwm!

Tam sim no peb tuaj yeem siv qhov kev paub no los ua peb lub drone tswj lub suab. Alexa drone tswj siv ntau yam ntawm cov yam ntxwv no thiab ntau ntxiv. Hmoov zoo thiab mus ntxiv!

Kauj Ruam 5: Siv Amazon Alexa thiab Amazon Cov Kev Pabcuam Hauv Lub Vev Xaib los Ua Ke Tswj Lub Suab

Siv Amazon Alexa thiab Amazon Lub Vev Xaib Kev Pabcuam los Ua Ke Tswj Lub Suab
Siv Amazon Alexa thiab Amazon Lub Vev Xaib Kev Pabcuam los Ua Ke Tswj Lub Suab
Siv Amazon Alexa thiab Amazon Lub Vev Xaib Kev Pabcuam los Ua Ke Tswj Lub Suab
Siv Amazon Alexa thiab Amazon Lub Vev Xaib Kev Pabcuam los Ua Ke Tswj Lub Suab

Cov kauj ruam no yog ib qho ntawm cov ntaub ntawv tsawg dua. Qhov no txhais tau tias nws yuav nyuaj rau daws teeb meem. Tsuas yog kom nws ua haujlwm coj kuv li ib hlis, tej zaum ntau dua. Qhov tseem ceeb tshaj plaws ntawm no yog ua siab ntev. Cov yam ntxwv no, yog siv hauv lub neej tiag tiag, tuaj yeem hloov pauv lub neej. Koj tsuas tuaj yeem qhia Alexa kom tau txais koj cov khoom noj rau koj es tsis txhob mus koj tus kheej. Xav txog qhov ntawd! Yog li tsis muaj ado ntxiv peb nkag mus rau hauv nws!

1. Sau npe rau Raspberry Pi ua ib yam ntawm AWS IoT

Txhawm rau siv IoT (Internet ntawm Yam), zoo peb xav tau ib yam. Yog li peb yuav tsum nkag mus rau AWS Console txhawm rau siv AWS IoT ua ntej. Tom qab ntawd mus rau IoT Core. Thaum muaj, koj yuav tsum nyem Tswj thiab tom qab ntawd tsim ib yam. Tom qab ntxiv lub npe, rau txuas, peb xav tau daim ntawv pov thawj. Kuv yuav pom zoo kom nyem rau ib-nias ntawv pov thawj. Tom qab ntawd tom qab pom daim ntawv pov thawj tshuaj xyuas, xyuas kom rub tawm txhua tus thiab txhua qhov tseem ceeb suav nrog hauv paus CA. Tom qab ntawd koj tuaj yeem mus thiab ua tiav qhov kev tsim ntawm qhov khoom. Tom ntej no peb yuav tsum tsim txoj cai. Rov qab tawm mus rau IoT Core. Tom qab ntawd nyem rau ntawm kev nyab xeeb thiab nyem txoj cai. Tom qab ntawd nyem tsim txoj cai. Tom qab ntawd koj tuaj yeem tsim lub npe thiab ntxiv cov peev txheej. Hauv kev nqis tes ua, ntaus iot * thiab ntaus * hauv cov peev txheej thiab ntaus cia kom muaj txiaj ntsig. Tom qab ntawd rov qab mus rau koj li khoom thiab mus rau koj daim ntawv pov thawj. Ib zaug ntawm no, nyem rau cov cai. Tom qab ntawd koj tuaj yeem txuas koj txoj cai rau qhov khoom thiab nws tau teeb tsa tag nrho!

2. Teeb tsa Txoj Cai ntawm Raspberry Pi thiab cuam tshuam nrog IoT

Rau ntu no, koj yuav xav tau SFTP Client (Kuv siv WinSCP) rau kev xa cov ntaub ntawv. Thaum txuas rau peb Raspberry Pi, peb yuav tsum muaj daim ntawv pov thawj tuav ntawm tes. Koj yuav tsum xa cov ntaub ntawv tseem ceeb mus rau Raspberry Pi. Koj kuj tseem yuav tsum nruab lub AWSIoTPythonSDK ntawm Raspberry Pi. Tom qab ntawd nkag mus rau dk phau ntawv teev npe ntawm Raspberry Pi. Koj siv Alexa Drone Tswj cov ntaub ntawv kuv muab rau kev sib txuas lus nrog IoT. Txhawm rau siv cov ntawv no Kuv siv Shell Script rau kev pib. Kuv yuav qhia cov cai hauv qab no vim kuv tsis tuaj yeem rub cov ntawv rau qee qhov laj thawj. Yog tias qhov program tsis khaws cov lus los ntawm AWS IoT thaum sim, tsis txhob txhawj! Qhov no yuav yog kuv qhov txhaum raws li Alexa Drone Tswj Cov Ntaub Ntawv yuav tsis haum koj li. Yog li, txhawm rau kho nws, rov qab mus rau AWS IoT thiab ntaus kawm ntawm lub vaj huam sib luag sab laug. Ua raws li cov lus qhia thiab koj yuav tau rov pib dua. Thov txim txog qhov ntawd. Thaum koj IoT pib ua haujlwm nrog qhov haujlwm ntawm RasPi, koj tuaj yeem sib sau ua ke dronekit code los ntawm Alexa Drone Control file kuv tau muab. Tom qab ntawd, siv Shell Script Kuv tau muab nrog koj daim ntawv pov thawj thiab So API Endpoint los ntawm IoT.

# nres tsab ntawv ntawm errorset -e # Txheeb xyuas seb lub hauv paus CA cov ntaub ntawv muaj nyob, rub tawm yog tias tsis yog [! -f./root-CA.crt]; ces printf "\ nDownloading AWS IoT Root CA daim ntawv pov thawj los ntawm AWS … / n" curl https://www.amazontrust.com/repository/AmazonRoot…>> root-CA.crt fi # nruab AWS Device SDK rau Python yog tias tsis tau teeb tsa os [! -d./aws-iot-device-sdk-python]; then printf "\ nInstalling AWS SDK … / n" git clone https://www.amazontrust.com/repository/AmazonRoot…> pushd aws-iot-device-sdk-python python setup.py install popd fi

# khiav pub/sub qauv app siv daim ntawv pov thawj rub tawm hauv pob

printf "\ n Khiav pub/sub qauv thov … / n" python dk/AlexaDroneControl.py -txuas 127.0.0.1:14550 -e "Koj IoT ARN" -r hauv paus -CA.crt -c PiGroundStation01.cert.pem -k PiGroundStation01.private.key

Qhov no yuav tsis ua haujlwm rau koj txhua tus vim tias cov npe sib txawv. Hloov chaw ntawm cov yuam sij uas kuv siv hloov nrog koj cov npe tseem ceeb thaum koj hloov cov ntaub ntawv. Nco ntsoov tawm dk ua ntej xa cov ntawv! Qhov ntawd yuav tsum yog txhua yam koj yuav tsum ua tam sim no.

3. Tsim koj li Alexa Skill

Cov kauj ruam no zoo li nyuaj dua qhov nws yog. Ua ntej, peb yuav tsum nkag mus rau hauv Alexa Developer console. Tom qab ntawd, tsuas yog ntaus tsim cov txuj ci. Thaum nws nug kom xaiv tus qauv rau koj qhov txuj ci, tsuas yog ntaus kev cai. Thaum nws nug kom xaiv txoj hauv kev, ntaus qhov muab koj tus kheej. Koj tuaj yeem sau nws txhua yam koj xav tau. Tsis xav tau tus qauv, yog li xaiv pib los ntawm kos. Tom ntej, tom qab tsim koj qhov txuj ci, koj yuav tsum tuaj txog ntawm Skill builder screen nrog daim ntawv txheeb xyuas ntawm sab xis. Los ntawm no, peb tuaj yeem pib tsim peb cov txuj ci. Thawj ntawm daim ntawv teev npe yog lub npe thov. Nov yog qhov koj yuav qhia Alexa kom ua rau koj qhov kev txawj ntse. Rau kuv, Kuv tsuas yog muab kuv lub npe hu ua drone. Tam sim no peb tuaj yeem mus rau peb lub siab nyiam, hais lus, thiab qhov qhib. Ntawm no, koj tuaj yeem ua cov lus txib rau lub drone xws li nce 1 meter lossis mus rau sab xis lossis nqes. Kuv tsuas yog ua haujlwm tiag tiag nrog ib 'meter' rau tam sim no. Koj tuaj yeem nyem JSON Editor nyob hauv qab ntawm lub vaj huam sib luag sab laug. Tom qab ntawd koj tuaj yeem muab cov cai hauv qab no tso rau nws.

Tom qab muab cov cai tso rau hauv JSON Editor, koj tuaj yeem nyem rau ntu thib peb ntawm daim ntawv txheeb xyuas thiab nws yuav tsim koj tus qauv sib cuam tshuam rau koj. Nrog cov kauj ruam no, koj yuav ua tiav rau tam sim no. Koj tuaj yeem tso qhov kawg ntawm qhov khoob rau tam sim no!

Kauj Ruam 4: Tsim Koj Li Lambda Ua Haujlwm

Tam sim no, cov kauj ruam no yog ib qho uas koj yuav tau txiav txim siab rau koj tus kheej. Kuv yuav qhia koj yuav ua li cas txuas nws mus rau Alexa Skill, tab sis koj yuav tsum tau sau nws tus kheej. Yog li, thawj zaug mus rau AWS kev tswj hwm console. Tom qab ntawd, mus rau Lambda. Tom qab ntawd koj tuaj yeem tsim lub luag haujlwm npe nws txhua yam koj xav tau. Nco ntsoov sau nws los ntawm kos thiab ua lub sijhawm ua haujlwm yam lus programming uas koj xav tau. Kuv siv Node.js. Txhawm rau ntxiv Alexa Skill, ntxiv qhov txhais thiab xaiv Alexa Skills Kit (ASK). Luam koj li Lambda ARN thiab rov qab mus rau Alexa Skill. Tam sim no, mus rau qhov kawg. Koj tuaj yeem muab tshuaj txhuam koj cov ARN, txuag, thiab tsim qauv tshiab. Tom qab ntawd, coj Alexa Skill ID, thiab muab nws tso rau hauv ntu ntu qhov nws nug koj ntawm Lambda. Tom ntej no, nqes mus rau ntawm Lambda thiab nrhiav cov kev teeb tsa yooj yim thiab ua kom ncua sijhawm 10 vib nas this. Tam sim no, nws nyob ntawm koj kom txiav txim siab qhov chaws. Txhawm rau qhia, koj tuaj yeem ua cov vev xaib hauv qab no.

github.com/aws/aws-iot-device-sdk-js

www.hackster.io/veggiebenz/voice-controlle…

thiab koj tuaj yeem siv cov ntawv kuv txuas, tab sis nws tsis tiav thiab yuav tsis ua haujlwm.

/ *** Tswj koj lub APM / Pixhawk quadcopter nrog koj lub suab, siv Amazon Alexa, Lambda, 2lemetry MQTT.*/ var awsIot = require ('aws-iot-device-sdk'); var config = xav tau ("./ config"); var deviceName = "EchoDroneControl"; // cov cuab yeej no yog tus tswj hwm tiag mqtt_config = {"keyPath": config.privateKey, "certPath": config.certificate, "caPath": config.rootCA, "host": config.host, "port": 8883, "clientId": "Lambda-" + deviceName, // + "-Lambda-" + (Hnub Tshiab (). getTime ()), "cheeb tsam": "us-east-1", "debug": tseeb}; var ctx = null; var tus neeg siv = null; // Txoj hauv kev thov tuaj raws hom (LaunchRequest, IntentRequest, thiab lwm yam) JSON lub cev ntawm qhov kev thov raug muab hauv qhov xwm txheej. exports.handler = muaj nuj nqi (xwm txheej, ntsiab lus) {sim {console.log ("event.session.application.applicationId =" + event.session.application.applicationId); ctx = ntsiab lus; yog (event.session.application.applicationId! == app_id) {ctx.fail ("ID daim ntawv thov tsis raug"); } client = awsIot.device (mqtt_config); client.on ("connect", function () {console.log ("Connected to AWS IoT"); // callback ();});

yog (event.session.new) {

onSessionStarted ({requestId: event.request.requestId}, event.session); } yog (event.request.type === "LaunchRequest") {onLaunch (event.request, event.session); } ntxiv yog (event.request.type === "IntentRequest") {onIntent (event.request, event.session); } ntxiv yog (event.request.type === "SessionEndedRequest") {onSessionEnded (event.request, event.session); ctx.succeed (); }} ntes (e) {console.log ("EXCEPTION hauv tus tuav:" + e); ctx.fail ("Kev zam:" + e); }}; /*** Hu thaum pib sib tham. */ muaj nuj nqi onSessionStarted (sessionStartedRequest, session) {console.log ("onSessionStarted requestId =" + sessionStartedRequest.requestId + ", sessionId =" + session.sessionId); }

/**

* Hu thaum tus neeg siv pib ua haujlwm yam tsis tau hais qhia yam lawv xav tau. */ muaj nuj nqi onLaunch (launchRequest, session, callback) {console.log ("onLaunch requestId =" + launchRequest.requestId + ", sessionId =" + session.sessionId); // Xa mus rau koj qhov txuj ci pib. getWelcomeResponse (hu rov qab); } /*** Hu thaum tus neeg siv qhia lub hom phiaj rau qhov txuj ci no. */function onIntent (intentRequest, session) {//, callback) {console.log ("onIntent requestId =" + intentRequest.requestId + ", sessionId =" + session.sessionId); var intent = intentRequest.intent, intentName = intentRequest.intent.name; console.log ("thov kom hlua =" + JSON.stringify (intentRequest)); var callback = tsis muaj; // Xa mus rau koj cov txuj ci kev ua haujlwm yog tias ("GoIntent" === intentName) {doGoIntent (txhob txwm, sib ntsib); } lwm tus yog ("CommandIntent" === intentName) {doCommandIntent (txhob txwm, ntu); } lwm yog ("TurnIntent" === txhob txwm npe) {doTurnIntent (txhob txwm, ntu); } lwm tus yog ("HelpIntent" === intentName) {getWelcomeResponse (); } lwm tus {pov tseg "Lub hom phiaj tsis raug"; }} /*** Hu thaum tus neeg siv xaus kev sib tham. * Tsis hu thaum cov txuj ci rov qab shouldEndSession = muaj tseeb. */ function onSessionEnded (sessionEndedRequest, session) {console.log ("onSessionEnded requestId =" + sessionEndedRequest.requestId + ", sessionId =" + session.sessionId); // Ntxiv kev ntxuav cov txheej txheem ntawm no} // --------------- Cov haujlwm uas tswj cov txuj ci tus cwj pwm -------------------- --- muaj nuj nqi getWelcomeResponse () {// Yog tias peb xav pib qhov kev sib tham kom muaj qee tus cwj pwm peb tuaj yeem ntxiv cov no. var sessionAttributes = {}; var cardTitle = "Zoo Siab Txais Tos"; var speechOutput = "Zoo siab txais tos rau DRONE CONTROL." // TODO: yog drone online lossis offline? Yog tias online, nws puas yog ARMED? var repromptText = "Drone npaj rau kev hais kom ua."; var shouldEndSession = tsis tseeb; ctx.succeed (buildResponse (sessionAttributes, buildSpeechletResponse (cardTitle, speechOutput, repromptText, shouldEndSession))); } /*** ua haujlwm mus rau lub hom phiaj. */ muaj nuj nqi doGoIntent (lub hom phiaj, sib tham, hu rov qab) {// var cardTitle = "Drone GO …"; var repromptText = ""; var sessionAttributes = {}; var shouldEndSession = tsis tseeb; var speechOutput = ""; var kev taw qhia = intent.slots. Direction.value; var nrug = intent.slots. Distance.value; var chav = intent.slots. Unit.value; var validDirections = ["mus rau tom ntej", "mus tom ntej", "rov qab", "rov qab", "sab xis", "sab laug", "nce", "nqis", "ncaj", "ua ntej", "ncaj nraim ua ntej"]; var validUnits = ["ko taw", "ko taw", "meter", "meter", "yard", "yards"]; repromptText = "Qhia rau kuv paub tias yuav mus deb npaum cas thiab mus rau qhov twg."; var fail = tsis tseeb; // validate inputs yog (! (parseInt (nrug)> = 1)) {speechOutput = "Kuv tsis nkag siab qhov deb koj xav kom kuv mus."; fail = tseeb; ctx.succeed (buildResponse (sessionAttributes, buildSpeechletResponse (cardTitle, speechOutput, repromptText, shouldEndSession))); } yog (validDirections.indexOf (kev taw qhia) == -1) {speechOutput = "Kuv tsis nkag siab cov lus qhia uas koj xav kom kuv mus ncig."; fail = tseeb; ctx.succeed (buildResponse (sessionAttributes, buildSpeechletResponse (cardTitle, speechOutput, repromptText, shouldEndSession))); } yog (validUnits.indexOf (chav) == -1) {speechOutput = "Kuv tsis nkag siab chav tsev koj xav kom kuv mus."; fail = tseeb; ctx.succeed (buildResponse (sessionAttributes, buildSpeechletResponse (cardTitle, speechOutput, repromptText, shouldEndSession))); } yog (! ua tsis tiav) {var cardTitle = "Drone mus" + kev qhia + "" + nrug + "" + chav nyob; speechOutput = "Mus" + kev taw qhia + "" + nrug + "" + chav; mqttPublish (kev mob siab rau, sessionAttributes, cardTitle, speechOutput, repromptText, shouldEndSession); }}

muaj nuj nqi doCommandIntent (txhob txwm, sib tham, hu rov qab) {

// var cardTitle = "Drone COMMAND …"; var repromptText = tsis muaj; var sessionAttributes = {}; var shouldEndSession = tsis tseeb; var speechOutput = ""; repromptText = "Qhia rau kuv paub dab tsi yog qhov hais kom ua rau lub drone."; var ua hauj lwm = intent.slots. Task.value; var validTasks = ["tso tawm", "thaj av", "r. t. l.", "tuav", "nyob twj ywm", "nres", "rov qab pib", "rho tawm"]; if (validTasks.indexOf (task) == -1) {speechOutput = "Kuv tsis nkag siab qhov hais kom ua." ctx.succeed (buildResponse (sessionAttributes, buildSpeechletResponse (cardTitle, speechOutput, repromptText, shouldEndSession))); } lwm {var cardTitle = "Ua tiav Drone hais kom ua" + ua haujlwm; speechOutput = "Ua kom tiav cov lus txib" + ua haujlwm; mqttPublish (kev mob siab rau, sessionAttributes, cardTitle, speechOutput, repromptText, shouldEndSession); }}

muaj nuj nqi doTurnIntent (lub hom phiaj, sib ntsib, hu rov qab) {

// var cardTitle = "Drone Tig …"; var repromptText = tsis muaj; var sessionAttributes = {}; var shouldEndSession = tsis tseeb; var speechOutput = ""; repromptText = "Qhia kuv seb koj xav tig lub drone li cas."; var kev taw qhia = intent.slots. Direction.value; var validDirections = ["txoj cai", "sab laug", "puag ncig"]; yog (validDirections.indexOf (kev taw qhia) == -1) {speechOutput = "Kuv tsis nkag siab qhov kev taw qhia ntawm qhov tig."; ctx.succeed (buildResponse (sessionAttributes, buildSpeechletResponse (cardTitle, speechOutput, repromptText, shouldEndSession))); } lwm {var cardTitle = "Drone tig" + kev qhia; speechOutput = "Tig" + kev taw qhia; mqttPublish (kev mob siab rau, sessionAttributes, cardTitle, speechOutput, repromptText, shouldEndSession); }}

muaj nuj nqi mqttPublish (mob siab rau, sessionAttributes, cardTitle, speechOutput, repromptText, shouldEndSession)

{var strIntent = JSON.stringify (txhob txwm); console.log ("mqttPublish: INTENT text =" + strIntent); // client.publish ("ikw1zr46p50f81z/drone/echo", strIntent, cuav); client.publish (config.topic, strIntent, cuav); client.end (); client.on ("kaw", (muaj nuj nqi () {console.log ("MQTT CLIENT CLOSE - xav tias nws ua tiav, ua tiav."); ctx.succeed (buildResponse (sessionAttributes, buildSpeechletResponse (cardTitle, speechOutput, repromptText, shouldEndSession)));)))); Kuv client.on ("yuam kev", (ua haujlwm (yuam kev, tau tso cai) {console.log ("MQTT CLIENT ERROR !!" + yuam kev);})); }

// --------------- Pab uas tsim txhua qhov lus teb -----------------------

muaj nuj nqi buildSpeechletResponse (npe, tso tawm, rov hais dua, yuav tsumEndSession) {rov qab {outputSpeech: {hom: "PlainText", ntawv: tso tawm}, daim npav: {hom: "Yooj yim", npe: npe, ntsiab lus: tso tawm}, rov hais dua: {tso tawm lus: {type: "PlainText", text: repromptText}}, shouldEndSession: shouldEndSession}} function buildResponse (sessionAttributes, speechletResponse) {return {version: "1.0", sessionAttributes: sessionAttributes, teb: speechletResponse}}

Pom zoo: