Cov txheej txheem:

Txoj Cai Tus Kheej Raws Tus Kheej Drone Nrog Raspberry Pi: 5 Kauj Ruam
Txoj Cai Tus Kheej Raws Tus Kheej Drone Nrog Raspberry Pi: 5 Kauj Ruam

Video: Txoj Cai Tus Kheej Raws Tus Kheej Drone Nrog Raspberry Pi: 5 Kauj Ruam

Video: Txoj Cai Tus Kheej Raws Tus Kheej Drone Nrog Raspberry Pi: 5 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Autonomous Line Follower Drone Nrog Raspberry Pi
Autonomous Line Follower Drone Nrog Raspberry Pi

Cov ntawv qhia no qhia tias yuav ua li cas koj tuaj yeem ua kab raws tus drone thaum kawg.

Lub drone no yuav muaj "hom kev tswj hwm tus kheej" hloov pauv uas yuav nkag mus rau drone rau hom. Yog li, koj tseem tuaj yeem ya koj lub drone zoo li ua ntej.

Thov nco ntsoov tias nws yuav siv sijhawm los tsim thiab ntau lub sijhawm los kho. Tab sis qhov kawg… yog ua rau koj xav tias tsim nyog nws.

Txhawm rau pib tsim koj tus kheej kab autonomus kab tracker drone, xyuas kom tseeb tias koj muaj;

  • Rasberry Pi 3 lossis Raspberry Pi Zero W nrog SSH nkag
  • Ready-To-Fly drone nrog APM lossis Pixhawk lub davhlau tswj
  • Arduino Leonardo lossis lwm Arduino nrog lub moos nrawm
  • Tsawg kawg 6 CH tus xa tawm
  • USB Webcam uas Raspberry Pi thiab OpenCV txhawb
  • Ib lub PC
  • 6 lub hom phiaj dav dav transistors
  • Cov kab hluav taws xob

Kauj Ruam 1: Lub Tswv Yim thiab Kev Sib Txuas

Lub Tswv Yim thiab Kev Sib Txuas
Lub Tswv Yim thiab Kev Sib Txuas

APM, aka ArduPilot, yog tus tswj lub davhlau raws Arduino Mega. Qhov no txhais tau tias peb tuaj yeem hloov kho nws kom zoo tshaj plaws rau peb rooj plaub. Tab sis txij li thaum kuv tsis muaj cov ntaub ntawv los ua li ntawd, Kuv yuav mus ua lwm txoj hauv kev.

Raspberry Pi's, hmoov tsis, tsis yog lub sijhawm-rhiab uas txhais tau tias tsis tuaj yeem cuam tshuam nrog PPM cov cim.

Yog vim li cas peb thiaj xav tau Arduino board ntxiv.

Ua li no, Raspberry Pi yuav ua cov duab thiab xam cov lus qhia dav hlau thiab xa mus rau Arduino ntawm Serial UART interface. Daim npav Arduino yuav sawv ntawm no ua PPM tus lej nkag/txiav txim siab, uas teev cov lus qhia davhlau rau PPM cov cim uas APM xav tau. Txhawm rau kom muaj lub tswv yim, koj tuaj yeem tshuaj xyuas daim duab qhia chaw.

Raspberry Pi yuav coj zoo li lub tshuab xa xov telemetry ib sab tshawb xyuas kab.

Lub hauv paus tseem ceeb tau qhia hauv cov duab. Kuv yuav piav qhia ntxiv hauv cov kauj ruam tom ntej.

Kauj Ruam 2: Raspberry Pi Kev Sib Txuas thiab Kev Kho

Raspberry Pi Kev Sib Txuas thiab Kev Kho
Raspberry Pi Kev Sib Txuas thiab Kev Kho
Raspberry Pi Kev Sib Txuas thiab Kev Kho
Raspberry Pi Kev Sib Txuas thiab Kev Kho

Raspberry Pi yuav txuas nrog Wi-Fi Adapter (xaiv tau), USB Webcam, Arduino Leonardo ntawm USB, APM ntawm kev sib txuas ua ke. APM - RPI kev sib txuas tau qhia nrog cov ntsiab lus hauv cov duab.

Txhawm rau teeb tsa, koj muaj ob txoj kev xaiv: ntshiab Raspbian nrog cov pob xav tau lossis cov duab tshwj xeeb rau MAVLink kev txuas hu ua APSync. Yog tias koj yuav siv Raspbian, xyuas kom koj tau teeb tsa cov pob no:

sudo apt-tau hloov tshiab

sudo apt-get install -y screen python-wxgtk3.0 python-matplotlib sudo apt-get install -y python-opencv python-pip python-numpy python-dev sudo apt-get install -y libxml2-dev libxslt-dev python- lxml sudo pip nruab yav tom ntej pymavlink mavproxy pyserial

Txhawm rau siv Raspberry Pi tus lej sib txuas ua ke, koj yuav tsum qhia OS kom tsis txhob siv nws. Ua li ntawd, ntaus ntawv

sudo raspi-teeb tsa

thiab ua raws cov kev xaiv cuam tshuam> Serial interface

Koj yuav tsum lov tes taw serial interface tab sis pab kom kho vajtse serial.

Txog ntawm qhov no, qhov seem yog tsim rau ob qho Raspbian thiab APSync.

Hauv cov npe hauv tsev, tsim peb cov ntaub ntawv: rov pib dua tsab ntawv thiab cov duab ua haujlwm scriptt. Kab thib ob ua rau reboot tsab ntawv ua tiav.

kov reboot.sh image_processor.py

chmod +x reboot.sh

Luam txhua kab hauv cov ntawv hauv qab no rau koj phau ntawv qhia tsev (/home/pi) hauv Raspberry Pi.

Tsab ntawv rov pib dua yuav suav nrog qhov tshwm sim uas yuav ua rau cov duab ua haujlwm thiab cov ntawv sau xov tooj cua. Tsis tas li ob peb nqis. Nco ntsoov tias yog tias koj tsis xav tau cov cuab yeej siv telemetry, ntxiv # ua ntej kab ntawd.

nano reboot.sh

#!/bin/tsoo

python3 /home/pi/image_processor.py

Txuag nws nrog CTRL+O thiab tawm nrog CTRL+X. Kauj ruam kawg txog nws yog sau npe rau OS pib ua ntaub ntawv, rc.local

sudo nano /etc/rc.local

Ntxiv kab no saum toj no tawm 0:

/home/pi/reboot.sh

Peb tsab ntawv rov pib dua yuav ua tiav ntawm txhua lub khau raj.

Peb xav kom Raspberry Pi kaw cov vis dis aus nyob, ua nws ntawm-ya-ya, xam cov lus qhia dav hlau, xa mus rau lub davhlau tswj thiab ua telemetry. Tab sis txij li Raspberry Pi tsis tuaj yeem tsim lub cim PPM uas APM xav tau, peb xav tau lwm txoj hauv kev kom ua tiav nws.

Raspberry Pi yuav xa nws cov duab tso tawm rau Arduino (hauv kuv qhov xwm txheej Arduino Leonardo) ntawm Serial Port. Arduino yuav tsim lub teeb liab PPM los ntawm cov lus nkag ntawd thiab xa nws mus rau Lub Chaw Tswj Dav Hlau ntawm cov xov hluav taws xob. Qhov no yog txhua yam rau Raspberry Pi.

Cia peb txav mus rau qib tom ntej.

Kauj Ruam 3: Kev Sib Txuas APM thiab Kev Kho

APM Kev Sib Txuas thiab Kev Kho
APM Kev Sib Txuas thiab Kev Kho

Yam txog APM yog qhov yooj yim vim nws twb npaj yuav ya lawm. Peb yuav tsum paub cov chaw nres nkoj txuas 'baudrates, thiab nco ntsoov tias TELEM chaw nres nkoj tau qhib.

Hauv koj cov software hauv av, hauv kuv cov ntaub ntawv Lub Hom Phiaj Npaj, txheeb xyuas lub dav hlau tus tswj hwm cov npe teev tseg thiab nrhiav cov baudrates. Piv txwv li, SERIAL_BAUD yog USB baudrate thiab SERIAL_BAUD1 yog TELEM chaw nres nkoj baudrate rau APM. Nco ntsoov tias qhov tseem ceeb.

Qhov tseem ceeb tshaj plaws yog INPUT pins kev sib txuas. Raws li tau qhia hauv daim duab, txuas Arduino's digital pins 4 meej 9. Koj yuav xav siv lub khob cij rau qhov no, txij li peb tab tom yuav ntxiv qee qhov transistors thiab cov txais cov txiaj ntsig. (Saib cov duab) (Transistors yuav ua haujlwm yog tias koj xav tswj koj lub drone)

ARD 4 ↔ APM INPUT 1

ARD 5 ↔ APM INPUT 2

ARD 6 ↔ APM INPUT 3

ARD 7 ↔ APM INPUT 4

ARD 8 ↔ APM INPUT 5

ARD 9 ↔ APM INPUT 6

Txuas txhua 5V tus pin ntawm APM Cov Tswv Yim rau Arduino Leonardo 5V tus pin. Ib yam li txuas txhua APM Cov Lus Qhia GND pins rau Arduino Leonardo GND tus pin.

Kauj Ruam 4: Kev teeb tsa Arduino Leonardo

Peb tau txuas tag nrho cov xov hlau rau Leonardo yog li tsuas yog cov lej sab laug.

Tshaj tawm cov cai hauv qab no rau koj Arduino Leonardo. Them nyiaj rau baudrates.

Kauj Ruam 5: Thawj Dav Hlau

Thaum koj ua tiav nrog txhua cov kauj ruam dhau los, nws txhais tau tias koj npaj tau lawm.

Fais fab txhua daim npav thiab txuas nrog SSH rau Raspberry Pi. Hom hauv davhlau ya nyob twg:

sudo ua

mavproxy.py -tus tswv =/dev/[INTERFACE] --baudrate [TELEM PORT BAUDRATE] -aircraft [CUSTOM NAME

Default Raspberry Pi built-in serial interface yog ttyS0 (/dev/ttyS0)

Default APM TELEM chaw nres nkoj baudrate yog 57600

Default APM USB chaw nres nkoj baudrate yog 115200

Koj tuaj yeem muab lub npe twg rau koj lub dav hlau, xaiv nws ntse, yog li koj tuaj yeem lees paub nws tom qab.

Yog tias txhua yam zoo, tam sim no txuas rau koj li Raspberry Pi ntawm VNC, yog li koj tuaj yeem saib dab tsi drone pom hauv lub sijhawm.

Tam sim no, koj tuaj yeem tuav koj lub drone. Zoo siab, txoj cai?

Coj koj lub drone tawm, thiab ya saum txoj kab. Tam sim no, koj tuaj yeem qhib txoj kab kev taug qab los ntawm kev siv CH6 hloov.

Pom zoo: