資料介紹
描述
介紹:
我們都熟悉《鋼鐵俠》電影和漫威系列中的“賈維斯”AI助手機(jī)器人。自己動(dòng)手做東西一直是程序員的夢(mèng)想。今天我將展示一種使用 Python 編程制作這樣一個(gè)助手的簡(jiǎn)單方法。而且,我還會(huì)給那個(gè)機(jī)器人做一個(gè)物理化身,這樣每當(dāng)我們和機(jī)器人說(shuō)話(huà)的時(shí)候,它就可以做一些動(dòng)作。這將比僅僅一個(gè)軟件機(jī)器人更令人驚奇。因?yàn)槿绻猩眢w,那就很酷了。所以今天我們將學(xué)習(xí)使用Arduino和Python編程來(lái)制作一個(gè)可以控制您的計(jì)算機(jī)并與您閑聊的AIrobot。讓我們跳進(jìn)去!
為什么我將機(jī)器人命名為“黃疸”?因?yàn)槲野阉砍牲S色,非常非常黃!
部分:
Arduino Nano – 1x
微型伺服 Sg90 – 3x
身體 -
PVC片材(最好是白色的,上色更好,我用的是藍(lán)色的)
伺服輪(用于支架)
工具:
切刀
剪刀
熱膠
噴漆
軟件-
Arduino.ide
原則:
在進(jìn)入實(shí)際建筑之前,很高興知道我們將要做什么。
那么,主要代碼或AI部分代碼會(huì)在電腦上運(yùn)行,為什么呢?因?yàn)樗С?python 并且比小 Arduino 具有更多的處理能力,而且 AI bot 將控制/自動(dòng)化我的電腦的一些任務(wù),它必須在我的電腦上運(yùn)行。因此,Arduinoboard 使用 USB 電纜連接到我的計(jì)算機(jī)。
這個(gè)想法是運(yùn)行一個(gè) python 程序,它將執(zhí)行 Speech totext 部分,處理文本并且還將執(zhí)行 Text to Speech。意味著機(jī)器人會(huì)傾聽(tīng)、理解和回話(huà)。對(duì)于身體運(yùn)動(dòng),我在 Arduino 板上保存了一些運(yùn)動(dòng)(封裝在函數(shù)中)。每個(gè)動(dòng)作的功能由python代碼執(zhí)行。
例如——如果機(jī)器人必須說(shuō)“Hi/hello”,python 代碼將發(fā)送一個(gè)字節(jié)“h”,Arduino 然后執(zhí)行 hi() 函數(shù)。就如此容易。
現(xiàn)在您有了一個(gè)想法,讓我們繼續(xù)下一個(gè)過(guò)程。
電路和電子
1 / 2
電路是讓大多數(shù)制造商煩惱的事情。如果出現(xiàn)問(wèn)題,您可能會(huì)燒掉一些昂貴的零件。為此,我設(shè)計(jì)了一個(gè)可用于制作大量項(xiàng)目的 PCB 板。它有微型 SD 卡插槽、藍(lán)牙模塊插槽、5v 外部電源,整個(gè)設(shè)備由 Arduino Nano 供電。
我使用 EasyEDA 設(shè)計(jì)了一個(gè) PCB ,并使用PCBWay在線(xiàn)服務(wù)進(jìn)行了打印。他們的服務(wù)很棒。我訂購(gòu)了PCB 即時(shí)報(bào)價(jià),他們的系統(tǒng)自動(dòng)為我完成了所有工作。三天之內(nèi),我從中國(guó)一路拿到了板子到孟加拉國(guó)。質(zhì)量非常好,阻焊層完美,線(xiàn)條/痕跡,光潔度盡可能好。
無(wú)論如何,我使用了.300 mmtraces,因?yàn)樗梢猿惺?1Amp 電流。
您可以從這里下載 PCB 文件。
焊接?xùn)|西和測(cè)試電路:
在這一步中,我焊接了所有東西。小心不要吸入煙霧,它可能會(huì)致癌。
我沒(méi)有使用藍(lán)牙模塊或 TF 模塊,所以我沒(méi)有焊接那些。好消息是,我使用了 3 個(gè)伺服電機(jī)和一個(gè)聲納傳感器,所有東西都可以通過(guò)我們連接的 USB 電纜輕松供電,以對(duì) Arduino 進(jìn)行編程。這很棒,因?yàn)槲覀儾槐乜紤]其他電源。
但是,如果您仍然想使用外部電池,那么請(qǐng)使用 lipo 2s (7.4V) 電池,不僅如此,伺服器也會(huì)燒毀。
制作身體:
1 / 13
我用PVC板做身體,你也可以用紙板。首先,我為主要部分做了一個(gè)盒子,里面有主板和伺服電機(jī)。這就像制作盒子一樣。我以同樣的方式制作了頭部,為傳感器制作了兩個(gè)孔(作為眼睛)。我已經(jīng)添加了你需要的所有圖片。我把一只手做成扳手,另一只手做成插頭。我實(shí)際上使用了一個(gè)插頭并使用熱膠將其添加到一個(gè)手臂上。
方面?實(shí)際上沒(méi)有,因?yàn)樗悄愕臋C(jī)器人,你可以使用一些簡(jiǎn)單的工具來(lái)制作它,讓它隨心所欲,讓它成為任何形狀和大小。
在關(guān)閉身體之前要非常小心地添加所有電子設(shè)備。在我放置傳感器和所有電子設(shè)備后,我畫(huà)了車(chē)身。不要那樣做,我已經(jīng)把我的 Arduino 染成了黃色。
所以,在車(chē)身上涂漆,然后放上所有的電子設(shè)備。
編碼1(Python):
從此站點(diǎn)下載Python,確保在安裝時(shí)將 python 添加到您的路徑中。
安裝 Python 后,您需要從命令提示符/終端運(yùn)行一些命令來(lái)安裝用于語(yǔ)音識(shí)別、音頻支持、文本到語(yǔ)音、瀏覽器自動(dòng)化、串行通信目的的庫(kù)。運(yùn)行這些命令 -
?
pip installspeechrecognition pip install pyaudio pip install pyttsx3 pip install pywhatkit pip install pyserial
?
然后從下面下載 pythoncode或從下面復(fù)制。前往coding2步驟。
?
""" JAUNDICE: AI Assistant robot with Arduino and Python author: ashraf minhaj mail: ashraf_minhaj@yahoo.com Last Edit: Nov 2020 License: Copyright (C) Ashraf Minhaj. General Public License (GPL3+) """ import speech_recognition as sr # voice recognition library import random # to choose random words from list import pyttsx3 # offline Text to Speech import datetime # to get date and time import webbrowser # to open and perform web tasks import serial # for serial communication import pywhatkit # for more web automation # Declare robot name (Wake-Up word) robot_name = 'jaundice' # random words list hi_words = ['hi', 'hello', 'yo baby', 'salam'] bye_words = ['bye', 'tata', 'hasta la vista'] r_u_there = ['are you there', 'you there'] # initilize things engine = pyttsx3.init() # init text to speech engine #voices = engine.getProperty('voices') #check for voices #engine.setProperty('voice', voices[1].id) # female voice listener = sr.Recognizer() # initialize speech recognition API # connect with NiNi motor driver board over serial communication try: port = serial.Serial("COM15", 9600) print("Phycial body, connected.") except: print("Unable to connect to my physical body") def listen(): """ listen to what user says""" try: with sr.Microphone() as source: # get input from mic print("Talk>>") voice = listener.listen(source) # listen from microphone command = listener.recognize_google(voice).lower() # use google API # all words lowercase- so that we can process easily #command = command.lower() print(command) # look for wake up word in the beginning if (command.split(' ')[0] == robot_name): # if wake up word found.... print("[wake-up word found]") process(command) # call process funtion to take action except: pass def process(words): """ process what user says and take actions """ print(words) # check if it received any command # break words in word_list = words.split(' ')[1:] # split by space and ignore the wake-up word if (len(word_list)==1): if (word_list[0] == robot_name): talk("How Can I help you?") #.write(b'l') return if word_list[0] == 'play': """if command for playing things, play from youtube""" talk("Okay boss, playing") extension = ' '.join(word_list[1:]) # search without the command word port.write(b'u') pywhatkit.playonyt(extension) port.write(b'l') return elif word_list[0] == 'search': """if command for google search""" port.write(b'u') talk("Okay boss, searching") port.write(b'l') extension = ' '.join(word_list[1:]) pywhatkit.search(extension) return if (word_list[0] == 'get') and (word_list[1] == 'info'): """if command for getting info""" port.write(b'u') talk("Okay, I am right on it") port.write(b'u') extension = ' '.join(word_list[2:]) # search without the command words inf = pywhatkit.info(extension) talk(inf) # read from result return elif word_list[0] == 'open': """if command for opening URLs""" port.write(b'l') talk("Opening, sir") url = f"http://{''.join(word_list[1:])}" # make the URL webbrowser.open(url) return elif word_list[0] == 'uppercut': port.write(b'U') elif word_list[0] == 'smash': port.write(b's') elif word_list[0] == 'punch': port.write(b'p') # now check for matches for word in word_list: if word in hi_words: """ if user says hi/hello greet him accordingly""" port.write(b'h') # send command to wave hand talk(random.choice(hi_words)) elif word in bye_words: """ if user says bye etc""" talk(random.choice(bye_words)) def talk(sentence): """ talk / respond to the user """ engine.say(sentence) engine.runAndWait() # run the app while True: listen() # runs listen one time
?
編碼2(Arduino):
這部分很容易,無(wú)需安裝。使用Arduino.ide對(duì)開(kāi)發(fā)板進(jìn)行編程。如果您以前從未使用過(guò) Arduino,請(qǐng)從此處下載。
正如我之前提到的,Arduino 程序等待串行數(shù)據(jù),如果它接收到任何數(shù)據(jù),它會(huì)檢查字節(jié)數(shù)據(jù)。如果數(shù)據(jù)與預(yù)定義的命令匹配,則它執(zhí)行一條語(yǔ)句。如果發(fā)送'u',它會(huì)使兩只手都向上,就像那樣。
從下面的副本下載代碼。
?
/** JAUNDICE: AI Assistant robot with Arduino and Python ** * * author: ashraf minhaj * mail: ashraf_minhaj@yahoo.com * Last Edit: Nov 2020 * * License: Copyright (C) Ashraf Minhaj. * General Public License (GPL3+) */ #includeServo head; Servo l_hand; Servo r_hand; // define sonar sensor's pins int trig = 4; int echo = 5; // received data byte val = ""; void setup() { // put your setup code here, to run once: head.attach(2); l_hand.attach(3); r_hand.attach(4); Serial.begin(9600); // for communicating via serial port with Python } void standby(){ // all motors to these positions head.write(90); int r_pos = 30; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); } void hi(){ // all motors to these positions head.write(90); int i = 0; for(i=30; i<= 170; i++){ r_hand.write(i); delay(5); } for(i=170; i>= 100; i--){ r_hand.write(i); delay(5); } for(i=100; i<= 170; i++){ r_hand.write(i); delay(5); } for(i=170; i>= 30; i--){ r_hand.write(i); delay(5); } standby(); } void hands_up(){ // do this on every command (nothing much just move hands a bit) //head.write(150); //delay(300); //head.write(90); int i = 0; for(i=30; i<= 170; i++){ int r_pos = i; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); delay(5); } delay(600); for(i=170; i>= 30; i--){ int r_pos = i; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); delay(5); } } void weight_lift(){ // lift weight using both hands int i = 0; for(i=30; i<= 170; i++){ int r_pos = i; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); delay(5); } for(int count=0; count<=4; count++){ for(i=170; i>= 60; i--){ int r_pos = i; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); delay(5); } for(i=60; i<= 170; i++){ int r_pos = i; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); delay(5); } } for(i=170; i>= 30; i--){ int r_pos = i; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); delay(5); } } void excited(){ return; } void look_left(){ // rotate hed to left head.write(180); } void confused(){ for(int count=0; count<=1; count++){ head.write(30); r_hand.write(170); delay(700); r_hand.write(30); head.write(120); l_hand.write(30); delay(700); l_hand.write(160); } standby(); } void double_punch(){ // do a punch int i = 0; for(i=30; i>= 0; i--){ int r_pos = i; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); delay(5); } delay(2000); int r_pos = 80; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); delay(500); standby(); } void r_upper_cut(){ // make right upper-cut int i = 0; for(i=30; i<= 170; i++){ int r_pos = i; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); delay(5); } for(int count=0; count<=4; count++){ int i = 0; for(i=170; i>= 60; i--){ r_hand.write(i); delay(1); } for(i=60; i<= 170; i++){ r_hand.write(i); delay(1); } } standby(); delay(100); } void smash(){ // smash things int i = 0; for(i=30; i<= 170; i++){ int r_pos = i; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); delay(5); } delay(2000); for(i=170; i>= 0; i--){ int r_pos = i; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); delay(1); } delay(300); int r_pos = 180; int l_pos = map(r_pos, 0, 180, 180, 0); l_hand.write(l_pos); r_hand.write(r_pos); delay(1000); standby(); } void eye_detect(){ // do something if eye sensor detect motion return; } void loop() { // put your main code here, to run repeatedly: standby(); while(Serial.available() > 0) //look for serial data available or not { val = Serial.read(); //read the serial value if(val == 'h'){ // do hi hi(); } if(val == 'p'){ // do hi double_punch(); } if(val == 'u'){ hands_up(); delay(3000); } if(val == 'l'){ standby(); look_left(); delay(2000); } if(val == 'U'){ // uppercut r_upper_cut(); delay(2000); } if(val == 's'){ smash(); delay(2000); } } }
?
上傳代碼。
將所有內(nèi)容放在一起并完成:
完成所有這些步驟后,我使用 USB 電纜將我的 Arduino 連接到 pc,然后運(yùn)行 ??python 程序。當(dāng)您使用它時(shí),請(qǐng)確保在 python 代碼中添加正確的 Arduino 端口。如果你按照我提到的那樣做所有事情,機(jī)器人應(yīng)該像魅力一樣工作。
謝謝你!
- 基于Jetson NANO的助手機(jī)器人
- Arduino機(jī)器人開(kāi)源
- Arduino機(jī)器人
- 帶有Arduino、樂(lè)高和3D打印部件的DIY雙足機(jī)器人
- 用Arduino和L298制作帶有避障機(jī)器人的巡線(xiàn)器
- 基于Python的AI助手機(jī)器人 1次下載
- GRIPP3R助手機(jī)器人開(kāi)源分享
- 帶有BT Web控制的Arduino自平衡機(jī)器人
- Wifi控制的FPV Rover機(jī)器人(帶有Arduino和ESP8266)
- Humaniod AI會(huì)說(shuō)話(huà)的機(jī)器人與Arduino
- Arduino機(jī)器人螞蟻
- ARLOK arduino機(jī)器人
- 魔方機(jī)器人(三)Arduino
- Arduino教學(xué)機(jī)器人的使用教程免費(fèi)下載 37次下載
- Arduino開(kāi)發(fā)機(jī)器人經(jīng)典書(shū)籍推薦Arduino開(kāi)發(fā)實(shí)戰(zhàn)指南:機(jī)器人卷
- 如何使用Python和PinPong庫(kù)控制Arduino 718次閱讀
- 發(fā)現(xiàn)更多機(jī)器人開(kāi)發(fā)技巧 AI與邊緣計(jì)算加持 638次閱讀
- 如何使用Arduino制造一個(gè)自動(dòng)平衡機(jī)器人 4429次閱讀
- 面對(duì)疫情 醫(yī)療機(jī)器人能幫上什么忙? 2126次閱讀
- dfrobotSparki機(jī)器人套裝簡(jiǎn)介 2064次閱讀
- dfrobotDevastator履帶機(jī)器人移動(dòng)平臺(tái)簡(jiǎn)介 1515次閱讀
- 協(xié)作機(jī)器人的起源_為什么需要協(xié)作機(jī)器人 8127次閱讀
- 手把手教你用Python創(chuàng)建微信機(jī)器人 3476次閱讀
- 盤(pán)點(diǎn)2018年機(jī)器人領(lǐng)域十大技術(shù) 3312次閱讀
- AI和VR在機(jī)器人控制的實(shí)在應(yīng)用匯總 5506次閱讀
- 軟體機(jī)器人 前所未見(jiàn)的機(jī)器人 3692次閱讀
- Python+樹(shù)莓派實(shí)現(xiàn)的微信拍攝機(jī)器人 1w次閱讀
- 機(jī)器人如何識(shí)別顏色 2.5w次閱讀
- 手機(jī)如何連接小米掃地機(jī)器人_小米掃地機(jī)器人怎么連wifi 17.6w次閱讀
- 用Arduino和安卓舊手機(jī),DIY遠(yuǎn)程遙控機(jī)器人 2.9w次閱讀
下載排行
本周
- 1山景DSP芯片AP8248A2數(shù)據(jù)手冊(cè)
- 1.06 MB | 532次下載 | 免費(fèi)
- 2RK3399完整板原理圖(支持平板,盒子VR)
- 3.28 MB | 339次下載 | 免費(fèi)
- 3TC358743XBG評(píng)估板參考手冊(cè)
- 1.36 MB | 330次下載 | 免費(fèi)
- 4DFM軟件使用教程
- 0.84 MB | 295次下載 | 免費(fèi)
- 5元宇宙深度解析—未來(lái)的未來(lái)-風(fēng)口還是泡沫
- 6.40 MB | 227次下載 | 免費(fèi)
- 6迪文DGUS開(kāi)發(fā)指南
- 31.67 MB | 194次下載 | 免費(fèi)
- 7元宇宙底層硬件系列報(bào)告
- 13.42 MB | 182次下載 | 免費(fèi)
- 8FP5207XR-G1中文應(yīng)用手冊(cè)
- 1.09 MB | 178次下載 | 免費(fèi)
本月
- 1OrCAD10.5下載OrCAD10.5中文版軟件
- 0.00 MB | 234315次下載 | 免費(fèi)
- 2555集成電路應(yīng)用800例(新編版)
- 0.00 MB | 33566次下載 | 免費(fèi)
- 3接口電路圖大全
- 未知 | 30323次下載 | 免費(fèi)
- 4開(kāi)關(guān)電源設(shè)計(jì)實(shí)例指南
- 未知 | 21549次下載 | 免費(fèi)
- 5電氣工程師手冊(cè)免費(fèi)下載(新編第二版pdf電子書(shū))
- 0.00 MB | 15349次下載 | 免費(fèi)
- 6數(shù)字電路基礎(chǔ)pdf(下載)
- 未知 | 13750次下載 | 免費(fèi)
- 7電子制作實(shí)例集錦 下載
- 未知 | 8113次下載 | 免費(fèi)
- 8《LED驅(qū)動(dòng)電路設(shè)計(jì)》 溫德?tīng)栔?/a>
- 0.00 MB | 6656次下載 | 免費(fèi)
總榜
- 1matlab軟件下載入口
- 未知 | 935054次下載 | 免費(fèi)
- 2protel99se軟件下載(可英文版轉(zhuǎn)中文版)
- 78.1 MB | 537798次下載 | 免費(fèi)
- 3MATLAB 7.1 下載 (含軟件介紹)
- 未知 | 420027次下載 | 免費(fèi)
- 4OrCAD10.5下載OrCAD10.5中文版軟件
- 0.00 MB | 234315次下載 | 免費(fèi)
- 5Altium DXP2002下載入口
- 未知 | 233046次下載 | 免費(fèi)
- 6電路仿真軟件multisim 10.0免費(fèi)下載
- 340992 | 191187次下載 | 免費(fèi)
- 7十天學(xué)會(huì)AVR單片機(jī)與C語(yǔ)言視頻教程 下載
- 158M | 183279次下載 | 免費(fèi)
- 8proe5.0野火版下載(中文版免費(fèi)下載)
- 未知 | 138040次下載 | 免費(fèi)
評(píng)論
查看更多