Cov txheej txheem:

EAL - Kev Lag Luam 4.0 GPS Sau Cov Ntaub Ntawv ntawm Rc Tsheb: 4 Cov Kauj Ruam
EAL - Kev Lag Luam 4.0 GPS Sau Cov Ntaub Ntawv ntawm Rc Tsheb: 4 Cov Kauj Ruam

Video: EAL - Kev Lag Luam 4.0 GPS Sau Cov Ntaub Ntawv ntawm Rc Tsheb: 4 Cov Kauj Ruam

Video: EAL - Kev Lag Luam 4.0 GPS Sau Cov Ntaub Ntawv ntawm Rc Tsheb: 4 Cov Kauj Ruam
Video: Max Verstappen Casually Driving Around In His Aston Martin Valkyrie😬🥶 #f1 #shorts #maxverstappen 2024, Kaum ib hlis
Anonim
EAL - Kev Lag Luam 4.0 GPS Sau Cov Ntaub Ntawv ntawm Rc Tsheb
EAL - Kev Lag Luam 4.0 GPS Sau Cov Ntaub Ntawv ntawm Rc Tsheb
EAL - Kev Lag Luam 4.0 GPS Sau Cov Ntaub Ntawv ntawm Rc Tsheb
EAL - Kev Lag Luam 4.0 GPS Sau Cov Ntaub Ntawv ntawm Rc Tsheb

Hauv Cov Lus Qhia no peb yuav tham txog yuav ua li cas peb teeb tsa GPS module ntawm lub tsheb RC thiab tshaj tawm cov ntaub ntawv sau rau hauv lub vev xaib kom yooj yim saib xyuas. Peb tau ua yav dhau los ua cov lus qhia ntawm yuav ua li cas peb ua peb lub tsheb RC, uas tuaj yeem pom ntawm no. Nov yog siv tib qho kev tsim, txawm hais tias peb tau txiav txim siab txhawm rau txhawm rau ntsuas lub ntsuas hluav taws xob thiab siv GPS module hloov chaw. Hauv txoj haujlwm peb tau teeb tsa lub hauv paus uas muaj cov ntaub ntawv GPS, thiab tsim lub vev xaib uas cov ntaub ntawv tuaj yeem pom ntawm, ib yam li tau siv nws rau hauv daim duab qhia chaw, yog li koj tuaj yeem pom lub tsheb tau nyob qhov twg. Mus ntsib Joerha.dk txhawm rau saib lub vev xaib.

Ntawm daim duab qhia chaw nyob rau sab saum toj, koj tuaj yeem pom cov ntsiab lus ntawm cov thev naus laus zis uas tau siv hauv txoj haujlwm no. Txhawm rau kom tau txais txiaj ntsig zoo tshaj plaws ntawm Cov Lus Qhia no, koj yuav tsum muaj kev lom zem nrog qee qhov, yog tias tsis yog txhua yam thev naus laus zis siv. Nws tau txuas nrog raws li kev siv. Muaj kev nkag siab qis ntawm Github tseem yuav pab tau, raws li peb tau txuas rau peb cov chaw khaws ntaub ntawv github.

Cov npe khoom siv hluav taws xob:

  • Github
  • Raspberry PI/Raspbian

    Nab hab sej

  • Node.js

    • Express.js
    • Sequelize.js
    • MySQL
  • HTML, CSS, JS

    Bootstrap

Kauj ruam 1: Teeb Database

Teeb Database
Teeb Database

Hauv ntu no peb yuav tham txog yuav ua li cas peb tsim cov txheej txheem database uas peb cov ntaub ntawv GPS tau rub los ntawm. Cov ntaub ntawv khaws tseg yog tsim hauv MySQL raws li daim duab saum toj no, qhov uas peb muaj ob lub rooj - "Cov Neeg Siv" thiab "GPSEntries". Hauv cov neeg siv peb muaj "Id" yog peb tus yuam sij thawj. Nws tau siv los ua tus cim tshwj xeeb. "Lub Npe" yog lub npe ntawm tus neeg siv tam sim no nkag mus rau hauv. "Apikey" yog tus yuam sij tshwj xeeb muab rau tus neeg siv nkag mus rau API. "Ua haujlwm" yog tshuaj xyuas yog tias tus neeg siv nquag, peb tuaj yeem ua rau tus neeg siv tsis ua haujlwm, yog li nws tsis tuaj yeem nkag mus rau lub database. "CreatedAt" thiab "UpdatedAt" yog tsim los ntawm cov txheej txheem peb siv los tsim cov database.

Hauv "GPSEntries" cov lus peb muaj txhua tus cwj pwm uas muaj cov ntaub ntawv los ntawm GPS module. "Sijhawm" yog lub sijhawm tam sim no ntawm GPS module, peb siv nws los qhia lub sijhawm ntawm kev tshaj tawm. Tom qab ntawd peb muaj txoj haujlwm hauv kev tswj hwm, ib yam li "nrawm" thiab "nqe lus". Peb kuj muaj ntau qhov ua yuam kev, uas qhia yog tias muaj qhov ua yuam kev hauv cov ntaub ntawv los ntawm GPS, fx hauv kev tswj hwm. Peb tau ntxiv lawv rau hauv lub database, tab sis peb tsis qhia lawv ntawm lub vev xaib. "UserId" yog tus yuam sij txawv teb chaws uas muaj "id" los ntawm Cov Neeg Siv cov lus. Qhov ntawd yog siv los qhia tus neeg siv tshaj tawm cov ntaub ntawv.

Kauj ruam 2: API

API
API

Hauv ntu no peb yuav tham txog API uas tswj hwm cov ntaub ntawv thiab muab cov ntaub ntawv tso rau nws. Lub vev xaib API tau tsim nrog Node.js, uas siv Express.js thiab Sequalize.js.

Node.js yog siv los khiav JavaScript serverside, qhov uas nws ib txwm siv feem ntau rau cov neeg siv-sab sau ntawv ntawm lub vev xaib.

Express.js yog lub hauv paus uas peb siv los tsim API.

Sequalize.js yog siv los ua cov kev sib txuas ntawm Gps cov ntaub ntawv, thiab cov ntaub ntawv tus yam ntxwv. Nws siv txoj hauv kev hu ua ORM (Object-Relational Mapping) los ua qhov no. Qhov no kuj yog qhov uas "Tsim Tsim" thiab "Hloov Kho Tshiab" tau tsim (Qhia hauv qib 1).

API tuaj yeem siv los ntawm kev mus saib api.joerha.dk. Tom qab ntawd ntxiv /gps rau qhov url, uas yuav qhia tag nrho cov ntaub ntawv hauv database hauv JSON hom. Txhawm rau tswj ntau npaum li cas koj xav tau, koj tuaj yeem ntxiv /2 (Tus neeg siv) thiab /x (tus lej nkag) rau qhov url. Fx api.joerha.dk/gps/2/10 yuav qhia 10 qhov tseeb nkag mus. Kev tshem tawm ntawm cov ntaub ntawv teeb tsa tau qhia hauv daim duab saum toj no.

Code tuaj yeem pom ntawm no: Github

Kauj Ruam 3: Daim Ntawv Thov GPS/Python

Daim ntawv thov GPS/Python
Daim ntawv thov GPS/Python
Daim ntawv thov GPS/Python
Daim ntawv thov GPS/Python
Daim ntawv thov GPS/Python
Daim ntawv thov GPS/Python

Hauv ntu no peb yuav tham txog tsab ntawv uas sau rau ntawm raspberry thiab khaws cov ntaub ntawv GPS, thiab xa mus rau API.

Txhawm rau sau cov ntaub ntawv los ntawm GPS peb tab tom siv daemon hu ua gpsd (Daim duab 1). Nov yog qhov uas peb khaws cov ntaub ntawv uas peb tshaj tawm rau lub hauv paus, thiab lub hauv paus rau peb GPSEntries cov lus. Tsab ntawv uas rub cov ntaub ntawv los ntawm gpsd thiab xa nws mus rau API, tau sau ua sej.

Daim ntawv thov pib ua xov, yog li nws tuaj yeem ua haujlwm ob qho gpsd thiab peb cov haujlwm tib lub sijhawm. Cov ntaub ntawv Gpsd tau nthuav tawm tsis tu ncua thaum GPS tseem ua haujlwm (Daim duab 2).

Tom qab ntawd peb ua lub sijhawm luv luv uas txuas ntxiv tshaj tawm nws cov nyiaj them rau API uas muaj cov ntaub ntawv GPS. Cov ntaub ntawv raug teeb tsa ua JSON. Kev them nyiaj suav nrog cov cwj pwm uas pom hauv GPSD. Cov ntawv.fix ua zoo li cov duab ntawm cov ntaub ntawv tam sim no, thiab xa qhov ntawd mus rau API. Qhov no yog ua tiav los ntawm kev thov.post, thiab siv qhov url thiab API yuam sij. Luam tawm (r.status_code) tau tso tawm rau tus neeg siv, kom paub seb cov ntaub ntawv tau txais thoob plaws qhov raug. Time.sleep (0.5) yog pes tsawg zaus cov ntaub ntawv tshaj tawm (Duab 3)

Code tuaj yeem pom ntawm no: Github

Kauj Ruam 4: Webpage rau Txoj Haujlwm

Webpage rau Qhov Project
Webpage rau Qhov Project

Hauv ntu no peb yuav tham txog yuav ua li cas peb tsim peb lub vev xaib uas qhia cov ntaub ntawv, thiab lwm yam ntaub ntawv hais txog txoj haujlwm. Lub xaib tau tsim nrog HTML, css thiab JS. Txhawm rau pib nrog peb siv Bootstrap 4.0, uas yog lub tsev qiv ntawv rau HTML, css thiab JS. Nws los nrog ntau txoj haujlwm uas pab koj tsim koj lub vev xaib. Peb tau siv nws rau navbar rau saum, ib yam li kab thiab kab teeb tsa uas lub xaib tau tsim nrog. Tom qab ntawd peb muaj lwm tsab ntawv me me css tswj cov xim ntawm keeb kwm yav dhau thiab lub taub hau. Txhawm rau qhov ntawd peb tau siv lub tsev qiv ntawv hu ua lub teeb, yog li koj tuaj yeem nyem cov duab thiab lawv pop-up. Cov ntsiab lus ntawm lub xaib muaj daim duab qhia chaw hauv google, cov lus ntawm cov ntaub ntawv, cov vis dis aus ntawm lub tsheb ua haujlwm thiab txuas mus rau nplooj ntawv no.

Daim ntawv qhia google yog qhov nthuav tshaj plaws. Daim ntawv qhia chaw tau rub los ntawm google API, qhov twg tshwj xeeb API tus yuam sij tau ntxig rau nws kom ua haujlwm. Cov ntaub ntawv tau xa mus rau hauv daim duab qhia chaw hauv ib lub sijhawm ntawm 500ms. Peb tau ua txoj haujlwm uas qhov 100 cov ntsiab lus kawg hauv cov ntaub ntawv khaws tseg yog cov cim, yog li koj tuaj yeem ua raws qhov chaw uas lub tsheb tau ua. Qhov no ua tiav los ntawm qhov hu ua AJAX hu.

Cov ntaub ntawv teev nyob hauv GPS cov ntaub ntawv rooj yog thov tib yam nkaus. Hauv lub rooj koj tuaj yeem pom 10 qhov kawg nkag, hloov kho lub sijhawm tiag tiag thaum GPS ua haujlwm. Peb khaws cov ntaub ntawv los ntawm cov ntaub ntawv khaws tseg hauv ib lub sijhawm ntawm 500 ms.

Code tuaj yeem pom ntawm no: Github

Pom zoo: