Cov txheej txheem:

Siv Cov Txheej Txheem Ua Yeeb Yam Zoo Tshaj Plaws los Tswj Cov Ntaub Ntawv Zoo Tshaj WiFi: 4 Cov Kauj Ruam (nrog Duab)
Siv Cov Txheej Txheem Ua Yeeb Yam Zoo Tshaj Plaws los Tswj Cov Ntaub Ntawv Zoo Tshaj WiFi: 4 Cov Kauj Ruam (nrog Duab)

Video: Siv Cov Txheej Txheem Ua Yeeb Yam Zoo Tshaj Plaws los Tswj Cov Ntaub Ntawv Zoo Tshaj WiFi: 4 Cov Kauj Ruam (nrog Duab)

Video: Siv Cov Txheej Txheem Ua Yeeb Yam Zoo Tshaj Plaws los Tswj Cov Ntaub Ntawv Zoo Tshaj WiFi: 4 Cov Kauj Ruam (nrog Duab)
Video: Tshuaj theem vim li cas thiaj tau nqi ?/ Siv kho mob dab tsi?/paris polyphylla использовать для? 2024, Hlis ntuj nqeg
Anonim
Siv Cov Txheej Txheem Ua Yeeb Yam Zoo Tshaj Plaws los Tswj Cov Ntaub Ntawv Zoo Tshaj WiFi
Siv Cov Txheej Txheem Ua Yeeb Yam Zoo Tshaj Plaws los Tswj Cov Ntaub Ntawv Zoo Tshaj WiFi
Siv Cov Txheej Txheem Ua Yeeb Yam Zoo Tshaj Plaws los Tswj Cov Ntaub Ntawv Zoo Tshaj WiFi
Siv Cov Txheej Txheem Ua Yeeb Yam Zoo Tshaj Plaws los Tswj Cov Ntaub Ntawv Zoo Tshaj WiFi

Koj puas tau xav sim sim tswj lub cev? Ua tej yam txav nrog nthwv dej ntawm koj txhais tes? Tswj suab paj nruag nrog kev sib tw ntawm koj lub dab teg? Cov lus qhia no yuav qhia koj li cas!

Complex Arts Sensor Board (complexarts.net) yog lub microcontroller ntau yam raws li ESP32 WROOM. Nws muaj tag nrho cov yam ntxwv ntawm ESP32 lub platform, suav nrog WiFi hauv thiab Bluetooth, thiab 23 teeb tsa GPIO pins. Lub Rooj Tswjhwm Saib Xyuas Sensor tseem muaj qhov BNO_085 IMU - 9 DOF cov txheej txheem ua haujlwm uas ua haujlwm onboard sensor fusion thiab quaternion equation, muab kev qhia meej meej tshaj plaws, lub ntiajteb txawj nqus vector, thiab cov ntaub ntawv nrawm nrawm. Lub Rooj Tswjhwm Saib Xyuas Sensor tuaj yeem ua haujlwm nrog Arduino, MicroPython, lossis ESP-IDF, tab sis rau zaj lus qhia no peb yuav ua lub rooj tsav xwm nrog Arduino IDE. Nws yog ib qho tseem ceeb kom nco ntsoov tias ESP32 cov qauv tsis yog ib txwm muaj peev xwm ua tau los ntawm Arduino IDE, tab sis ua kom qhov ntawd ua tau yooj yim heev; muaj kev qhia zoo ntawm no: https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/ uas yuav siv li 2 feeb los ua kom tiav. Qhov kawg ntawm kev teeb tsa peb xav tau yog tus tsav tsheb rau USB-rau-UART nti ntawm Sensor Board, uas tuaj yeem pom ntawm no: https://www.silabs.com/products/development-tools/software/usb-to -uart-choj-vcp-tsav tsheb. Tsuas yog xaiv koj li OS thiab teeb tsa, uas yuav siv sijhawm li 2 feeb ntxiv. Thaum qhov no ua tiav, peb zoo mus!

[Zaj lus qhia no tsis xav tias muaj kev paub zoo nrog Arduino lossis Pure Data, txawm li cas los xij nws yuav tsis npog lawv cov kev teeb tsa. Arduino tuaj yeem pom ntawm aduino.cc. Cov ntaub ntawv ntshiab tuaj yeem nrhiav tau ntawm puredata.info. Ob qhov chaw tau yooj yim-rau-ua raws cov lus qhia rau kev teeb tsa thiab teeb tsa.]

Tsis tas li… cov ntsiab lus tau hais hauv qhov kev qhia no, xws li teeb tsa UDP kev sib txuas, ua haujlwm ESP32 nrog Arduino, thiab yooj yim Ntshiab Cov ntaub ntawv thaj ua tsev - yog cov tsev thaiv uas tuaj yeem thov rau ntau qhov haujlwm, yog li tsis txhob duav ntawm no ib zaug koj tau ua tau txais cov ntsiab lus no!

Khoom siv

1. Txoj Kev Nyuaj Siab Sensor Board

2. Arduino IDE

3. Cov Ntaub Ntawv Ntshiab

Kauj Ruam 1: Txheeb Xyuas Txoj Cai:

Txheeb Xyuas Txoj Cai
Txheeb Xyuas Txoj Cai
Txheeb Xyuas Txoj Cai
Txheeb Xyuas Txoj Cai

Ua ntej, peb yuav saib Arduino code. (Lub hauv paus muaj nyob ntawm https://github.com/ComplexArts/SensorBoardArduino. Nws tau pom zoo tias koj ua raws nrog cov cai thaum peb mus.) Peb xav tau qee lub tsev qiv ntawv, ib qho uas tsis yog lub tsev qiv ntawv Arduino tseem ceeb, yog li koj tej zaum yuav tsum tau nruab nws. Txoj haujlwm no tso siab rau ntawm SparkFun_BNO080_Arduino_Library.h cov ntaub ntawv, yog li yog tias koj tsis muaj qhov ntawd, koj yuav tsum tau mus rau Sketch -> Xws li Lub Tsev Qiv Ntawv -> Tswj Tsev Qiv Ntawv. Ntaus hauv “bno080” thiab lub tsev qiv ntawv hais los saum toj no yuav tshwm sim. Nias nruab.

Lwm peb lub tsev qiv ntawv uas tau siv yuav tsum tuaj nrog Arduino los ntawm lub neej ntawd. Ua ntej, peb yuav siv SPI lub tsev qiv ntawv los sib tham nrog BNO. Nws tseem tuaj yeem siv UART nruab nrab ntawm ESP32 thiab BNO, tab sis txij li SparkFun twb muaj lub tsev qiv ntawv uas siv SPI, peb yuav nrog qhov ntawd. (Ua tsaug, SparkFun!) Xws li cov ntaub ntawv SPI.h yuav tso cai rau peb xaiv tus pin thiab chaw nres nkoj twg peb xav siv rau SPI kev sib txuas lus.

Lub tsev qiv ntawv WiFi muaj cov haujlwm uas tso cai rau peb nkag mus rau lub wireless network. WiFiUDP muaj cov haujlwm uas tso cai rau peb xa thiab txais cov ntaub ntawv hla lub network ntawd. Ob kab tom ntej tau txais peb ntawm lub network - sau koj lub npe network thiab tus password. Ob kab tom qab ntawd hais qhia lub network chaw nyob thiab chaw nres nkoj uas peb xa peb cov ntaub ntawv. Hauv qhov no, peb tsuas yog tshaj tawm, uas txhais tau tias xa nws mus rau txhua tus hauv peb lub network uas tau mloog. Tus lej chaw nres nkoj txiav txim siab leej twg mloog, raws li peb yuav pom me ntsis.

Ob kab tom ntej no tsim cov tswv cuab rau lawv cov chav kawm sib xws yog li peb tuaj yeem nkag mus tau yooj yim rau lawv cov haujlwm tom qab.

Tom ntej no, peb muab cov pins tsim nyog ntawm ESP rau lawv cov koob ntawm BNO.

Tam sim no peb teeb SPI tus tswv cuab hauv chav kawm, tseem teeb tsa SPI chaw nres nkoj nrawm.

Thaum kawg peb tau mus rau teeb tsa muaj nuj nqi. Ntawm no, peb yuav pib qhov chaw nres nkoj txuas ntxiv yog li peb tuaj yeem saib xyuas peb cov zis li ntawd yog tias peb xav tau. Tom qab ntawd peb pib WiFi. Daim ntawv ceeb toom tias txoj haujlwm tos rau WiFi txuas ua ntej mus. Thaum WiFi txuas nrog, peb pib UDP kev sib txuas, tom qab ntawv luam peb lub npe network thiab peb tus IP chaw nyob mus rau tus saib xyuas. Tom qab ntawd peb pib SPI chaw nres nkoj thiab tshawb xyuas kev sib txuas lus ntawm ESP thiab BNO. Thaum kawg, peb hu txoj haujlwm "enableRotationVector (50);" raws li peb tsuas yog siv kev sib hloov vector rau zaj lus qhia no.

Kauj Ruam 2: Qhov seem ntawm Txoj Cai…

Qhov seem ntawm Txoj Cai…
Qhov seem ntawm Txoj Cai…

Ua ntej peb mus rau lub voj loj (), peb muaj txoj haujlwm hu ua "mapFloat."

Nov yog txoj haujlwm tshwj xeeb uas peb tau ntxiv los txhawm rau ua daim duab qhia chaw, lossis ntsuas, qhov txiaj ntsig rau lwm qhov txiaj ntsig. Kev ua daim ntawv qhia ua haujlwm hauv Arduino tsuas tso cai ua daim phiaj, tab sis tag nrho peb qhov txiaj ntsig thawj zaug los ntawm BNO yuav nyob nruab nrab ntawm -1 thiab 1, yog li peb yuav tsum ntsuas lawv tus kheej rau qhov txiaj ntsig uas peb xav tau tiag tiag. Tsis muaj kev txhawj xeeb, txawm hais tias - ntawm no yog cov haujlwm yooj yim los ua qhov ntawd xwb:

Tam sim no peb los rau lub voj loj (). Thawj qhov koj yuav pom yog lwm txoj hauv kev thaiv, zoo li qhov uas ua rau txoj haujlwm tos rau kev sib txuas hauv network. Qhov no nres kom txog thaum muaj cov ntaub ntawv los ntawm BNO. Thaum peb pib tau txais cov ntaub ntawv ntawd, peb muab cov txiaj ntsig quaternion nkag mus rau qhov hloov pauv ntawm cov ntsiab lus thiab luam tawm cov ntaub ntawv ntawd mus rau tus saib xyuas.

Tam sim no peb yuav tsum ua daim ntawv qhia cov txiaj ntsig.

[Ib lo lus hais txog UDP kev sib txuas lus: cov ntaub ntawv raug xa mus hla UDP hauv 8-pob ntawv, lossis tus nqi los ntawm 0-255. Txhua yam dhau 255 yuav raug thawb rau pob ntawv tom ntej, ntxiv rau nws tus nqi. Yog li ntawd, peb yuav tsum ua kom ntseeg tau tias tsis muaj tus nqi ntau dua 255.]

Raws li tau hais ua ntej, peb muaj cov txiaj ntsig khoom nyob hauv thaj tsam ntawm -1 -1. Qhov no tsis muab ntau yam rau peb ua haujlwm nrog, txij li txhua yam hauv qab 0 yuav raug txiav tawm (lossis pom zoo li 0) thiab peb ua tsis tau ib tuj nrog qhov tseem ceeb ntawm 0 -1. Peb thawj zaug yuav tsum tshaj tawm qhov hloov pauv tshiab los tuav peb tus nqi mapped, tom qab ntawd peb coj qhov kev hloov pauv thawj zaug thiab daim ntawv qhia nws los ntawm -1 -1 txog 0 -255, muab qhov txiaj ntsig rau peb qhov sib txawv tshiab hu ua Nx.

Tam sim no peb muaj peb cov ntaub ntawv khij, peb tuaj yeem tso peb pob ntawv ua ke. Txhawm rau ua qhov ntawd, peb yuav tsum tshaj tawm qhov tsis rau pob ntawv cov ntaub ntawv, muab nws qhov loj me ntawm [50] kom paub tseeb tias txhua cov ntaub ntawv yuav haum. Peb tom qab ntawd pib pob ntawv nrog qhov chaw nyob thiab chaw nres nkoj peb tau teev tseg saum toj no, sau peb qhov tsis thiab 3 qhov txiaj ntsig mus rau pob ntawv, tom qab ntawv kawg pob ntawv.

Thaum kawg, peb luam peb daim ntawv qhia chaw tswj hwm mus rau tus saib xyuas. Tam sim no tus lej Arduino ua tiav! Nyem qhov chaws mus rau Lub Rooj Tswj Xyuas Sensor thiab tshuaj xyuas lub koos pij tawj kom paub tseeb tias txhua yam ua haujlwm raws li qhov xav tau. Koj yuav tsum pom qhov quaternion qhov tseem ceeb nrog rau qhov ntsuas qhov tseem ceeb.

Kauj Ruam 3: Txuas Nrog Cov Ntaub Ntawv Ntshiab…

Txuas Nrog Cov Ntaub Ntawv Ntshiab…
Txuas Nrog Cov Ntaub Ntawv Ntshiab…

Tam sim no rau Cov Ntaub Ntawv Ntshiab! Qhib Cov Ntaub Ntawv Ntshiab thiab pib thaj tshiab (ctrl n). Lub thaj uas peb yuav tsim yog yooj yim heev, tsuas muaj xya yam khoom. Thawj qhov peb yuav tsim yog qhov khoom [netreceive]. Nov yog qhob cij thiab butter ntawm peb thaj, tuav tag nrho UDP kev sib txuas lus. Daim ntawv ceeb toom muaj peb qhov kev sib cav rau qhov [netreceive] khoom; the -u qhia meej UDP, -b qhia txog binary, thiab 7401 yog qhov tseeb qhov chaw nres nkoj uas peb tau mloog. Koj tseem tuaj yeem xa "mloog 7401" cov lus rau [netreceive] txhawm rau qhia koj qhov chaw nres nkoj.

Thaum peb muaj cov ntaub ntawv nkag los, peb yuav tsum tau ntim nws. Yog tias peb txuas cov khoom [luam tawm] mus rau [netrecieve], peb tuaj yeem pom cov ntaub ntawv pib los rau peb raws li cov lej, tab sis peb xav cais cov lej ntawd thiab siv txhua tus rau qee yam sib txawv. Piv txwv li, koj yuav xav siv X-axis tig los tswj lub suab ntawm tus oscillator, thiab Y-axis rau ntim, lossis ib qho ntawm lwm qhov muaj peev xwm. Txhawm rau ua qhov ntawd, cov ntaub ntawv xa mus los ntawm qhov [unpack] cov khoom uas muaj peb ntab (f f) yog nws cov lus sib cav.

Tam sim no koj nyob deb, lub ntiaj teb yog koj cov oyster! Koj muaj lub wireless tswj uas koj tuaj yeem siv los tswj txhua yam koj xav tau hauv Cov Ntaub Ntawv Ntshiab. Tab sis nres! Dhau li ntawm Kev Sib Hloov Vector, sim siv lub ntsuas hluav taws xob lossis lub ntsuas hluav taws xob. Sim siv cov haujlwm tshwj xeeb ntawm BNO xws li "ob npaug kais" lossis "co". Txhua yam nws siv yog khawb me ntsis hauv cov neeg siv phau ntawv (lossis Cov Lus Qhia tom ntej…).

Kauj ruam 4:

Dab tsi peb tau ua tiav saum toj no yog teeb tsa kev sib txuas lus ntawm Sensor Board thiab Cov Ntaub Ntawv Ntshiab. Yog tias koj xav pib muaj kev lom zem ntau dua, nqes koj cov ntaub ntawv tawm mus rau qee qhov oscillators! Ua si nrog kev tswj ntim! Tej zaum tswj qee lub sijhawm ncua lossis rov hais dua! lub ntiaj teb yog koj tus oyster!

Pom zoo: