Cov txheej txheem:
- Kauj ruam 1: Taw qhia
- Kauj Ruam 2: Cov Khoom & Software Yuav Tsum Tau
- Kauj Ruam 3: Tsim Rover Chassis
- Kauj Ruam 4: Tsim Lub Tsev Sib Ntsib Ultrasonic Rangefinder
- Kauj Ruam 5: Schematics thiab Kev Sib Txuas Hluav Taws Xob
- Kauj Ruam 6: SSH thiab Qhib CV Kev Txhim Kho
- Kauj Ruam 7: Khiav Python Code rau Rover
Video: Raspberry Pi - Autonomous Mars Rover Nrog OpenCV Lub Hom Phiaj Nrhiav: 7 Cov Kauj Ruam (nrog Duab)
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Txhawb nqa los ntawm Raspberry Pi 3, Qhib CV cov khoom paub, Ultrasonic sensors thiab geared DC motors. Lub rover no tuaj yeem taug qab txhua yam khoom nws tau kawm rau thiab txav mus rau txhua qhov av.
Kauj ruam 1: Taw qhia
Hauv Cov Lus Qhia no, peb tab tom tsim kom muaj Kev ywj pheej Mars Rover uas tuaj yeem lees paub cov khoom thiab taug qab lawv siv Open CV software khiav ntawm Raspberry Pi 3 nrog rau kev xaiv siv lub webcam ntaus ntawv lossis thawj lub koob yees duab raspberry pi. Nws tseem tau nruab nrog lub ntsuas hluav taws xob Ultrasonic ntsuas ntawm lub servo txhawm rau taug qab nws txoj hauv kev ib puag ncig tsaus ntuj uas lub koob yees duab yuav tsis ua haujlwm. Cov paib tau txais los ntawm Pi raug xa mus rau tus tsav tsheb IC (L293D) uas tsav 4 x 150RPM DC motors tau teeb tsa ntawm lub cev ua los ntawm cov kav dej PVC.
Kauj Ruam 2: Cov Khoom & Software Yuav Tsum Tau
Cov Ntaub Ntawv Yuav Tsum Tau
- Raspberry Pi (Ib qho tab sis xoom)
- Raspberry PI Lub Koob Yees Duab lossis lub vev xaib
- L293D tsav tsheb tsav IC
- Neeg Hlau Log (7x4cm) X 4
- Tsav DC Motors (150RPM) X 4
- PVC kav rau chassis
Software xav tau
- Putty rau SSH hauv Pi
- Qhib CV rau kev lees paub cov khoom
Kauj Ruam 3: Tsim Rover Chassis
Txhawm rau tsim lub PVC chassis no, koj yuav xav tau
- 2 X 8"
- 2 X 4"
- 4 T-Sib Koom
Teem cov kav dej PVC hauv tus ntaiv zoo li cov qauv thiab ntxig rau hauv T-pob qij txha. Koj tuaj yeem siv PVC sealant los ua kom cov pob qij txha muaj zog dua.
Lub zog DC lub cev muaj zog txuas nrog lub PVC yeeb nkab chassis siv clamps thiab tom qab ntawd lub log txuas nrog lub cav siv cov ntsia hlau.
Kauj Ruam 4: Tsim Lub Tsev Sib Ntsib Ultrasonic Rangefinder
Kev sib xyaw ua ke ntawm cov ntsuas hluav taws xob tau tsim los siv HC-SR04 Ultrasonic sensor txuas nrog Micro Servo lub cev muaj zog. Cables tau txuas ua ntej nrog lub ntsuas hluav taws xob ultrasonic ua ntej muab tso rau hauv cov ntaub ntawv yas uas txuas nrog rau servo lub cev muaj zog ntawm cov ntsia hlau.
Kauj Ruam 5: Schematics thiab Kev Sib Txuas Hluav Taws Xob
Thov ua qhov txuas hluav taws xob raws li daim duab qhia chaw txuas nrog.
Kauj Ruam 6: SSH thiab Qhib CV Kev Txhim Kho
Tam sim no, peb yuav tsum tau SSH rau hauv peb cov raspberry pi txhawm rau txhawm rau txhim kho cov software xav tau. Peb yuav pib los ntawm SSHing rau peb Raspberry Pi. Nco ntsoov tias koj tus Pi txuas nrog tib lub router zoo li koj lub PC thiab koj paub nws yog IP chaw nyob uas tau muab los ntawm koj lub router. Tam sim no, qhib qhov hais kom ua lossis PUTTY yog tias koj nyob ntawm Windows thiab khiav cov lus txib hauv qab no.
Koj tus Pi tus IP yuav txawv, kuv yog 192.168.1.6.
Tam sim no, sau koj tus password tsis raug - "raspberry"
Tam sim no, tias koj muaj SSH'd rau hauv koj Pi, Cia pib los ntawm kev hloov kho nrog cov lus txib no.
sudo apt-tau hloov tshiab & sudo apt-tau hloov tshiab
Cia peb teeb tsa cov cuab yeej tsim tawm tam sim no, sudo apt-tau nruab tsim-qhov tseem ceeb cmake pkg-teeb tsa
Tom ntej no, peb yuav tsum teeb tsa qee cov duab I/O pob khoom uas yuav pab peb Pi mus nqa ntau yam duab tawm tswv yim los ntawm disk.
sudo apt-tau nruab libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
Tam sim no, qee pob khoom rau nqa cov vis dis aus, nyob kwj thiab ua kom zoo dua OpenCV kev ua haujlwm
sudo apt-tau nruab libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-tau nruab libxvidcore-dev libx264-dev
sudo apt-tau nruab libgtk2.0-dev libgtk-3-dev
sudo apt-tau nruab libatlas-base-dev gfortran
Peb kuj yuav tsum tau teeb tsa Python 2.7 thiab Python 3 header files yog li peb tuaj yeem suav sau OpenCV nrog cov nab hab sej khi
sudo apt-tau nruab python2.7-dev python3-dev
Rub tawm OpenCV qhov chaws
cd ~ ib
wget -O opencv.zip
unzip qhib cv.zip
Rub tawm opencv_contrib repository
wget -O opencv_contrib.zip
unzip qhib cv_contrib.zip
Nws kuj tseem pom zoo kom siv ib puag ncig virtual rau txhim kho OpenCV.
sudo pip nruab virtualenv virtualenvwrapper
sudo rm -rf ~/.cache/pip
Tam sim no, qhov virtualenv thiab virtualenvwrapper tau teeb tsa, peb yuav tsum hloov kho peb ~/.profile kom suav nrog cov kab hauv qab no hauv qab
export WORKON_HOME = $ HOME/.virtualenvs export VIRTUALENVWRAPPER_PYTHON =/usr/bin/python3 qhov chaw /usr/local/bin/virtualenvwrapper.sh
Tsim koj li nab nab virtual puag ncig
mkvirtualenv cv -p python2
hloov mus rau qhov tsim ib puag ncig virtual
qhov chaw ~/.profile
siv cv
Txhim kho NumPy
pip nruab numpy
Sau & Nruab OpenCV
cd ~/opencv-3.3.0/
mkdir ua
cd tsim
cmake -D CMAKE_BUILD_TYPE = RELEASE / -D CMAKE_INSTALL_PREFIX =/usr/local / -D INSTALL_PYTHON_EXAMPLES = ON / -D OPENCV_EXTRA_MODULES_PATH = ~/opencv_contrib -3.3.0/modules / …
Thaum kawg suav sau OpenCV
ua j4
Tom qab cov lus txib no ua tiav. Txhua yam koj yuav tsum ua yog nruab nws.
sudo ua config
sudo ldconfig
Kauj Ruam 7: Khiav Python Code rau Rover
Tsim cov ntawv Python hu ua tracker.py thiab ntxiv cov cai hauv qab no rau nws.
sudo nano tracker.py
chaws:-
#ASAR Txoj Haujlwm
#Txoj haujlwm no taug qab lub pob liab thiab qhia raspberry pi kom ua raws nws. import sys sys.path.append ('/usr/local/lib/python2.7/site-packages') import cv2 import numpy as np import os import RPi. GPIO as IO IO.setmode (IO. BOARD) IO.setup (7, IO. OUT) IO.setup (15, IO. OUT) IO.setup (13, IO. OUT) IO.setup (21, IO. OUT) IO.setup (22, IO. OUT) def fwd (): IO.output (21, 1) #Left Motor Forward IO.output (22, 0) IO.output (13, 1) #Right Motor Forward IO.output (15, 0) def bac (): IO.output (21, 0) #Left Motor rov qab IO.output (22, 1) IO.output (13, 0) #Right Motor rov qab IO.output (15, 1) def ryt (): IO.output (21, 0) #Left Motor rov qab IO.output (22, 1) IO.output (13, 1) #Right Lub cev muaj zog rau pem hauv ntej IO.output (15, 0) def lft (): IO.output (21, 1) #Left Tsav rau pem hauv ntej IO.output (22, 0) IO.output (13, 0) #Right Motor rov qab IO.output (15, 1) def stp (): IO.output (21, 0) #Left Tsav nres IO.output (22, 0) IO.output (13, 0) #Right Tsav nres IO.output (15, 0) ########################### ############################################# ###################### def lub ntsiab (): capWebcam = cv2. VideoCapture (0)#tshaj tawm a VideoCapture kwv thiab koom nrog webcam, 0 => siv 1st webcam # qhia thawj qhov kev daws teeb meem luam tawm "kev daws teeb meem =" + str (capWebcam.get (cv2. CAP_PROP_FRAME_WIDTH)) + "x" + str (capWebcam.get (cv2. CAP_PROP_FRAME_HEIGHT)) capWebcam.set (cv2. CAP_PROP_FRAME_WIDTH, 320.0) # hloov kev daws teeb meem rau 320x240 rau kev ua kom sai dua) + "x" + str (capWebcam.get (cv2. CAP_PROP_FRAME_HEIGHT)) yog capWebcam.isOpened () == Cuav: # xyuas yog tias VideoCapture kwv yees cuam tshuam nrog webcam ua tiav luam tawm "yuam kev: capWebcam tsis nkag mus tau zoo / n / n" # yog tsis yog, luam tawm cov lus yuam kev rau std tawm os.system ("ncua") # ncua kom txog thaum tus neeg siv tus yuam sij kom tus neeg siv tuaj yeem pom cov lus yuam kev rov qab # thiab tawm kev ua haujlwm (uas tawm qhov program) # kawg yog thaum cv2.waitKey (1)! = 27 thiab capWebcam.isOpened (): # kom txog thaum tus yuam sij Esc raug nias lossis lub vev xaib txuas tau ploj mus blnFrameReadSuccessf ully, imgOriginal = capWebcam.read () # nyeem kab ntawv tom ntej yog tias tsis blnFrameReadSuccessfully lossis imgOriginal yog Tsis muaj: # yog cov kab ntawv tsis tau nyeem ua tiav luam "yuam kev: thav duab tsis tau nyeem los ntawm webcam / n" # luam cov lus yuam kev rau std tawm os.system ("ncua") # ncua kom txog thaum tus neeg siv nias tus yuam sij kom tus neeg siv tuaj yeem pom cov lus yuam kev tawg # tawm thaum lub voj (uas tawm qhov program) # kawg yog imgHSV = cv2.cvtColor (imgOriginal, cv2. COLOR_BGR2HSV) imgThreshLow = cv2.inRange (imgHSV, np.array ([0, 135, 135]), np.array ([18, 255, 255])) imgThreshHigh = cv2.inRange (imgHSV, np.array ([165, 135, 135]), np. array ([179, 255, 255])) imgThresh = cv2.add (imgThreshLow, imgThreshHigh) imgThresh = cv2. GaussianBlur (imgThresh, (3, 3), 2) imgThresh = cv2.dilate (imgThresh, np.ones ((5, 5), np.uint8)) imgThresh = cv2.erode (imgThresh, np.ones ((5, 5), np.uint8)) intRows, intColumns = imgThresh.shape circles = cv2. HoughCircles (imgThresh, cv2. HOUGH_GRADIENT, 5, intRows / 4) # sau cov voj sib txawv nrog txhua lub voj voog hauv cov duab ua tiav yog lub voj voog tsis yog Tsis muaj: # kab ntawv no yog qhov tsim nyog kom ua haujlwm tsis txhob poob ntawm kab tom ntej yog tias tsis pom lub voj voog IO.output (7, 1) rau lub voj voos hauv lub voj voos [0]: # rau txhua lub voj x, y, vojvoog = lub voj voog # tawg tawm x, y, thiab lub vojvoog sau "pob ntawv x =" + str (x) + ", y =" + str (y) + ", radius =" + str (radius) # luam tawm txoj haujlwm pob thiab radius obRadius = int (vojvoog) xAxis = int (x) yog obRadius> 0 & obRadius100 & xAxis180: luam tawm ("Tsiv Txoj Cai") ryt () elif xAxis <100: print ("Moving Left") lft () else: stp () else: stp () cv2.circle (imgOriginal, (x, y), 3, (0, 255, 0), -1) # kos lub voj voog ntsuab ntsuab ntawm qhov nruab nrab ntawm cov khoom pom cv2.circle (imgOriginal, (x, y), radius, (0, 0, 255), 3) # kos lub voj voog liab nyob ib puag ncig cov khoom pom # kawg rau # kawg yog lwm qhov: IO.output (7, 0) cv2.namedWindow ("imgOriginal", cv2. WINDOW_AUTOSIZE) # tsim windows, siv WINDOW_AUTOSIZE rau lub qhov rai ruaj khov loj cv2.namedWindow ("imgThresh", cv2. WINDOW_AUTOSIZE) # lossis siv WINDOW_NORMAL tso cai qhib qhov rai loj dua cv2.imshow ("imgOriginal", imgOri ginal)#qhia windows cv2.imshow ("imgThresh", imgThresh)#kawg thaum cv2.destroyAllWindows ()#tshem qhov rais los ntawm kev nco rov qab #################### ####################################### ############################## yog tias _name_ == "_main_": main ()
Tam sim no, txhua yam uas tseem tshuav yog ua qhov program
nab hab sej tracker.py
Nrog koj zoo siab! koj tus kheej tsav tsheb rover tau npaj txhij! Ultrasonic sensor raws txoj kev taw qhia yuav ua tiav sai thiab kuv yuav hloov kho cov lus qhia no.
Ua tsaug rau kev nyeem ntawv!
Pom zoo:
Kev Tshawb Nrhiav Lub Hom Phiaj Nrog Sipeed MaiX Boards (Kendryte K210): 6 Cov Kauj Ruam
Kev Tshawb Nrhiav Lub Hom Phiaj Nrog Sipeed MaiX Boards (Kendryte K210): Raws li txuas ntxiv ntawm kuv tsab xov xwm dhau los txog kev lees paub cov duab nrog Sipeed MaiX Boards, Kuv txiav txim siab sau lwm qhov kev qhia, tsom mus rau cov khoom pom. Muaj qee qhov kho vajtse nthuav tawm tsis ntev los no nrog Kendryte K210 nti, suav nrog S
Lub Hom Phiaj Taw Qhia: Tsim Lub Hom Phiaj Kawm/Qhia Txoj Kev/Cov Txheej Txheem Siv Cov Duab Puncher: 5 Kauj Ruam
Lub Hom Phiaj Taw Qhia: Tsim Lub Hom Phiaj Kawm/Qhia Txoj Kev/Cov Qauv Siv Cov Duab Puncher: Kawm/qhia txoj hauv kev rau cov tub ntxhais kawm tshiab rau kev tsom mus rau lub hom phiaj. Nov yog txoj hauv kev tso cai rau lawv kom pom kev thiab pom cov txheej txheem ntawm kev tsim cov khoom los ntawm cov chav kawm. EkTools 2-nti loj punch; cov duab zoo tshaj plaws. 2. Daim ntawv los yog c
Lub Hom Phiaj Nrhiav Lub Koob Yees Duab Slider Nrog Kev Sib Hloov. 3D Luam & Ua Rau ntawm RoboClaw DC Lub Cev Muaj Zog Tswj & Arduino: 5 Kauj Ruam (nrog Duab)
Lub Hom Phiaj Nrhiav Lub Koob Yees Duab Slider Nrog Kev Sib Hloov. 3D Luam & Ua Rau ntawm RoboClaw DC Tsav Tus Tswj & Arduino: Txoj haujlwm no tau yog ib qhov kuv nyiam tshaj plaws txij li thaum kuv tau koom ua ke kuv qhov kev txaus siab ntawm kev ua yeeb yaj kiab nrog DIY. Kuv ib txwm saib thiab xav ua raws cov yeeb yaj kiab uas tau ua hauv cov yeeb yaj kiab uas lub koob yees duab txav mus hla lub vijtsam thaum tab tom taug qab mus
Lub Hom Phiaj Taw Qhia: Tsim Lub Hom Phiaj Kawm/Qhia Txuj Ci/Txuj Ci Siv Txiab: 5 Kauj Ruam
Lub Hom Phiaj Taw Qhia: Tsim Lub Hom Phiaj Kawm/Qhia Txoj Kev/Txuj Ci Siv Txiab: Kawm/qhia txoj hauv kev rau cov tub ntxhais kawm tshiab rau lub hom phiaj ua haujlwm. Nov yog ib txoj hauv kev tso cai rau lawv kom pom kev thiab pom cov txheej txheem ntawm kev tsim cov khoom los ntawm cov chav kawm.Parts: 1. Txiab (yam twg yuav ua). 2. Daim ntawv lossis daim npav. 3. Marker… nyeem ntxiv
Kev Tshawb Nrhiav Lub Hom Phiaj W/ Dragonboard 410c lossis 820c Siv OpenCV thiab Tensorflow: 4 Kauj Ruam
Kev Tshawb Nrhiav Lub Hom Phiaj W/ Dragonboard 410c lossis 820c Siv OpenCV thiab Tensorflow.: Cov lus qhia no piav qhia yuav ua li cas rau nruab OpenCV, Tensorflow, thiab tshuab kev kawm ua haujlwm rau Python 3.5 kom ua tiav Daim Ntawv Thov Kev Tshawb Fawb