Cov txheej txheem:

Kev Tshawb Fawb Kawm Txog Kev Hloov Harmonic Yooj Yim: 5 Kauj Ruam
Kev Tshawb Fawb Kawm Txog Kev Hloov Harmonic Yooj Yim: 5 Kauj Ruam

Video: Kev Tshawb Fawb Kawm Txog Kev Hloov Harmonic Yooj Yim: 5 Kauj Ruam

Video: Kev Tshawb Fawb Kawm Txog Kev Hloov Harmonic Yooj Yim: 5 Kauj Ruam
Video: Tswv Yexus lub neej thaum pib txug thaum xaus 2024, Kaum ib hlis
Anonim

Los ntawm arrowlikeFollow Ntau los ntawm tus sau:

Taug Kev Strandbeest, Java/Python thiab App Tswj
Taug Kev Strandbeest, Java/Python thiab App Tswj
Taug Kev Strandbeest, Java/Python thiab App Tswj
Taug Kev Strandbeest, Java/Python thiab App Tswj

Hauv chav kawm, peb feem ntau siv lub tswb moos los ua qhov kev sim pendulum, lossis kev sim ua kom sib haum xeeb yooj yim. Nov yog qhov nyuaj, peb tuaj yeem tsim daim duab tiag tiag ntawm nws qhov kev txav mus thiab pom dab tsi yog txoj haujlwm tam sim thiab qhov nrawm, uas yog cov ntaub ntawv ntau ntxiv thiab lom zem.

Thawj lo lus nug, peb yuav tsum txiav txim siab lub cev pendulum yog lub cev tsis muaj qhov hnyav lossis tus pas nrig zoo ib yam. Txoj hlua txoj hauv kev zoo li yooj yim dua. Los ntawm kev xyaum ua ib lub tsev, Kuv muaj cov kev xav pauv pauv hauv qab no: Txoj hauv kev yooj yim tshaj plaws los dai lub pendulum system tuaj yeem dai nws mus rau sab ntug ntawm koj lub qhov rooj. Qhov ntawd ua rau koj ~ 2m pendulum ntev yam tsis tau ua haujlwm tsim kho vaj tsev. Tab sis nws xav tau qhov viav vias yuav tsis kov lub qhov rooj, uas tsuas yog rhuav tshem tag nrho cov kev sim. Yog li lub dav hlau nws viav vias yuav tsum ua kom ncaj ncaj rau koj phab ntsa/qhov rooj. Ib txoj hlua tsis hnyav hnyav ua rau nyias, nws tuaj yeem tig tau yooj yim, thiab ua rau qhov ntsuas ntsuas viav vias yooj yim dua. Peb xav siv ib qho kev ntsuas los sawv cev rau lub xeev viav vias. Cov hlua nyias, xws li cov kab ntses, tuaj yeem ua kom ywj thiab nthuav dav, uas cuam tshuam rau ib qho ntawm peb qhov tseem ceeb tshaj plaws ntsuas los ntawm peb thiab siv hauv qhov sib npaug, uas yog qhov ntev ntawm lub pendulum. Qee qhov kuj tseem yuav cuam tshuam los ntawm qhov kub thiab txias. Qhov hnyav hnyav dai rau ntawm qhov kawg ntawm txoj hlua yuav tsum hnyav txaus kom qhov hnyav ntawm txoj hlua ua tsis zoo. Thov tawm tswv yim yog tias koj pom zoo lossis tsis pom zoo nrog lawv, lossis koj muaj lwm cov tswv yim tsim kev lag luam tawm. Txhawm rau kawm qhov teeb meem no, peb xav tau lub cuab yeej uas yog lub teeb pom kev uas nws qhov hnyav tuaj yeem tsis quav ntsej thiab peb tseem kho lub pendulum system raws li txoj hlua tsis sib xws. Kuv tab tom siv COTS cov khoom siv hluav taws xob uas siv tau, uas xa cov gyro, ntsuas lub ntsuas, thiab cov ntaub ntawv kaum rau peb ntawm kev txuas bluetooth. Cov kev ntsuas no yuav muab khaws cia rau hauv cov ntaub ntawv xov tooj ntawm tes app. Tom qab ntawd, peb yuav tshuaj xyuas cov ntaub ntawv rau peb qhov kev sim ua kom sib haum xeeb yooj yim. Kev txheeb xyuas tus lej tsom mus rau cov ncauj lus hauv qab no: 1) Predict pendulum oscillation period 2) Programmably collect pendulum yooj yim harmonic txav kev sim cov ntaub ntawv 3) Siv kmean rau pab pawg cov ntaub ntawv thiab tshem tawm qhov sib txawv hauv cov txheej txheem tshuaj xyuas 4) Siv sijhawm luv FFT los kwv yees pendulum oscillation zaus

Khoom siv

Bluetooth ntsuas cov cuab yeej

Android xov tooj App: Mus rau Google playstore, tshawb M2ROBOTS thiab teeb tsa kev tswj App. Yog tias nws nyuaj rau nkag mus rau Google playstore, mus ntsib kuv tus homepage rau lwm txoj hauv kev rub tawm app

ntoo pas

ob peb qhov luam tawm 3D

pom cov hniav lossis cov khoom siv hlau zoo sib xws

Kauj Ruam 1: Pendulum yog dab tsi? Yuav Ua Li Cas Tus Qauv?

Muaj ntau tsab xov xwm thiab phau ntawv qhia txog pendulum equation derivation, suav nrog koj cov ntaub ntawv kawm txog physics. Cov ntsiab lus zoo li no yuav zoo dua tsis rov hais dua ntawm no dua. Tsuas yog qhov kev txiav txim siab zaum kawg tau teev tseg ntawm no hais txog lub ncauj lus ntawm "kev sib haum xeeb yooj yim". Txhawm rau kom paub lub sijhawm ntawm tus pendulum, txhua yam peb yuav tsum paub yog qhov ntev ntawm lub pendulum, qhia ua "l", hauv meters.

Yog tias peb paub tseeb tias qhov hnyav nyob ze rau qhov kawg ntawm qhov hnyav uas tsis muaj hlua dai rau hauv tus pivot, thiab lub pendulum tau viav vias ntawm cov ces kaum me θ, hais tsawg dua 15 °, lub sijhawm T1 ntawm cov pendulum tau muab los ntawm:

T1 = 2*pi*(l/g)^0.5

g = lub ntiajteb txawj nqus nrawm, kwv yees li 9.8 m/s^2

Yog tias qhov tsis muaj qhov hnyav hloov pauv los ntawm tus pas nrig zoo ib yam, ntev dua l, nws lub suab sib dhos yooj yim T2 tau muab los ntawm T1 = 2*pi*(2l/3g)^0.5

Ua tau zoo nws muaj lub sijhawm zoo ib yam li lub cev tsis muaj qhov hnyav pendulum ua ob feem peb ntawm txoj hlua tsis sib thooj ntev.

Nov yog keeb kwm yav dhau los, thiab peb tuaj yeem pib npaj peb qhov kev sim.

Kauj Ruam 2: Npaj Tshooj rau Kev Tsim Kho Vajtse

Npaj Cov Khoom Rau Kev Kho Vajtse
Npaj Cov Khoom Rau Kev Kho Vajtse
Npaj Cov Khoom Rau Kev Kho Vajtse
Npaj Cov Khoom Rau Kev Kho Vajtse
Npaj Cov Khoom Rau Kev Kho Vajtse
Npaj Cov Khoom Rau Kev Kho Vajtse

Txhawm rau tsim cov qauv pendulum, peb 3D luam tawm qee qhov, thiab rov ua dua qee yam uas peb twb muaj lawm. Tus qauv pendulum tag nrho yog qhia hauv daim duab 1. Nws yog qhov sib xyaw ntawm 3D luam tawm ntu ua ke nrog qee qhov khoom siv tes ua thiab cov ntoo ntev los ntawm Lowe's.

Ib feem 3D luam tawm hauv daim duab 2 tau dai rau saum ntug ntawm lub qhov rooj, vim tias peb lub qhov rooj yog qhov tiaj tiaj yooj yim rau peb dai ib yam dab tsi. STL cov ntaub ntawv rub tawm txuas:

xiapeiqing.github.io/doc/kits/pendulum/pen…

Ib feem ntsuab hauv daim duab 3 txuas tus pas ntoo mus rau rab riam, thiab rab riam zaum saum ob daim phiaj tsheb nqaj hlau saum lub qhov rooj 3D luam tawm ua ntej. STL cov ntawv rub tawm txuas:

Ob daim ntawm txoj kev tsheb nqaj hlau yog ua los ntawm kev tsoo lub qub saw hniav nyob hauv ib nrab, saib daim duab 4. Ntu hauv daim duab 2 tau npaj qhov loj me me rau lawv. Qhov zoo tshaj plaws peb tuaj yeem ua tus "V" zoo li tus thais hauv ob lub qhov muag pom siv cov ntawv. Ib qho hlau uas muaj qhov ntse, xws li ib rab chais hniav ntug, lossis ib txhais tes ua cov hlau, tuaj yeem zaum sab hauv "V" zoo li tus thais. Yog vim li cas peb xav tau thaj chaw sib cuag me me yog txhawm rau txo lub zog hluav taws xob poob thaum viav vias.

Qhov kawg 3D luam tawm ib feem hauv daim duab 5 yog lub tais me me los tuav lub tshuab ntsuas hluav taws xob.

Rub tawm txuas:

Cov cuab yeej ntsuas bluetooth tsim lub kaum sab xis kwv yees, ntsuas gyro thiab ntsuas kev ntsuas. Txhua cov ntaub ntawv no muaj rau peb los ntawm bluetooth wireless txuas.

Peb yuav ua ntau yam kev sim los ntawm kev siv lub cuab yeej no ntawm txoj haujlwm sib txawv ntawm caj npab pendulum, thiab pom qhov sib txawv.

Kauj Ruam 3: Kuaj Cov Ntaub Ntawv

Kev sim cov ntaub ntawv khaws tseg
Kev sim cov ntaub ntawv khaws tseg
Kev sim cov ntaub ntawv khaws tseg
Kev sim cov ntaub ntawv khaws tseg
Kev sim cov ntaub ntawv khaws tseg
Kev sim cov ntaub ntawv khaws tseg

Muaj ob txoj hauv kev ua tau rau kev sim cov ntaub ntawv khaws cia ua ntej peb txheeb xyuas cov ntaub ntawv tau txais:

1) Siv Android xov tooj App tau teev tseg hauv kab lus yuav tsum teev txhua qhov ntsuas uas tsim los ntawm lub cuab yeej rau hauv cov ntaub ntawv khaws cia hauv koj lub xov tooj SD daim npav. Peb tuaj yeem luam cov ntawv thiab tshaj tawm cov txheej txheem.

2) Siv lub koos pij tawj qhib lub computer, lub PC, lub khoos phis tawj lossis lub khoos phis tawj me me RaspberryPi los tsim kev sib txuas bluetooth rau lub tshuab thiab nyeem cov ntaub ntawv rau lub sijhawm tiag tiag lossis kev tshuaj xyuas offline.

Muaj ob qho tib si zoo thiab tsis zoo rau txhua txoj hauv kev, peb yuav sim ob qho tib si thiab qhia qhov sib txawv hauv cov lus qhia no.

Txog txoj hauv kev (1) siv Android app, thaum peb nyob hauv android App tswj kev sib tham, cov ntaub ntawv xov tooj cua xa los ntawm lub cuab yeej ntsuas bluetooth mus rau lub xov tooj hauv xov tooj yuav raug kaw rau hauv cov ntaub ntawv teev npe hu ua m2flightDatayyyymmdd_hhmmss.txt. Nws tuaj yeem pom hauv koj lub xov tooj hauv xov tooj ntawd rub tawm/m2LogFiles nplaub tshev. Lub nplaub tshev "Download" yog cov ntawv ua ntej uas twb muaj lawm hauv koj lub xov tooj Android OS thiab "m2LogFiles" yog daim nplaub tshev uas App tau tsim. Cov ntsiab lus ntawm cov ntaub ntawv yyyymmdd_hhmmss yog txoj hauv kev los ntsuas qhov kev sim pib lub sijhawm (xyoo, hli, hnub, teev, feeb thiab feeb) hauv cov npe ntawv.

Txhua kab hauv cov ntaub ntawv teev npe yog ib daim ntawv. Nws pib nrog lub sijhawm teem sijhawm, kab lus ua ntej "eam:", ua raws 4 cov ntaub ntawv peb zaug, uas yog:

Accelerometer XYZ axis nyeem ntawv nyob rau hauv raw sensor kho vajtse sau npe rov qab qhov tseem ceeb

Gyroscope XYZ axis nyeem ntawv nyob rau hauv cov nyoos sensor kho vajtse sau npe rov qab qhov tseem ceeb

Magnetometer XYZ axis nyeem ntawv nyob rau hauv cov nyoos sensor kho vajtse sau npe rov qab qhov tseem ceeb

onboard kwv yees Roll/Pitch/Raw hauv qib

Cov ntaub ntawv tsim los siv khoos phis tawj khoos phis tawj yuav siv cov ntaub ntawv zoo ib yam, yog li qhov program peb siv hauv kev txheeb xyuas cov ntaub ntawv yuav tsis cuam tshuam nrog cov ntaub ntawv uas tau tsim los ntawm peb qhov kev pab cuam nab nab lossis hauv app.

Cia peb pib coding siv txoj hauv kev (2).

Txhawm rau cuam tshuam nrog lub cuab yeej ntsuas bluetooth, ob qhov tsw ntawm SDK tau muab:

1) Python SDK, uas tuaj yeem teeb tsa los ntawm "pip3 install m2controller", sej3 yog hom lus siv. Cov piv txwv ntawm cov neeg siv daim ntawv thov tus lej raug khaws cia hauv https://github.com/xiapeiqing/m2robots/tree/maste… Rau qhov kev sim no, peb yuav siv tus nab npawb nab npawb pendulum1.py

2) Java SDK, uas tsis siv rau hauv cov lus qhia no vim tias peb xav tau kev pom tom qab thiab kev tshuaj xyuas ntawm cov ntaub ntawv pendulum tau txais, uas yuav siv zog me ntsis ntxiv rau peb rau program hauv Java.

Python3 cov ntaub ntawv sau cov phiaj xwm qhov chaws muaj ntau cov lus hais rau cov cai ua haujlwm cov ntsiab lus. Ib qho snapshot ntawm qhov chaws tau muab rau ntawm no.

#!/usr/bin/env nab hab sej#-*-coding: UTF-8-*-los ntawm m2controller ntshuam m2controller los ntawm m2controller ntshuam m2Const ntshuam teeb liab ntshuam lub sij hawm ntshuam datetime ntshuam usrCfg ntshuam pendulum2

requestExit = tsis tseeb

################################################################

#peb xav siv tib cov ntaub ntawv teev npe lub rooj sib tham kom cov ntaub ntawv ntsuas ntsuas, pendulum2.py, tuaj yeem tsis lees paub yuav ua li cas peb tau txais cov ntaub ntawv teev cov ntaub ntawv ################# ################################################## logfilename = " m2flightData%s.txt "%(datetime.datetime.fromtimestamp (time.time ()). strftime ('%Y%m%d_%H%M%S')) dataLogfile = qhib (logfilename," w ")

def signal_handler (sig, thav duab):

kev thov thoob ntiaj tebExit luam tawm ('tus neeg siv Ctrl-C kom tawm qhov kev ua haujlwm tiav')

################################################################

#raws li txhua qhov ntsuas cov ntaub ntawv muaj nyob ntawm 20Hz tus nqi, qhov "hu rov qab" no yuav raug hu ############################# ################################# def def callbackfunc (telemetry): strTimeStamp = datetime.datetime.fromtimestamp (time.time ()). strftime ('%H:%M:%S.%f') [:-3] dataStr = "%s, eam:%d,%d,%d,%d,%d,%d, %d, %d, %d, %2.1f, %2.1f, %2.1f / n " %(strTimeStamp, telemetry ['m_fAccelHwUnit'] [0], telemetry ['m_fAccelHwUnit'] [1], telemetry ['m_fAccelHwUnit'] [2], telemetry ['m_fGyroHwUnit'] [0], telemetry ['m_fGyroHwUnit'] [1], telemetry ['m_fGyroHwUnit'] [2], telemetry ['m_fMagHw] 'm_fMagHwUnit'] [1], telemetry ['m_fMagHwUnit'] [2], telemetry ['m_fRPYdeg'] [0], telemetry ['m_fRPYdeg'] [1], telemetry ['m_fRPYdeg'] [2]) ## ####################################### ##############peb luam kab ntawv cov ntaub ntawv rau lub vijtsam thiab khaws cia rau hauv cov ntaub ntawv teev cia ####################### ############################################## print (dataStr) dataLogfile.writlines (dataStr)

################################################################

#pib ua tus tswj hwm, nco ntsoov teeb tsa BleMACaddress los ua koj lub cuab yeej MAC chaw nyob ############################# ################################TODO: cia pib ua ntej BleMACaddress yog tias tsis tau teeb tsa los ntawm tus neeg siv. maub los = m2controller. BleCtrller (m2Const.etDebian, callbackfunc, usrCfg. BleMACaddress) controller.connect () thaum muaj tseeb: ###################### #########################################tos rau ntsuas cov ntaub ntawv tsim thiab xa los ntawm kev ntsuas pendulum cov cuab yeej ####################################################### ############### controller.m_CommsTunnel.waitForNotifications (1.0) yog thov thov Exit: ####################### ##############################################tsev khaws cia ua haujlwm ntawm no thaum peb ua tiav cov ntaub ntawv nkag ####################################### ############## controller.stop () dataLogfile.close () so

################################################################

#kev sau cov ntaub ntawv tiav, tam sim no cia peb txheeb xyuas cov ntaub ntawv teev tseg ###################################### ######################### pendulum2.parseDataLogFile (logfilename)

Txog kev hloov kho mus sij hawm ntev, thov txheeb xyuas

Tam sim no cia piav qhia nws txoj kev ua haujlwm. Qhov kev pab cuam nab nab no tau sau rau saum cov pob uas tuaj yeem rub tau, hu ua m2controller. Cov qib qis dua muaj cov txheej txheem hu rov qab, yog li txhua qhov tau txais kev ntsuas hloov tshiab yuav ua rau muaj nuj nqi rov qab hu peb tau sau, thiab khaws cov ntaub ntawv rau hauv cov ntaub ntawv teev npe hauv zos. Hom ntawv ntawm cov ntaub ntawv cov ntaub ntawv cov ntsiab lus zoo ib yam rau dab tsi yog tsim los ntawm Android app app, yog li cov ntaub ntawv teev cov ntaub ntawv tsim los ntawm ob qho kev pab cuam nab hab sej lossis andriod companion app sib pauv tau.

Tus neeg siv ctrl-C teeb liab, ntes los ntawm lub kaw lus ua haujlwm, tau dhau mus rau qhov haujlwm, thiab nres lub voj tsis kawg uas tos txog qhov tuaj txog tshiab ntawm cov ntaub ntawv ntsuas.

Txog tam sim no, cov ntaub ntawv teev npe tau tsim tiav, thiab txoj haujlwm no yuav hu rau qhov kev tshuaj xyuas los kawm peb cov txiaj ntsig kev sim.

Nov yog ob qhov kev sim, thiab kev sib piv qhia pom qhov sib txawv tseem ceeb los ntawm kev txuas 7gram ntaus ntawv ntawm qhov chaw sib txawv.

Hauv daim duab 2, peb siv lub ntsuas los txiav txim qhov hnyav ntawm lub cuab yeej ntsuas bluetooth.

Daim duab 3 piav qhia txog kev teeb tsa pendulum qhov twg 7gram ntaus ntawv txuas rau qhov qis kawg ntawm lub pendulum. Teeb teeb tsa hauv daim duab 4 muaj 7gram pawg nyob ze rau qhov viav vias pivot.

Daim duab 5 yog qhov pom ze ntawm tus qauv pendulum.

Kauj Ruam 4: Txheeb Xyuas Cov Ntaub Ntawv

Kev Txheeb Xyuas Cov Ntaub Ntawv
Kev Txheeb Xyuas Cov Ntaub Ntawv
Kev Txheeb Xyuas Cov Ntaub Ntawv
Kev Txheeb Xyuas Cov Ntaub Ntawv
Kev Txheeb Xyuas Cov Ntaub Ntawv
Kev Txheeb Xyuas Cov Ntaub Ntawv

Cov cuab yeej ntsuas bluetooth hnyav ~ 7gram, uas hnyav ntau dua li ~ 1.6meter ntoo ntev. Siv qhov kev xav ntawm "txhav tsis sib xws pas nrig", thiab peb muaj lub sijhawm pendulum equation, T1 = 2*pi*(2l/3g)^0.5

Kom tau txais lub ntiajteb txawj nqus tas li, peb tuaj yeem siv 9.8m/s^2. Tab sis qhov tseeb dua qhov nqus qhov tsis tu ncua ntawm ib qho chaw geolocation tuaj yeem muab rov qab los ntawm cov vev xaib no:

www.wolframalpha.com/widgets/view.jsp?id=e…

Rau san francisco, nws yog 9.81278m/s^2

Lub pendulum ntev tau ntsuas kom yog 64.5 ``

2*pi*sqrt (2*64.5*0.0254/(3*9.81278)) muab lub sijhawm pendulum kev cia siab ntawm 2.0962 (sec).

Cia saib seb nws puas pom zoo nrog peb cov kev sim.

Hauv qhov kev sim zaum 1, kev teeb tsa pendulum muaj 7gram cov cuab yeej txuas rau qhov qis kawg ntawm lub pendulum. Kuv daim ntawv teev npe tuaj yeem rub tawm hauv:

xiapeiqing.github.io/doc/kits/pendulum/pen…

Hloov nws mus rau "PendulumTestData.txt" thiab muab tso rau hauv tib lub nplaub tshev ntawm qhov kev tshuaj xyuas nab hab sej. Ib qho snapshot ntawm qhov chaws tau muab rau ntawm no.

#!/usr/bin/env python#-*-coding: UTF-8-*-import csv ntshuam matplotlib.pyplot li plt plt.style.use ('seaborn-whitegrid') ntshuam numpy li np los ntawm hnub tim ntshuam datetime, timedelta ntshuam seaborn raws li sns los ntawm sklearn.cluster ntshuam KMeans los ntawm kev suav sau ntshuam ################################## #################################txoj haujlwm no sau cov ntaub ntawv tshuaj xyuas haujlwm ua haujlwm ############ ####################################### ## def parseDataLogFile (cov ntaub ntawv npe): ##################################### #######################extract cov ntaub ntawv hauv cov cim cais cov ntaub ntawv teev cov ntaub ntawv (CSV) thiab khaws cov ntsiab lus hauv txhua kab ntawv rau hauv ib qho ntab-yam sib txawv ## ################################################## ############ nrog qhib (datafilename) raws li csvfile: readCSV = csv.reader (csvfile, delimiter = ',') timestampS = fAccelHwUnit_y = fAccelHwUnit_y = fAccelHwUnit_y = fAccelHwUnit_y = fAccelHwUnitz = fGyroHwUnit_x = fGyroHwUnit_y = fGyroHwUnit_z = fMagHwUnit_x = fMagHwUnit_y = fMagHwUni t_z = fRPYdeg_r = fRPYdeg_p = fRPYdeg_y = rau kab hauv readCSV: sim: x = datetime.strptime (row [0].split (',') [0], '%H:%M:%S.%f ') timestampS.append (timedelta (teev = x.hour, feeb = x.minute, vib nas this = x.second, microseconds = x.microsecond).total_seconds ()) fAccelHwUnit_x.append (ntab (kab) [1] [4:])) fAccelHwUnit_y.append (float (row [2])) fAccelHwUnit_z.append (float (row [3])) fGyroHwUnit_x.append (float (row [4])) fGyroHwUnit_y.append (kab [5])) fGyroHwUnit_z.append (float (row [6])) fMagHwUnit_x.append (float (row [7])) fMagHwUnit_y.append (float (row [8])) fMagHwUnit_z.append (float (row (8))) [9])) fRPYdeg_r.append (float (row [10])) fRPYdeg_p.append (float (row [11])) fRPYdeg_y.append (float (row [12])) except: pass timestampS = np.asarray (timestamps) timestamps = timestamps - timestamps [0] fAccelHwUnit_x = np.asarray (fAccelHwUnit_x) fAccelHwUnit_y = np.asarray (fAccelHwUnit_y) fAccelHwUnit_z = np.asarray (fAccelHwUnit_z) fGyroHwUnit_x = np.asarray (fGyroHwUnit_x) fGyroHwUnit_y = np.asarray (fGyroHwUnit_y) fGyroH wUnit_z = np.asarray (fGyroHwUnit_z) fMagHwUnit_x = np.asarray (fMagHwUnit_x) fMagHwUnit_y = np.asarray (fMagHwUnit_y) fMagHwUnit_z = np.asarray (fMagHwUnit_z) fRPYdeg_r = np.asarray (fRPYdeg_r) fRPYdeg_p = np.asarray (fRPYdeg_p) fRPYdeg_p = fRPYdeg_p - np.mean (fRPYdeg_p) fRPYdeg_y = np.asarray (fRPYdeg_y)

################################################################

#peb xav tau kwv yees qhov tseeb ntawm qhov piv txwv piv rau lub sijhawm kwv yees tseeb ################################# ############################# FsHz = getSamplingIntervalS (timestampS) ################ #################################################### siv cov ntsiab lus suab hauv tus cwj pwm hais txog kev siv cov txheej txheem rau pendulum sijhawm tsom xam ############################## ########################## analyse_timeSequence (timestampS, fRPYdeg_p, FsHz, 'pitch') ########### ################################################## ####siv kev ntsuas ntsuas ntsuas cov khoom nyoos rau lub sijhawm ntsuas pendulum ################################### ########################### analyse_timeSequence (timestampS, fAccelHwUnit_x, FsHz, 'accel') ########### ################################################## ####siv gyro raw ntsuas ntsuas tso tawm rau lub sijhawm ntsuas pendulum ################################# ########################### analyse_timeSequence (timestampS, fGyroHwUnit_y, FsHz, " gyro ') luam tawm (' ua tiav, zoo siab nrog:-) ') plt.show () ########################### #################################hauv bluetooth kev sib tham txheej txheem, muaj tsawg zaus uas cov ntaub ntawv tuaj yeem ua tau yuav ploj#peb siv K-txhais kom cais 20Hz meaurement cov ntaub ntawv los ntawm qhov txawv, uas tshwm sim los ntawm pob ntawv poob#dhia mus rau "teeb liab thiab kab ke kom paub meej ntxiv" ################ ###################################################### def getSamplingIntervalS (timestampS): plt.figure () sampleIntervalS = np.diff (timestampS) sns.distplot (sampleIntervalS) plt.ylabel ('histogram') plt.xlabel ('ntsuas nruab nrab (s)') clusterCnt = 5 km = KMeans (n_clusters = clusterCnt) km.fit (sampleIntervalS.reshape (-1, 1)) centroids = km.cluster_centers_ elemCnt = Counter (km.labels_) tshwm simCnt = rau ii hauv thaj tsam (clusterCnt): tshwm simCnt.append (elemCnt [ii]) FsHz = 1/centroids [tshwm simCnt.index (max (tshwm simCnt))] rov qab FsHz

################################################################

#siv spectrometer, piv txwv li, lub sijhawm luv FFT kom tau txais qhov feem cuam tshuam, qhov siab tshaj plaws yog peb qhov kev kwv yees zoo tshaj plaws ntawm pendulum oscillation ######################## ###################################### def def_timeSequence (timestampS, timeSeqData, FsHz, strComment): fig, (ax1, ax2) = plt.subplots (nrows = 2) ax1.plot (timestampS, timeSeqData, marker = 'o', markerfacecolor = 'blue', markersize = 2, color = 'skyblue', linewidth = 1) ax1.set_title ("pendulum lub sijhawm ntsuas ntsuas - %s" %strComment) ax1.set_xlabel ("piv txwv lub sijhawm (thib ob)") ax1.set_ylabel (strComment); NFFT = 2048 # qhov ntev ntawm ntu qhov rai

Pxx, freqs, bins, im = ax2.specgram (timeSeqData, NFFT = NFFT, Fs = FsHz, noverlap = NFFT/2)

ax2.set_title ("Spectrogram") ax2.set_xlabel ("kuaj") ax2.set_ylabel ("zaus (Hz)");

# Txoj kev `specgram 'xa 4 yam khoom. Lawv yog:

# - Pxx: periodogram # - freqs: vector zaus # - bins: cov chaw nruab nrab ntawm lub sijhawm bins # - im: matplotlib.image. AxesImage piv txwv piv rau cov ntaub ntawv hauv cov phiaj pkresult = np.where (Pxx == np.amax (Pxx)) oscFreqHz = freqs [pkresult [0] [0] print ('pendulum oscillation Freq (Hz) =%f, Period (Sec) =%f, kwv yees cov ntaub ntawv qhov chaw:%s'%(oscFreqHz, 1/oscFreqHz, strComment)) rov qab 1/oscFreqHz

################################################################

#peb yuav tsum ua qhov haujlwm no ntawm nws tus kheej, piv txwv li, tsis raug hu los ntawm pendulum1.py,#peb txhais lub neej ntawd cav cov ntaub ntawv lub npe yuav raug tshuaj xyuas #################### ################################################################################################################################################################################ Yog tias muaj ": defaultFilename = './PendulumTestData.txt' ntshuam os.path yog os.path.isfile (defaultFilename): parseDataLogFile (defaultFilename) lwm: print (" default log file %s not existing " %defaultFilename)

Txog kev hloov kho mus sij hawm ntev, thov txheeb xyuas

Cov peev txheej muaj cov ncauj lus ntxaws ntxaws, cia peb muab cov ntsiab lus qib siab ntawm kev kwv yees kwv yees ntawm no.

1) Peb xub nyeem CSV cov ntsiab lus hauv computer, siv pob sej hu ua "csv". Peb muaj kev ntsuas ib ntus.

21: 34: 26.362, eam: 0, -128, 14464, -8, 144, -96, 2112, -1280, 1664, -0.5, -5.5, 40.5

21: 34: 26.373, eam: 128, 0, 14272, -8, 136, 40, 2112, -1280, 1664, -0.5, -6.5, 40.0

21: 34: 26.412, eam: 448, -64, 14208, -8, 136, 24, 2176, -1280, 1664, -0.5, -7.5, 40.5

21: 34: 26.462, eam: 448, -128, 14272, -8, 120, 16, 2176, -1280, 1664, -0.5, -8.0, 40.5

2) Txij li qhov ntsuas tus nqi yog qhov tseem ceeb heev thiab qhia ncaj qha pendulum lub sijhawm kwv yees yuam kev, peb xav kwv yees lawv. Peb qhov ntsuas ntsuas lub sijhawm yog 50ms, piv txwv li, 20Hz. Qhov nruab nrab dhau txhua qhov kev ntsuas zoo li OK, tab sis peb qee zaum poob cov ntaub ntawv xa mus, qhov hloov pauv hloov ua 100ms lossis 150ms, …

Yog tias peb npaj qhov tshwm sim ntawm cov ntaub ntawv no, saib Daim Duab 1, ua tib neeg, peb tuaj yeem yooj yim muaj qhov muag pom ntawm 0.05sec. Txawm li cas los xij, peb puas tuaj yeem ua tau zoo dua qhov ntawd?

Peb yuav tsum siv txoj kev faib tawm los tsuas yog xaiv qhov zoo rau kev suav nruab nrab. Nab hab sej muaj lub thawv npe hu ua KMeans los pab peb ua pawg, lossis hais txog kev faib tawm. Cov tswv yim no tau siv hauv ntau cov ntaub ntawv loj thiab AI thaj chaw.

3) Daim duab 2 muaj ob daim duab. Cov phiaj xwm saum toj kawg nkaus yog lub sijhawm ua ntu zus ntawm peb qhov kev ntsuas lub kaum sab xis hauv deg. Los ntawm kev xa mus rau x-axis timestamp hauv Thib Ob, peb tuaj yeem nyeem kwv yees li 22.5 mus hauv 50second, uas txhais mus rau 2.22 Sec pendulum period. Puas muaj ib txoj hauv kev rau txheej txheem txheej txheem no thiab muaj qhov kwv yees tseeb dua? Yog, peb tuaj yeem siv cov cuab yeej ua zauv hu ua spectrogram, uas siv cov ntawv me me ntawm cov ntaub ntawv ntsuas thiab qhia peb nws qhov zaus, saib daim duab hauv qab no. Y-axis nyeem ntawv rau kab uas tsaus tshaj plaws yog qhov pendulum oscillation zaus. Ua kab kab rov tav lees paub qhov pendulum oscillation tsis hloov pauv txhua qhov kev sim. Tus nqi thim rov qab ntawm oscillation zaus yog lub sijhawm pendulum oscillation.

Daim ntawv tshaj tawm zaum kawg uas ua los ntawm txoj haujlwm yog cov ntawv sau tseg:

pendulum oscillation Freq (Hz) = 0.449224, Lub Sijhawm (Sec) = 2.226059, kwv yees cov ntaub ntawv qhov chaw: suab

Peb tuaj yeem pom peb qhov muag pom yav dhau los ntawm tes suav qhov txiaj ntsig, 2.22sec, zoo ib yam nrog cov phiaj xwm suav tus nqi.

Piv rau 2.0962 (sec) theoretically computed value, peb muaj ~ 5% qhov yuam kev seem. Yuav ua li cas kom tshem ntawm lawv? Nco ntsoov qhov kev xav tias yog "txhav tsis sib xws pas nrig"? Txawm tias 7 grams qhov hnyav ntxiv zoo li tsis tseem ceeb, nws yog qhov loj tshaj ntawm qhov ua yuam kev ntxiv.

Tam sim no peb txav lub cuab yeej, ze rau pivot. Saib cov kauj ruam dhau los rau daim duab ze. Cov ntaub ntawv teev npe kuv tsim tau tuaj yeem rub tawm ntawm no:

xiapeiqing.github.io/doc/kits/pendulum/pen…

Khiav tib txoj kev ntsuas ntsuas, thiab peb tau Txais Lub Sijhawm ntawm 2.089867 (Sec), saib daim duab 3, uas yuav luag zoo ib yam rau kev kwv yees kwv yees kwv yees. Zoo kawg!

Txij li thaum peb tsis tsuas yog viav vias ntsuas lub kaum sab xis, tab sis kuj ntsuas gyroscopic thiab ntsuas kev ntsuas ntawm tib tus lej. Khiav qhov ntsuas tib yam rau lwm ob qhov ntsuas, peb tau txais txiaj ntsig hauv daim duab 4 thiab 5. Kev kwv yees los ntawm tag nrho peb qhov kev ntsuas ntsuas pom zoo, uas ua rau peb muaj kev ntseeg siab ntawm kev ua tiav ntawm peb qhov kev sim.

Nov yog qhov tshwm sim raws li qhov tso tawm zaum kawg ntawm kev ua haujlwm nab nab:

pendulum oscillation Freq (Hz) = 0.478499, Lub Sijhawm (Sec) = 2.089867, kwv yees cov ntaub ntawv qhov chaw: suab

pendulum oscillation Freq (Hz) = 0.478499, Lub Sijhawm (Sec) = 2.089867, kwv yees cov ntaub ntawv qhov chaw: nrawm

pendulum oscillation Freq (Hz) = 0.478499, Lub Sijhawm (Sec) = 2.089867, kwv yees cov ntaub ntawv qhov chaw: gyro

Kev xav zaum kawg hauv cov kauj ruam no, yuav ua li cas kev kwv yees kwv yees zoo ib yam siv cov ntaub ntawv sib txawv ntawm cov ntaub ntawv? Qhov no yog counter-intuition. Kuv yuav tso lo lus nug no rau cov nyeem. Nov yog cov lus qhia: nco ntsoov peb siv lub sijhawm luv FFT los kwv yees qhov zaus oscillation? Hauv cov lej digital, qhov kwv yees kwv yees tau muab tso rau hauv cov thoob sib cais tsis siv cov lej kwv yees.

Kauj Ruam 5: Cov Lus Qhia Ua Haujlwm Yav Tom Ntej

Muaj ob peb pawg kev pom zoo ua haujlwm yav tom ntej.

Hauv qib ua ntej, peb tswj kom txo peb qhov kev sim ua yuam kev los ntawm ~ 5% mus rau tsawg dua 1%, peb puas tuaj yeem ua tau zoo dua qhov ntawd? Kev ceeb toom qhov ntau ntawm qhov oscillation txo qis zuj zus, ib qho ua rau tuaj yeem yog huab cua rub tshwm sim thaum viav vias lub pendulum. Cov ntoo khaub lig seem ntawm lub pendulum tej zaum yuav tsum tau hloov kho kom zoo li qub kom thiaj li txo tau lub zog aerodynamic.

Peb puas tuaj yeem thov lub sijhawm sib txawv tau txais kev kawm siv cov txheej txheem lim hloov pauv kom tso tawm qhov siab tshaj qhov ntsuas qhov siab. Nyob rau lub sijhawm no, txheeb xyuas qhov sib txawv ntawm qhov txo qis yuav muaj zog sab nraud.

Peb tsis tuaj yeem pom dab tsi yooj yim dua li "yooj yim sib haum xeeb txav". Peb puas tuaj yeem siv cov chaw uas peb txheeb xyuas lub pendulum los tshuaj xyuas qee yam nyuab dua, kev ua kis las, foob pob foob pob dej tso ua ntu zus, thiab lwm yam?

Zoo siab hacking

Pom zoo: