Cov txheej txheem:

Web Tswj Rover: 14 Cov Kauj Ruam (nrog Duab)
Web Tswj Rover: 14 Cov Kauj Ruam (nrog Duab)

Video: Web Tswj Rover: 14 Cov Kauj Ruam (nrog Duab)

Video: Web Tswj Rover: 14 Cov Kauj Ruam (nrog Duab)
Video: Tus Neeg Ruam - R-Lin Thoj | New Song [ Official MV ] Nkauj Tawm Tshiab 2023 Hmong Song 2023 2024, Hlis ntuj nqeg
Anonim
Web Tswj Rover
Web Tswj Rover
Web Tswj Rover
Web Tswj Rover

Tsim thiab ua si nrog cov neeg hlau yog kuv lub siab txhaum loj hauv lub neej. Lwm tus ua si golf lossis caij ski, tab sis kuv tsim neeg hlau (vim kuv tsis tuaj yeem ntaus golf lossis caij ski:-). Kuv pom nws so thiab lom zem! Ua kom feem ntau ntawm kuv cov bots, Kuv siv cov khoom siv chassis. Siv cov khoom siv pab kuv ua qhov kuv nyiam ua ntau dua, software thiab khoom siv hluav taws xob thiab tseem ua rau lub chassis zoo dua rau kuv tus ntiv tes xoo tus kheej.

Hauv Cov Lus Qhia no, peb yuav saib qhov nws yuav siv los ua kom yooj yim tab sis muaj zog Wifi/lub vev xaib tswj hwm rover. Lub chassis siv yog Actobotics Gooseneck. Kuv xaiv nws rau nws qhov loj me, nthuav dav-muaj peev xwm thiab tus nqi tab sis koj tuaj yeem siv lwm lub chassis ntawm koj tus kheej xaiv.

Txog qhov haujlwm zoo li no, peb yuav xav tau lub khoos phis tawj zoo ib leeg thiab rau lub bot no kuv tau xaiv los siv Raspberry Pi (RPI) lub Linux raws lub khoos phis tawj. RPI (thiab Linux) muab ntau txoj hauv kev rau peb xaiv thiab Python yuav siv rau sab coding. Rau lub vev xaib sib tham Kuv siv Flask, lub vev xaib hnyav rau Python.

Txhawm rau tsav lub cav, kuv xaiv RoboClaw 2x5a. Nws tso cai rau kev sib txuas lus yooj yim rau kev hais kom ua thiab ua haujlwm tau zoo nrog RPI thiab lub cav ntawm Gooseneck.

Thaum kawg, nws muaj lub vev xaib rau POV hom vis dis aus tawm tswv yim rau kev tsav tsheb nws nyob deb. Kuv yuav npog txhua lub ncauj lus kom ntxaws ntxiv tom qab.

Kauj Ruam 1: Xav Tau Kho Vajtse

Kho vajtse xav tau
Kho vajtse xav tau
Kho vajtse xav tau
Kho vajtse xav tau
Kho vajtse xav tau
Kho vajtse xav tau
Kho vajtse xav tau
Kho vajtse xav tau
  • Actobotics Gooesneck chassis lossis kev hloov pauv uas koj xaiv
  • Raspberry Pi uas koj xaiv (lossis clone) - Ib qho RPI qauv B tau siv ntawm tus kab mob no, tab sis ib qho nrog tsawg kawg ob lub USB chaw nres nkoj yuav ua haujlwm
  • Txheem Servo Phaj B x1
  • 90 ° Ib Leeg Ib Leeg Channel Bracket x1
  • RoboClaw 2x5a tsav tsheb
  • S3003 lossis zoo ib yam li tus qauv loj servo
  • Cov ntawv me me los yog Mini breadboard
  • Poj niam rau Poj niam jumper xov hlau
  • Txiv neej rau Poj niam jumper xov hlau
  • Web cam (xaiv tau) - Kuv siv Logitech C110, thiab ntawm no yog cov npe ntawm cov cams txhawb rau RPI
  • 5v-6v lub zog siv rau lub zog servo
  • 7.2v-11.1v roj teeb rau tsav lub zog tsav
  • 5v 2600mah (lossis siab dua) USB lub txhab nyiaj fais fab rau RPI
  • USB Wifi adapter

Ntawm kuv tus bot, kuv siv 4 lub log los ua kom nws me ntsis ntxiv Txhua-Thaj Chaw-Sab Hauv. Rau qhov kev xaiv no koj yuav xav tau:

  • 4 "Hnyav Plaub Hau Log x2
  • 4mm Bore Teeb Ntsia Hlau Hub (0.770 nti) x2

Kauj Ruam 2: Sib dhos Chassis

Sib dhos Chassis
Sib dhos Chassis
Sib dhos Chassis
Sib dhos Chassis
Sib dhos Chassis
Sib dhos Chassis

Ua ntej sib sau ua ke lub chassis raws li cov lus qhia suav nrog lub chassis lossis video. Tom qab ua tiav koj yuav tsum muaj qee yam zoo li daim duab. NCO TSEG: Thaum sib dhos lub caj dab ib sab, cia li tso lub pob khawm tshem tawm.

Ntawm kuv tus bot, Kuv tau xaiv los hloov lub log uas lub chassis tuaj nrog rau 4 lub log hnyav ua haujlwm. Qhov no yog nyob ntawm yeem thiab tsis xav tau tshwj tsis yog tias koj xav ua ib yam.

Kauj Ruam 3: Mounting Electronics

Mounting Electronics
Mounting Electronics
Mounting Electronics
Mounting Electronics
Mounting Electronics
Mounting Electronics

Gooseneck muaj ntau chav thiab xaiv rau kev teeb tsa koj cov khoom siv hluav taws xob. Kuv muab cov duab no los ua kab lus qhia, tab sis koj tuaj yeem xaiv qhov koj xav tso nws txhua qhov. Koj tuaj yeem siv sawv ntsug-tawm, ob daim kab xev, Velcro lossis daim kab xev servo los txhawm rau txhawm rau lub rooj tsavxwm thiab roj teeb.

Kauj Ruam 4: Ntxiv Webcam

Ntxiv Webcam
Ntxiv Webcam
Ntxiv Webcam
Ntxiv Webcam
Ntxiv Webcam
Ntxiv Webcam

Coj tus 90 degree bracket, lub teeb rau lub servo hub thiab plaub (4) ntawm.3125 screws rau cov kauj ruam no:

  • Nqa lub servo hub thiab muab tso rau ntawm ib sab ntawm lub bracket thiab ruaj ntseg lawv ua ke nrog.2125 "screws zoo li daim duab
  • Tom ntej no teeb tsa lub servo rau hauv servo bracket
  • Txuas lub 90 degree bracket nrog servo horn rau servos nqaj qaum thiab siv lub ntsia hlau ntsia hlau uas tuaj nrog servo los txuas lawv ua ke
  • Tam sim no teeb tsa Servo hauv qhov txuas mus rau sab saum toj ntawm goose-caj dab nrog cov ntsia hlau ntxiv
  • Mount lub koob yees duab nrog zip-ties lossis daim kab xev ob tog rau ntawm 90 degree bracket

Siv cov duab rau cov lus qhia yog xav tau.

Kauj Ruam 5: Txhim Kho Txhua Qhov

Txuas Nws Txhua Qhov
Txuas Nws Txhua Qhov
Txuas Nws Txhua Qhov
Txuas Nws Txhua Qhov
Txuas Nws Txhua Qhov
Txuas Nws Txhua Qhov
Txuas Nws Txhua Qhov
Txuas Nws Txhua Qhov

Txoj hlua yog ncaj ncaj rau pem hauv ntej rau tus neeg hlau no.

Cov Motors:

Cov laug ua rau ob lub cav yog tias koj tsis tau ua li ntawd

Nrog cov neeg hlau ua ntej (qhov kawg nrog lub caj dab) tig ntsej muag ntawm koj:

  • Txuas lub tshuab hluav taws xob ntawm sab laug lub cev mus rau M1A thiab M1B
  • Txuas lub cav hlau ntawm txoj cai lub cev rau M2A thiab M2B

Hauv av (GND) kev sib txuas:

  • Txuas ib tus pin hauv av ntawm RoboClaw rau hauv av jumper board. Cov kab hauv av ntawm RoboClaw nyob ze rau nruab nrab (Saib daim duab)
  • Txuas tus lej PIN 6 ntawm RPI mus rau lub rooj tsav nkoj jumper. Saib RPI header pic rau tus lej ua haujlwm.
  • Txuas GND los ntawm pob roj teeb servo mus rau ib qho ntawm tus pin ntawm jumper board.
  • Khiav lub jumper hlau los ntawm jumper board mus rau servos GND xaim.

RPI to RoboClaw:

Txuas RPI GPIO14 TXD tus pin rau RoboClaw S1 tus pin

Hwj chim:

  • Txuas lub POS xaim los ntawm lub roj teeb servo mus rau servos POS txhuas
  • Txuas lub POS xaim los ntawm lub roj teeb lub cev rau POS (+) ntawm RoboClaw lub cev muaj zog lub tshuab hluav taws xob nkag. Peb yuav tawm ntawm GND lub dav hlau tsis txuas rau tam sim no.

Kauj Ruam 6: Teeb RPI

Kev teeb tsa RPI
Kev teeb tsa RPI

Kuv xav tias tus neeg siv ntawm no paub qee yam txog Linux thiab RPI. Kuv tsis npog yuav teeb tsa lossis txuas rau ib qho. Yog tias koj xav tau kev pab nrog qhov ntawd siv cov nplooj ntawv hauv qab no.

Txhawm rau kom koj tau teeb tsa RPI, saib cov nplooj ntawv hauv qab no:

  • RPI Basic Setup
  • RPI Phau ntawv pib ceev
  • NOOBS setup guilde

Rau cov nplooj ntawv dav-tawm, RPI nplooj ntawv tseem ceeb thiab eLinux nplooj ntawv yog qhov chaw zoo los pib.

Saib qhov txuas no rau RPI kev teeb tsa Wifi dav dav.

Yog tias koj npaj yuav siv qee lub koob yees duab lossis lub web cam ntawm tus bot, saib ntawm nplooj ntawv no kom tau txais cov ntaub ntawv xav tau yooj yim.

  • RPI cam teeb tsa
  • eLinix RPI cam teeb tsa

Tshaj tawm video:

Muaj ob peb txoj hauv kev kom tau txais cov vis dis aus ua haujlwm ntawm RPI, tab sis txoj hauv kev kuv nyiam yog siv Motion.

Txhawm rau nruab nws ntawm koj RPI khiav qhov no: sudo apt-tau nruab suab

Qhov kev tsis txaus ntseeg no dhau mus teeb nws rau streaming ib yam.

Kauj Ruam 7: Kho RPI Serial Port

Peb yuav tsum tau xiam lub Linux console hom rau siv RX thiab TX raws li peb xav tham nrog RoboClaw lub cev muaj zog tswj los ntawm qhov chaw nres nkoj no. Txhawm rau ua qhov no, koj tuaj yeem siv txoj hauv kev no lossis cov cuab yeej no. Qhov kev xaiv yog koj li ntawm txoj hauv kev vim lawv ob leeg ua tib yam nkaus thaum kawg.

Kauj Ruam 8: Txhim Kho Python Modules

Koj yuav xav tau nab hab sej nruab rau ntawm RPI ntxiv rau pob sej pob installer pip.

Txhawm rau nruab pip ua:

  1. sudo apt-tau nruab nruab sej-setuptools
  2. sudo easy_install pip

Tom qab ntawd:

  1. sudo pip nruab flask
  2. sudo pip nruab pyserial
  3. sudo pip nruab RPIO

Qhov no yuav yog txhua qhov qauv xav tau rau cov cai kom ua haujlwm.

Kauj Ruam 9: Teeb tsa RoboClaw

Kuv muaj tus lej neeg hlau tham nrog RoboClaw hauv Standard Serial Mode ntawm 19200 baud.

Txhawm rau teeb tsa RoboClaw rau qhov no ua:

  1. Ntaus "MODE" khawm ntawm RoboClaw
  2. Ntaus lub pob teeb kom txog thaum LED teeb 5 (tsib) zaug ntawm qhov qeeb
  3. Ntaus "LIPO" khawm kom khaws
  4. Tom ntej no ntaus lub "SET" khawm kom txog thaum LED flashes 3 (peb) zaug ntawm qhov qeeb
  5. Ntaus lub LIPO khawm kom khaws

Qhov ntawd yog nws rau teeb tsa lub cav tswj. Saib daim ntawv pdf txuas rau saum toj no yog xav paub ntxiv.

Kauj Ruam 10: Txhim Kho Rover Program/cov ntaub ntawv

Rub tawm thiab luam cov ntawv rover.zip rau koj RPI hauv koj tus neeg siv pi npe.

Yog tias koj tab tom khiav Linux lossis Mac, koj tuaj yeem siv 'scp' ua nws:

scp ~/qhov chaw/ntawm/the/file/rover.zip pi@your_rpi_ip:/~

Rau Windows, koj tuaj yeem rub tawm thiab siv pscp thiab tom qab ntawd ua:

pscp /location/of/the/file/rover.zip pi@your_rpi_ip:/~

Thaum zipfile tau theej rau RPI, nkag mus rau nws raws li tus neeg siv pi.

Tam sim no khiav:

unzip rover.zip

Qhov no yuav unzip cov ntaub ntawv mus rau daim nplaub tshev npe hu ua 'rover' thiab muaj cov hauv qab no hauv qab ntawv ntawd:

  • restrover.py (Python code rau tus neeg hlau)
  • zoo li qub (tuav cov ntaub ntawv duab rau cov nyees khawm ntawm nplooj ntawv tswj)
  • cov qauv (tuav cov ntawv index.htlm, tswj lub vev xaib)

Yog tias koj siv lub vev xaib, hloov kab ze rau hauv qab ntawm qhov index.html cov ntaub ntawv hauv daim ntawv tais ceev tseg. Hloov qhov URL hauv kab IFRAME kom phim src URL rau koj cov vis dis aus.

Kauj Ruam 11: Pib Bot Up

Pib Bot Up
Pib Bot Up

Txuas lub zog USB rau RPI.

Txhawm rau pib tus lej bot, nkag mus ua tus neeg siv pi thiab khiav:

  • cd rov
  • sudo nab hab sej restrover.py

Yog tias txhua yam ua tau zoo, koj yuav tsum pom lub vijtsam zoo ib yam li cov duab hauv qib no

Yog tias koj pom ib qho yuam kev lossis teeb meem, koj yuav tau kho lawv ua ntej yuav mus tom ntej.

Tam sim no, txuas GND (-) xaim mus rau NEG (-) davhlau ya nyob twg ntawm RoboClaw lub cev muaj zog lub zog nkag.

Kauj Ruam 12: Nkag mus rau Bot Control Page

Nkag mus rau Bot Tswj Xyuas Nplooj Ntawv
Nkag mus rau Bot Tswj Xyuas Nplooj Ntawv
Nkag mus rau Bot Tswj Nplooj Ntawv
Nkag mus rau Bot Tswj Nplooj Ntawv

Tom qab tus neeg hlau cov ntawv nab nab tab tom khiav, txhawb nqa RoboClaw thiab tom qab ntawd mus rau koj li RPI's ip zoo li:

koj_rpi_ip

Koj yuav tsum pom lub vev xaib tswj hwm nplooj ntawv zoo li hauv cov duab. Yog tias tsis yog, txheeb xyuas koj lub RPI lub davhlau ya nyob twg thiab saib rau qhov ua yuam kev thiab kho lawv.

Ib zaug ntawm nplooj ntawv, koj tau npaj los tswj tus bot.

Tus neeg hlau yuav pib hauv "Med run" teeb tsa thiab ntawm qhov nruab nrab nrawm.

Tus bot tuaj yeem tswj tau los ntawm cov nyees khawm ntawm nplooj ntawv lossis los ntawm cov yuam sij ntawm cov keyboard.

Cov yuam sij yog:

  • w - rau pem hauv ntej
  • z - rov qab/rov qab
  • a - lem sab laug ntev
  • s - ntev txoj cai tig
  • q - luv lem sab laug
  • e - luv txoj cai tig
  • 1 - pan lub koob yees duab sab laug
  • 2 - yias lub koob yees duab sab xis
  • 3 - pan puv sab laug
  • 4 - pan tag txoj cai
  • / - tsev/ nruab nrab lub koob yees duab
  • h - nres/nres neeg hlau

Muaj ib nrab ncua sijhawm ncua sijhawm thib ob ntawm cov lus txib xa mus. Kuv tau ua qhov no txhawm rau tshem tawm cov lus txib tsis xav tau. Koj tuaj yeem tshem tawm qhov no los ntawm cov cai yog tias koj nyiam (hauv index.html)

Tus so ntawm kev tswj hwm thiab tswj hwm nws yuav tsum piav qhia tus kheej.

Kauj Ruam 13: Tus Python/Flask Code

Tus kab mob no siv Python thiab Flask web framework. Koj tuaj yeem kawm paub ntau ntxiv txog Flask ntawm no yog tias koj xav tau.

Qhov sib txawv loj ntawm Flask app thiab Python tsab ntawv yog @app.route chav kawm/txoj hauv kev siv los ua URI tuav. Lwm yam tshaj li qhov nws zoo nkauj npaum li cas Python rau feem ntau.

#!/usr/bin/env nab hab sej

# # Wifi/Web uas tau tsav Rover # # Sau los ntawm Scott Beasley - 2015 # # Siv RPIO, pyserial thiab Flask # ntshuam lub sijhawm ntshuam serial los ntawm RPIO ntshuam PWM los ntawm cov raj ntshuam Flask, render_template, thov app = Flask (_name_, static_url_path = '') # Txuas mus rau qhov chaw nres nkoj comm tham nrog Roboclaw lub cev tswj lub zog sim: # Hloov tus nqi baud ntawm no yog txawv dua 19200 roboclaw = serial. Serial ('/dev/ttyAMA0', 19200) tshwj tsis yog IOError: luam tawm ("Comm chaw nres nkoj tsis pom ") sys.exit (0) # Ceev thiab tsav tswj qhov sib txawv last_direction = -1 speed_offset = 84 turn_tm_offset = 0.166 run_time = 0.750 # Servo nruab nrab txoj haujlwm (tsev) servo_pos = 1250 servo = PWM. Servo () servo.set_servo (18, servo_pos) # Lub tsev me me rau kev teeb tsa lub sijhawm sijhawm. pw tsaug zog (3) # # URI tus tuav haujlwm - txhua qhov bot nplooj ntawv ua tiav ntawm no # # Xa tawm bots tswj nplooj ntawv (home page) @app.route ("/") def index (): rov render_template ('index.html', lub npe = Tsis muaj) @app.route ("/rau pem hauv ntej") def rau pem hauv ntej (): ntiaj teb kawg_direction, run_ti kuv luam "Forward" go_forward () last_direction = 0 # pw 100ms + run_time time.sleep (0.100 + run_time) # Yog tias tsis txuas ntxiv, tom qab ntawd nres tom qab ncua yog run_time> 0: last_direction = -1 nres () rov qab "ok" @ app.route ("/rov qab") def rov qab (): ntiaj teb kawg_direction, khiav_time sau "Rov qab" go_backward () kawg_direction = 1 # pw 100ms + run_time time.s pw (0.100 + run_time) # Yog tias tsis txuas ntxiv, tom qab ntawd ncua yog run_time> 0: last_direction = -1 nres () rov qab "ok" @app.route ("/sab laug") def sab laug (): ntiaj teb kawg_direction, tig_tm_offset luam "Sab laug" go_left () last_direction = -1 # pw @1 /2 zaum thib ob.sleep (0.500 - turn_tm_offset) # nres nres () time.sleep (0.100) rov "ok" @app.route ("/txoj cai") def txoj cai (): ntiaj teb kawg_direction, tig_tm_offset luam tawm "Txoj cai" go_right () # pw tsaug zog @1/2 zaum thib ob.sleep (0.500 - turn_tm_offset) last_direction = -1 # nres nres () time.sleep (0.100) rov "ok" @app.route ("/ltforward") def ltforward (): ntiaj teb kawg_direction, tig_t m_offset print "Sab laug rau pem hauv ntej tig" go_left () # pw @1 /8 zaum thib ob.sleep (0.250 - (turn_tm_offset / 2)) last_direction = -1 # nres nres () time.s pw (0.100) rov "ok" @app.route ("/rtforward") def rtforward (): ntiaj teb kawg_direction, tig_tm_offset luam "Txoj cai rau pem hauv ntej tig" go_right () # pw tsaug zog @1/8 thib ob. tsaug zog (0.250 - (turn_tm_offset/2)) last_direction = -1 # nres nres () sijhawm.s pw (0.100) rov qab "ok" @app.route ("/nres") def nres (): thoob ntiaj teb kawg_direction luam "Nres" nres () last_direction = -1 # pw 100ms lub sijhawm.sleep (0.100)) rov qab "ok" @app.route ("/panlt") def panlf (): thoob ntiaj teb servo_pos luam tawm "Panlt" servo_pos -= 100 yog servo_pos 2500: servo_pos = 2500 servo.set_servo (18, servo_pos) # pw 150ms lub sijhawm. pw tsaug zog (0.150) rov qab "ok" @app.route ("/home") def tsev (): thoob ntiaj teb servo_pos print "Tsev" servo_pos = 1250 servo.set_servo (18, servo_pos) # pw 150ms lub sijhawm.sleep (0.150) rov qab "ok" @app.route ("/panfull_lt") def panfull_lt (): thoob ntiaj teb servo_pos luam "Pan puv l eft "servo_pos = 500 servo.set_servo (18, servo_pos) # pw 150ms lub sijhawm.sleep (0.150) rov qab" ok " @app.route ("/panfull_rt ") def panfull_rt (): thoob ntiaj teb servo_pos luam tawm" Pan puv txoj cai "servo_pos = 2500 servo.set_servo (18, servo_pos) # pw 150ms lub sijhawm.sleep (0.150) rov "ok" @app.route ("/speed_low") def speed_low (): thoob ntiaj teb speed_offset, kawg_direction, turn_tm_offset speed_offset = 42 turn_tm_offset = 0.001 # Hloov kho tam sim no kom tau txais qhov nrawm tshiab yog qhov kawg_direction == 0: go_forward () yog qhov kawg_direction == 1: go_backward () # pw 150ms lub sijhawm.sleep (0.150) rov "ok" @app.route ("/speed_mid") def speed_mid (): thoob ntiaj teb speed_offset, kawg_direction, tig_tm_offset speed_offset = 84 tig_tm_offset = 0.166 # Hloov kho tam sim no kom tau txais kev nrawm tshiab yog last_direction == 0: go_forward () yog last_direction == 1: go_backward () # pw 150ms lub sijhawm.sleep (0.150) rov qab "ok" @app.route ("/speed_hi") def speed_hi (): thoob ntiaj teb speed_offset, kawg_direction, tig_tm_offset speed_offset = 126 tur n_tm_offset = 0.332 # Hloov kho tam sim no kom tau txais qhov nrawm tshiab yog qhov kawg_direction == 0: go_forward () yog kawg_direction == 1: go_backward () # pw 150ms lub sijhawm.s pw (0.150) rov "ok" @app.route ("/txuas ntxiv ") def nruam (): thoob ntiaj teb run_time luam ntawv" Ua haujlwm txuas ntxiv "run_time = 0 # pw 100ms sijhawm.sleep (0.100) rov qab" ok " @app.route ("/mid_run ") def mid_run (): thoob ntiaj teb run_time print" Mid khiav "run_time = 0.750 nres () # pw 100ms lub sijhawm.sleep (0.100) rov qab" ok " @app.route ("/short_time ") def short_time (): thoob ntiaj teb run_time print" Short run "run_time = 0.300 halt () # tsaug zog 100ms lub sijhawm.sleep (0.100) rov qab "ok" # # Lub zog tsav lub zog # def go_forward (): thoob ntiaj teb speed_offset yog speed_offset! = 42: roboclaw.write (chr (1 + speed_offset)) roboclaw.write (chr (128 +) speed_offset)) lwm qhov: roboclaw.write (chr (127 - speed_offset)) roboclaw.write (chr (255 - speed_offset)) def go_backward (): thoob ntiaj teb speed_offset yog speed_offset! = 42: roboclaw.write (chr (127 - speed_offset)) roboclaw.wri te (chr (255 - speed_offset)) ntxiv: roboclaw.write (chr (1 + speed_offset)) roboclaw.write (chr (128 + speed_offset)) def go_left (): thoob ntiaj teb speed_offset yog speed_offset! = 42: roboclaw.write (chr (127 - speed_offset)) roboclaw.write (chr (128 + speed_offset)) lwm: roboclaw.write (chr (1 + speed_offset)) roboclaw.write (chr (255 - speed_offset)) def go_right (): thoob ntiaj teb speed_offset yog speed_offset! = 42: roboclaw.write (chr (1 + speed_offset)) roboclaw.write (chr (255 - speed_offset)) lwm qhov: roboclaw.write (chr (127 - speed_offset)) roboclaw.write (chr (128 + speed_offset)) def nres (): roboclaw.write (chr (0)) yog _name_ == "_main_": app.run (host = '0.0.0.0', chaw nres nkoj = 80, debug = Tseeb)

Yog tias koj tsis xav tau lossis xav tau cov ntaub ntawv debug los ntawm Flask, teeb debug rau 'cuav' ntawm app.run kab.

yog _name_ == "_main_":

app.run (host = '0.0.0.0', chaw nres nkoj = 80, debug = Tsis tseeb)

Koj tseem tuaj yeem hloov chaw nres nkoj uas Flask http server mloog ntawm no ib yam.

Kauj Ruam 14: Siv Lwm Cov Khoos Phis Tawj

Yog tias koj xav siv lwm yam khoom siv, zoo li lwm hom SBC (Tib Lub Tshuab Khoos Phis Tawj) koj yuav tsum muaj teeb meem me me kom tau Python thiab Flask khiav ntawm lwm cov laug cam zoo li Beagle Bone, PCDuino thiab lwm yam … Koj yuav tau hloov cov cai kom phim GPIO teeb tsa thiab siv lub peev xwm tsav tsheb servo ntawm pawg thawj coj saib tshiab.

Txhawm rau siv lwm hom tsav tsheb, koj tsuas yog yuav tsum hloov kho go_forward, go_backward, go_left, go_right thiab nres lub luag haujlwm kom ua dab tsi uas tau hloov pauv lub tshuab tsav tsheb xav tau los ua kom lub tshuab ua haujlwm tshwj xeeb.

Pom zoo: