Cov txheej txheem:

Arduino Otto Neeg Hlau Nrog Lub Xeev Tshuab: 4 Kauj Ruam
Arduino Otto Neeg Hlau Nrog Lub Xeev Tshuab: 4 Kauj Ruam

Video: Arduino Otto Neeg Hlau Nrog Lub Xeev Tshuab: 4 Kauj Ruam

Video: Arduino Otto Neeg Hlau Nrog Lub Xeev Tshuab: 4 Kauj Ruam
Video: NOOBS PLAY CLASH ROYALE FROM START LIVE 2024, Hlis ntuj nqeg
Anonim
Image
Image

Txheej txheem cej luam

Hauv txoj haujlwm no, kuv xav qhia koj txoj hauv kev ntawm kev ua haujlwm Otto Robot, uas yog Arduino raws li DIY neeg hlau. Siv YAKINDU Statechart Cov Cuab Yeej (pub dawb rau kev lag luam) peb tuaj yeem siv lub xeev cov tshuab yooj yim los teeb tsa tus yam ntxwv ntawm Otto Robot thiab tsim C/C ++ code. Peb yuav siv ib qho ntawm lawv cov piv txwv los nthuav tus cwj pwm rau peb nyiam.

Rau cov tib neeg uas tsis paub tias lub xeev lub tshuab yog dab tsi thiab tsis xav kom yws los ntawm qhov nyuaj Wikipedia tsab xov xwm, ntawm no yog lus piav qhia me me:

Lub xeev lub tshuab tsuas yog cov nodes thiab txoj hauv kev ntawm cov nodes no. Koj muaj lub hauv paus pib thiab tuaj yeem coj txoj hauv kev mus rau lwm qhov ntawm qhov nyob ntawm lawv tus tiv thaiv, uas tuaj yeem sawv cev los ntawm cov xwm txheej. Cov xwm txheej no tau tsa los ntawm lub xeev lub tshuab nws tus kheej lossis los ntawm sab nraud (zoo li lub luag haujlwm, thiab lwm yam).

Cov cuab yeej nws tus kheej siv kev rub & poob interface thiab hom lus tshwj xeeb. Kuv yuav hla nws rau koj, yog li koj tsis tas yuav khawb dhau lawv cov ntaub ntawv kom tau txais koj li Otto thiab khiav. Kev teeb tsa IDE tsis nyuaj heev, vim tias txhua qhov plug-ins, thiab lwm yam yuav tsum tau teeb tsa cia.

Khoom siv

Otto Robot lossis Zowi Robot

Ob qho ntawm cov neeg hlau no ua tau zoo ib yam thiab siv tib API. Tus Neeg Hlau Otto yog tus neeg hlau DIY, nrog nws ntu hauv online, npaj yuav luam tawm nrog lub tshuab luam ntawv 3D yog tias koj muaj. Lwm txoj hauv kev yog Zowi Robot, uas tuaj yeem yuav online thiab npaj siv.

YAKINDU Statechart Cov Cuab Yeej

Cov cuab yeej uas peb yuav siv los ua qauv lub xeev lub tshuab. Koj tuaj yeem pib nrog 30 hnub sim thiab tau txais daim ntawv tso cai pub dawb rau kev lag luam tsis siv tom qab.

Dab noj hnub C ++ IDE rau Arduino Plugin

Peb tsis tas yuav rub nws los ntawm tus kheej, vim IDE ua rau peb. Kuv tseem xav tias nws yuav zoo los sau nws ntawm no.

Kauj Ruam 1: Teeb Txhua Yam

Nkag Siab Yuav Ua Li Cas Interface Otto
Nkag Siab Yuav Ua Li Cas Interface Otto

Tom qab teeb tsa IDE, khiav nws thiab teeb tsa chaw ua haujlwm nyob txhua qhov chaw ntawm koj lub pc (teeb tsa zoo ib yam rau kev siv Eclipse thawj zaug). Thaum qhov haujlwm tau pib ua tiav, nyem rau ntawm nplooj ntawv txais tos thiab nyem rau 'File -> New -> Piv txwv …' thiab tom qab ntawd xaiv 'YAKINDU Statechart Piv txwv', tos me ntsis thiab tshawb rau "Embedded Systems -> Zowi (C ++)) "piv txwv.

TSEEM CEEB: Nyem rau ntawm sab xis sab xis hu ua 'Install Dependencies …'! Qhov no teeb tsa txhua yam rau koj, yog li koj tsis tas yuav txhawj xeeb txog Tsev Qiv Ntawv, Plug-Ins thiab lwm yam. Rub tawm qhov piv txwv, ua raws cov lus qhia hauv "Embedded Systems -> Zowi (C ++)" piv txwv thiab tom qab ntawd txuas ntxiv nrog cov kauj ruam tom ntej.

Kauj Ruam 2: Nkag Siab Yuav Ua Li Cas cuam tshuam rau Otto

Mus rau hauv ".sct" cov ntaub ntawv thiab hloov kho lub xeev lub tshuab rau koj nyiam. Ntawm sab xis yog cov ntawv qhia zaub mov nrog txhua yam khoom muaj. Peb tsuas yog xav paub txog lub xeev thiab kev hloov pauv.

Hauv daim duab, koj tuaj yeem pom, tias kuv tau sau qee yam khoom mus rau qhov hloov pauv; "tom qab X s" zoo nkauj piav qhia tus kheej thiab "ib txwm" tsuas yog txhais tau tias, nws mus rau ntawd tom qab ua tiav txoj cai los ntawm Xeev. Qhov "nkag /" txhais tau tias, txoj cai yuav tsum tau ua tom qab nkag mus rau lub xeev.

IDE suav nrog lub xeev lub tshuab rau C ++, uas yog Arduino ua raws. Txhawm rau siv cov yam ntxwv ntawm Otto, peb yuav tsum ua haujlwm me ntsis peb tus kheej nkag mus rau lub interface.

Cov ntsiab lus hauv qab no tuaj yeem siv los txhais cov khoom rau lub xeev lub tshuab siv:

constants, uas tuav qhov tseem ceeb thiab tsis tuaj yeem hloov pauv

sib txawv, uas tuav qhov tseem ceeb thiab tuaj yeem hloov pauv

kev ua haujlwm, uas yuav tsim tawm rau virtual C ++ txoj hauv kev rau kev ua haujlwm

interface:

const PIN_YL: integer = 2 const PIN_YR: integer = 3 const PIN_RL: integer = 4 const PIN_RR: integer = 5 const suab: integer = 2 const mouth_heart: integer = 13 const mouth_happyOpen: integer = 11 ua haujlwm zowi_init (YL: integer, YR: integer, RL: integer, RR: integer) operation zowi_home () operation zowi_putMouth (mouthType: integer) operation zowi_sing (songName: integer) operation zowi_walk (steps: real, T: integer, dir: integer) operation zowi_shakeLeg ()

Cov Lus Qhia Pro: yog tias koj tsis paub yuav nkag mus rau qee qhov lossis zoo li muaj qhov ua yuam kev, nias "ctrl+space" kom tau txais qee cov lus qhia ntawm yam koj tuaj yeem nkag mus.

Ib qho ntxiv, koj yuav tsum saib mus rau hauv cov piv txwv, lawv muaj qee qhov chaws nyob hauv ib yam nkaus! Koj kuj tseem tuaj yeem siv lawv los ua tus qauv txhawm rau kho qhov qauv, uas yog ib feem uas peb txaus siab rau tam sim no.

Kauj Ruam 3: Sau Qhov Gap

Sau Qhov khoob
Sau Qhov khoob

Tom qab hloov qee yam hauv tus qauv koj tuaj yeem nyem rau ntawm "zowiSCT.sgen -> Tsim Cov Ntawv Cuam Tshuam". Qhov no tsim cov haujlwm virtual hauv C ++, uas tau tshaj tawm hauv lub xeev lub tshuab mus rau daim nplaub tshev "src-gen", uas peb tom qab ntawd siv qhov qub C ++.

Tsuas yog tsim ob daim ntawv no hauv "src" nplaub tshev kom tau txais kev ua haujlwm uas peb xav tau los ntawm Otto.

Thawj qhov Impl.h

#ifndef SRC_IMPL_H_

#define SRC_IMPL_H_ #include "../src-gen/ZowiSCT.h" class Impl: public ZowiSCT:: DefaultSCI_OCB {public: Impl (); virtual ~ Impl (); void zowi_init (sc_integer YL, sc_integer YR, sc_integer RL, sc_integer RR); tsis muaj dab tsi zowi_home (); tsis muaj dab tsi zowi_putMouth (sc_integer mouthType); tsis muaj dab tsi zowi_sing (sc_integer songName); tsis muaj dab tsi zowi_walk (sc_real cov kauj ruam, sc_integer T, sc_integer dir); tsis muaj dab tsi zowi_shakeLeg (); }; #endif / * SRC_IMPL_H_ * /

Tom qab ntawd Impl.cpp

#suav nrog "Impl.h"

#include "../Zowi/Zowi.h" Zowi zowi = tshiab Zowi (); Impl:: Impl () {} Impl:: ~ Impl () {} void Impl:: zowi_home () {zowi.home (); } void Impl:: zowi_init (sc_integer YL, sc_integer YR, sc_integer RL, sc_integer RR) {zowi.init (YL, YR, RL, RR); } void Impl:: zowi_putMouth (sc_integer mouthType) {zowi.putMouth (mouthType); } void Impl:: zowi_sing (sc_integer songName) {zowi.sing (songName); } void Impl:: zowi_walk (sc_real cov kauj ruam, sc_integer T, sc_integer dir) {zowi.walk (cov kauj ruam, T, dir); } void Impl:: zowi_shakeLeg () {zowi.shakeLeg (); }

Kauj Ruam 4: Ua Kev Lom Zem Otto

Thaum koj zoo siab nrog koj cov khoom, nyem rau ntawm rauj rau sab laug sab saum toj thiab tos kom cov txheej txheem ua kom tiav. Tom qab ntawd nyem rau ntawm lub xub ntsuab mus rau sab xis ntawm rauj thiab pom koj Otto seev cev!

Yog tias koj xav tau, koj tuaj yeem tshawb xyuas qee qhov piv txwv: YAKINDU Statechart Cov Cuab Yeej

Pom zoo: