Cov txheej txheem:

Motion Tracking Siv MPU-6000 thiab Raspberry Pi: 4 Cov Kauj Ruam
Motion Tracking Siv MPU-6000 thiab Raspberry Pi: 4 Cov Kauj Ruam

Video: Motion Tracking Siv MPU-6000 thiab Raspberry Pi: 4 Cov Kauj Ruam

Video: Motion Tracking Siv MPU-6000 thiab Raspberry Pi: 4 Cov Kauj Ruam
Video: Qhiab Siv AI Motion Capture for iclone 2024, Hlis ntuj nqeg
Anonim
Image
Image

MPU-6000 yog 6-Axis Motion Tracking Sensor uas muaj 3-Axis accelerometer thiab 3-Axis gyroscope kos rau hauv. Qhov ntsuas no muaj peev xwm taug qab qhov tseeb ntawm qhov chaw thiab qhov chaw ntawm ib yam khoom hauv lub dav hlau 3-dimensional. Nws tuaj yeem ua haujlwm hauv cov kab ke uas xav tau kev tshuaj xyuas txoj haujlwm mus rau qhov siab tshaj plaws.

Hauv qhov kev qhia no kev cuam tshuam ntawm MPU-6000 sensor module nrog raspberry pi tau piav qhia. Txhawm rau nyeem qhov tseem ceeb ntawm kev nrawm thiab tig lub kaum ntse ntse, peb tau siv raspberry pi nrog I2c adapter. Qhov I2C adapter ua rau kev txuas mus rau lub ntsuas qhov ntsuas tau yooj yim thiab ntseeg tau ntau dua.

Kauj Ruam 1: Yuav Tsum Kho Vajtse:

Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse

Cov ntaub ntawv uas peb xav tau kom ua tiav peb lub hom phiaj suav nrog cov khoom siv hauv qab no:

1. MPU-6000

2. Raspberry Pi

3. I2C Cable

4. I2C Shield rau raspberry pi

5. Ethernet cable

Kauj ruam 2: Khoos phis tawj sib txuas:

Kho vajtse Hookup
Kho vajtse Hookup
Kho vajtse Hookup
Kho vajtse Hookup

Tshooj khoos phis tawj sib txuas ntu piav qhia qhov txuas txuas uas xav tau ntawm lub ntsuas cua thiab raspberry pi. Ua kom muaj kev sib txuas raug yog qhov tseem ceeb xav tau thaum ua haujlwm ntawm ib qho system rau qhov xav tau cov zis. Yog li, qhov xav tau kev sib txuas yog raws li hauv qab no:

MPU-6000 yuav ua haujlwm dhau I2C. Nov yog qhov piv txwv kab hluav taws xob daim duab, qhia txog yuav ua li cas xaim txhua lub interface ntawm lub sensor.

Tawm-ntawm-lub thawv, lub rooj tsavxwm tau teeb tsa rau I2C interface, zoo li peb pom zoo siv qhov kev sib txuas no yog tias koj tsis ntseeg lwm yam.

Txhua yam koj xav tau yog plaub lub xov hlau! Tsuas yog plaub qhov kev sib txuas xav tau Vcc, Gnd, SCL thiab SDA tus pin thiab cov no txuas nrog kev pab ntawm I2C cable.

Cov kev sib txuas no tau qhia hauv cov duab saum toj no.

Kauj Ruam 3: Txoj Cai rau Tsab Ntawv Teev Npe:

Txoj Cai rau Kev Tshawb Fawb
Txoj Cai rau Kev Tshawb Fawb

Qhov zoo ntawm kev siv raspberry pi yog, uas muab rau koj hloov pauv ntawm cov lus programming uas koj xav tau los teeb tsa lub rooj tsav xwm txhawm rau txhawm rau cuam tshuam lub sensor nrog nws. Kev siv cov txiaj ntsig zoo ntawm pawg thawj coj no, peb tab tom qhia ntawm no nws cov phiaj xwm hauv nab hab sej. Nab hab sej yog ib qho ntawm cov lus yooj yim programming nrog cov lus yooj yim tshaj plaws. Cov nab npawb nab npawb rau MPU-6000 tuaj yeem rub tawm los ntawm peb cov zej zog GitHub uas yog Dcube Store

Ntxiv rau qhov yooj yim ntawm cov neeg siv, peb tab tom piav qhia cov cai ntawm no thiab:

Raws li thawj kauj ruam ntawm kev sau npe, koj yuav tsum rub tawm SMBus lub tsev qiv ntawv thaum muaj nab nab vim tias lub tsev qiv ntawv no txhawb nqa cov haujlwm siv hauv txoj cai. Yog li, txhawm rau rub lub tsev qiv ntawv koj tuaj yeem mus ntsib qhov txuas hauv qab no:

pypi.python.org/pypi/smbus-cffi/0.5.1

Koj tuaj yeem luam cov cai ua haujlwm los ntawm no kuj:

ntshuam smbus

lub sij hawm ntshuam

# Tau I2C busbus = smbus. SMBus (1)

# MPU-6000 chaw nyob, 0x68 (104)

# Xaiv gyroscope teeb tsa sau npe, 0x1B (27)

# 0x18 (24) Qhov ntsuas tag nrho = 2000 dps

bus.write_byte_data (0x68, 0x1B, 0x18)

# MPU-6000 chaw nyob, 0x68 (104)

# Xaiv cov ntawv teev npe kev ntsuas tus ntsuas, 0x1C (28)

# 0x18 (24) Qhov ntsuas tag nrho = +/- 16g

bus.write_byte_data (0x68, 0x1C, 0x18)

# MPU-6000 chaw nyob, 0x68 (104)

# Xaiv lub zog tswj kev sau npe1, 0x6B (107)

# 0x01 (01) PLL nrog xGyro siv

bus.write_byte_data (0x68, 0x6B, 0x01)

sijhawm.s pw (0.8)

# MPU-6000 chaw nyob, 0x68 (104)

# Nyeem cov ntaub ntawv rov qab los ntawm 0x3B (59), 6 bytes

# Accelerometer X-Axis MSB, X-Axis LSB, Y-Axis MSB, Y-Axis LSB, Z-Axis MSB, Z-Axis LSB

cov ntaub ntawv = bus.read_i2c_block_data (0x68, 0x3B, 6)

# Hloov cov ntaub ntawv

xAccl = cov ntaub ntawv [0] * 256 + cov ntaub ntawv [1]

Yog tias xAccl> 32767:

xAccl -= 65536

yAccl = cov ntaub ntawv [2] * 256 + cov ntaub ntawv [3]

Yog tias yAccl> 32767:

yAccl -= 65536

zAccl = cov ntaub ntawv [4] * 256 + cov ntaub ntawv [5]

yog zAccl> 32767:

zAccl -= 65536

# MPU-6000 chaw nyob, 0x68 (104)

# Nyeem cov ntaub ntawv rov qab los ntawm 0x43 (67), 6 bytes

# Gyrometer X-Axis MSB, X-Axis LSB, Y-Axis MSB, Y-Axis LSB, Z-Axis MSB, Z-Axis LSB

cov ntaub ntawv = bus.read_i2c_block_data (0x68, 0x43, 6)

# Hloov cov ntaub ntawv

xGyro = cov ntaub ntawv [0] * 256 + cov ntaub ntawv [1]

yog xGyro> 32767:

xwm -65536

yGyro = cov ntaub ntawv [2] * 256 + cov ntaub ntawv [3]

Yog tias yGyro> 32767:

yGyro -= 65536

zGyro = cov ntaub ntawv [4] * 256 + cov ntaub ntawv [5]

yog zGyro> 32767:

zGyro -= 65536

# Cov ntaub ntawv tso tawm rau lub vijtsam

luam "Kev nrawm hauv X-Axis: %d" %xAccl

luam "Kev nrawm hauv Y-Axis: %d" %yAccl

luam "Kev nrawm hauv Z-Axis: %d" %zAccl

luam "X-Axis ntawm Kev Hloov: %d" %xGyro

luam "Y-Axis ntawm Kev Hloov: %d" %yGyro

luam "Z-Axis ntawm Kev Hloov: %d" %zGyro

Txoj cai tau ua tiav siv cov lus txib hauv qab no:

$> nab nab MPU-6000.py gt; nab hab sej MPU-6000.py

Cov zis ntawm lub ntsuas tau pom hauv daim duab saum toj no rau kev siv ntawm tus neeg siv.

Kauj Ruam 4: Cov ntawv thov:

Cov ntawv thov
Cov ntawv thov

MPU-6000 yog lub suab ntsuas lub suab ntsuas, uas pom nws daim ntawv thov hauv kev sib cuam tshuam ntawm cov xov tooj ntawm tes thiab ntsiav tshuaj. Hauv cov xov tooj ntawm tes cov cuab yeej no tuaj yeem ua haujlwm hauv cov ntawv thov xws li kev hais lus taw tes rau kev siv thiab tswj lub xov tooj, txhim kho kev ua si, ua kom muaj kev muaj tiag, ua kom pom cov duab pom thiab pom, thiab taug kev thiab tsheb nqaj hlau. MotionTracking thev naus laus zis tuaj yeem hloov kho lub xov tooj thiab cov ntsiav tshuaj rau hauv cov cuab yeej ntse 3D uas tuaj yeem siv rau hauv cov ntawv thov xws li kev saib xyuas kev noj qab haus huv thiab kev tawm dag zog mus rau cov kev pabcuam raws qhov chaw.

Pom zoo: