Cov txheej txheem:

Ua Tau LiDAR TFmini (Ua Ntej Qhia): 5 Kauj Ruam (nrog Duab)
Ua Tau LiDAR TFmini (Ua Ntej Qhia): 5 Kauj Ruam (nrog Duab)

Video: Ua Tau LiDAR TFmini (Ua Ntej Qhia): 5 Kauj Ruam (nrog Duab)

Video: Ua Tau LiDAR TFmini (Ua Ntej Qhia): 5 Kauj Ruam (nrog Duab)
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Ua Tau LiDAR TFmini (Ua Ntej Qhia)
Ua Tau LiDAR TFmini (Ua Ntej Qhia)
Ua Tau LiDAR TFmini (Ua Ntej Qhia)
Ua Tau LiDAR TFmini (Ua Ntej Qhia)

Nqe lus piav qhia

Benewake TFMINI Micro LIDAR Module muaj nws qhov tshwj xeeb kho qhov muag, yam ntxwv, thiab tsim hluav taws xob. Cov khoom lag luam muaj peb qhov txiaj ntsig tseem ceeb: tus nqi qis, ntim me me thiab siv hluav taws xob tsawg.

Lub hauv paus txheej txheem hloov kho rau ib puag ncig sab hauv thiab sab nraum zoov tuaj yeem lav qhov ua tau zoo ntawm tus nqi qis thiab hauv qhov ntim me me, uas nthuav dav cov ntawv thov thiab xwm txheej ntawm LiDAR thiab tso lub hauv paus ruaj khov rau yav tom ntej "qhov muag" hauv ntse tiam.

Kev qhia tshwj xeeb

  • Kev tawm tswv yim Voltage: 5v
  • Lub zog nruab nrab: 0.12W
  • Kev sib txuas lus raws tu qauv: UART (Baud tus nqi: 115200)
  • Kev Ua Haujlwm Kub: -20 ℃ ~ 60 ℃
  • FOV: 2.3 °

Qhov ntev

  • Loj: 42mmx15mmx16mm
  • Qhov hnyav: 6.1g

Txwv

0cm-30cm "dig muag" ntau

Yuav Qhov Twg

  • RobotShop
  • Amazon

Cov lus qhia no xav kom koj paub txog cov hauv qab no:

  • Cov khoom siv hluav taws xob yooj yim
  • Cov cuab yeej siv tes zoo li cov tshuab txiav hlau thiab cov hneev taw
  • Nyeem schematics thiab txuas kab kos
  • C/C ++ programming rau Arduino (yeem)
  • Python programming rau Raspberry Pi (yeem)

Kauj Ruam 1: Sib Sau Cov Khoom

Sib Sau Cov Khoom
Sib Sau Cov Khoom
Sib Sau Cov Khoom
Sib Sau Cov Khoom
Sib Sau Cov Khoom
Sib Sau Cov Khoom

Cov lus qhia no yuav coj koj mus rau ntau txoj hauv kev xa tawm TFmini LiDAR siv koj lub Windows PC thiab Raspberry Pi. Txhua txoj hauv kev nws muaj qhov xav tau thiab tuaj yeem sib txawv raws qhov koj xav tau.

** Koj yuav xav tau Benewake TFmini LiDAR rau txhua kis (tau kawg) **

Rau kev ua raws PC:

  • OS: Windows
  • USB-TTL hloov
  • Jumper Hlau

Rau kev siv Raspberry Pi Raws li:

  • Raspberry Pi
  • Jumper Hlau
  • LEDs (yeem)
  • USB-TTL converter (yeem)
  • Breadboard (yeem)
  • Resistor (ntawm 100-1k Ohm) (yeem)

Kauj ruam 2: PC Raws Li Kev Siv Siv Benewake App

PC Raws Li Kev Siv Siv Benewake App
PC Raws Li Kev Siv Siv Benewake App
PC Raws Li Kev Siv Siv Benewake App
PC Raws Li Kev Siv Siv Benewake App
  1. Txuas TFmini LiDAR rau USB-TTL hloov pauv siv jumper (txiv neej-poj niam) cov xov hlau raws li cov phiaj xwm pom

    • Liab Hlau 5V
    • Dub Hlau GND
    • Dawb/Xiav Hlau Tx
    • Ntsuab Hlau Rx
  2. Txuas USB-TTL rau koj lub khoos phis tawj
  3. Mus rau Tus Thawj Tswj Ntaus Ntawv (Yeej + X) thiab nrhiav "Prolific USB-to-Serial Comm Port" nyob hauv Ports (COM & LPT). Nco ntsoov tias Windows lees paub lub cuab yeej
  4. Rub tawm thiab rho tawm WINCC_TF.rar
  5. Khiav WINCC_TFMini.exe los ntawm cov ntawv rho tawm
  6. Xaiv qhov sib txuas COM chaw nres nkoj los ntawm cov ntawv qhia zaub mov hauv Benewake App hauv qab nqe lus Serial Port
  7. Nyem CONNECT

Kauj Ruam 3: PC Raws Li Kev Siv Siv Python (PySerial)

PC Raws Kev Siv Siv Python (PySerial)
PC Raws Kev Siv Siv Python (PySerial)
  1. Txuas TFmini LiDAR rau PC siv USB-TTL hloov pauv
  2. Rub tawm thiab qhib PC_Benewake_TFmini_LiDAR.py siv Python IDLE (xyuas kom tseeb tias koj tau nruab PySerial thiab Python ntawm koj lub PC)
  3. Kho qhov chaw nres nkoj COM hauv tus lej kom phim COM chaw nres nkoj ntawm USB-TTL hloov pauv ntawm koj lub PC (saib duab)
  4. Nyem Run tab
  5. Nyem Run Module

** Xa mus rau Kauj Ruam-5 kom piav qhia qhov chaws

Kauj Ruam 4: Kev Siv Raspberry Pi Raws Li

Kev Siv Raspberry Pi Raws Li
Kev Siv Raspberry Pi Raws Li
Kev Siv Raspberry Pi Raws Li
Kev Siv Raspberry Pi Raws Li
Kev Siv Raspberry Pi Raws Li
Kev Siv Raspberry Pi Raws Li
Kev Siv Raspberry Pi Raws Li
Kev Siv Raspberry Pi Raws Li
  1. Txuas TFmini LiDAR rau RPi siv USB-TTL hloov pauv lossis UART chaw nres nkoj siv GPIO
  2. Rub tawm thiab qhib Pi_benewake_LiDAR.py siv Python IDLE
  3. Yog tias koj siv USB-TTL hloov pauv nrog RPi, Qhib Arduino IDE. Nyem rau ntawm Tools -> Serial Port, thiab kho qhov chaws kom raug. Yog tias koj siv UART GPIO chaw nres nkoj, tom qab ntawv sau /dev /ttyAMA0
  4. Khiav cov cai

** Txoj cai tuaj yeem siv los sau qhov nrug, tab sis txij li RPi tsis muaj lub zog ua haujlwm ntau, nws tau qhia kom pom lub teeb ci LED yog tias qhov sau tseg qis dua qis dua qee qhov (schematic rau LED nrog RPi txuas nrog)

Q. Vim li cas siv USB-TTL hloov pauv nrog RPi?

RPi tsuas muaj ib qho chaw nres nkoj UART, thiab qee zaum koj yuav tsum tso ob peb tus qauv uas xav tau UART kev sib txuas lus. USB-TTL muab qhov chaw nres nkoj UART ntxiv rau RPi muab sijhawm rau peb txuas ntau dua ib lub cuab yeej UART (zoo li ob lossis ntau TFmini LiDAR) rau RPi.

Kauj Ruam 5: Txog Txoj Cai

Txog Txoj Cai
Txog Txoj Cai

Txoj cai tuaj yeem faib ua peb ntu:

  • Tsim kom muaj kev sib txuas
  • Sau cov ntaub ntawv
  • Nyeem cov ntaub ntawv

Tsim kom muaj kev sib txuas:

Tom qab ntshuam cov ntaub ntawv header tsim nyog, peb tsim kev sib txuas rau peb TFmini LiDAR los ntawm kev hais qhia nws qhov chaw nres nkoj COM, Baud-tus nqi thiab kev txuas sijhawm tas sijhawm

ser = serial. Serial ('COM7', 115200, sijhawm = 1) #PC

ser = serial. Serial ('/dev/ttyUSB1', 115200, sijhawm = 1) #Raspberry Pi

Sau cov ntaub ntawv:

Cov cai tuaj yeem faib ua ob ntu, sau thiab txais. Txhawm rau kom tau txais cov ntaub ntawv, koj yuav tsum tau ua raws cov lus txib rau TFmini LiDAR (ib feem ntawm cov txheej txheem pib). Hauv qhov no, kuv tau xaiv 4257020000000106. Txawm hais tias RPi khiav tib yam ntawm Python tab sis muaj qhov hloov pauv me me hauv syntax li RPi tsis lees txais cov ntaub ntawv uas tsis yog binary.

ser.write (0x42) yog

ser.write (0x57) ser.write (0x02) ser.write (0x00) ser.write (0x00) ser.write (0x00) ser.write (0x01) ser.write (0x06)

Nyeem cov ntaub ntawv:

Cov kab ntawv muab hauv cov ntaub ntawv-daim ntawv muab rau peb 'tawg' ntawm 9-Byte UART cov lus. Thawj ob Bytes yog kab ntawv header muaj tus nqi hex 0x59 (cim 'Y'). Lawv tuaj yeem nyeem thiab siv los txheeb xyuas qhov pib ntawm UART cov lus.

yog (('Y' == ser.read ()) thiab ('Y' == ser.read ())):

Thaum nyeem kab ntawv header tau nyeem, ob tom ntej bytes, nqa cov ntaub ntawv nyob deb, tuaj yeem nyeem tau. Cov ntaub ntawv nyob deb tau muab faib ua ob pob ntawv 8 -ntsis, Dist_L (Byte3) - Qis 8bits thiab Dist_H (Byte4) - Siab dua 8bits.

Dist_L = ser.read () #Byte3Dist_H = ser.read () #Byte4

Los ntawm kev sib tw Dist_H los ntawm 256, cov ntaub ntawv binary tau hloov pauv los ntawm 8 mus rau sab laug (sib npaug rau "<< 8"). Tam sim no cov ntaub ntawv qis dua 8-ntsis, Dist_L, tuaj yeem yooj yim ntxiv ua rau 16-ntsis cov ntaub ntawv ntawm Dist_Total.

Dist_Total = (txiav (Dist_H) * 256) + (ord (Dist_L)))

Txij li thaum peb muaj 'deciphered' tus nqi nrug nrog peb, tsib byte tom ntej tuaj yeem tsis quav ntsej. Nco ntsoov tias cov ntaub ntawv nyeem tsis raug khaws cia nyob txhua qhov chaw.

rau kuv hauv ntau (0, 5): ser.read ()

** Hauv lwm qhov chaw, koj yuav pom 'ncua' (sijhawm pw hauv Nab hab sej) suav nrog ua ntej qhov kawg ntawm lub voj vim qhov uas TFmini LiDAR muaj 100Hz ua haujlwm zaus. Qhov kev ncua no 'txoj haujlwm qeeb' thiab yuav ua rau cov ntaub ntawv hloov tshiab tom qab qee qhov kev ncua. Kuv ntseeg tias txij li peb twb tau tos cov ntaub ntawv txhawm rau nce mus txog 9-Bytes, yuav tsum tsis txhob muaj lwm qhov kev ncua

#sijhawm.sleep (0.0005) #Qhov ncua tau hais tawm

thaum (ser.in_waiting> = 9):

Pom zoo: