{"id":494,"date":"2019-08-25T15:22:20","date_gmt":"2019-08-25T15:22:20","guid":{"rendered":"https:\/\/www.protowrxs.com\/?page_id=494"},"modified":"2019-08-25T15:22:22","modified_gmt":"2019-08-25T15:22:22","slug":"head-bots","status":"publish","type":"page","link":"https:\/\/www.protowrxs.com\/index.php\/robotics\/head-bots\/","title":{"rendered":"Head Bots"},"content":{"rendered":"\n<h2>Head Bot Example and Starting Code<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"320\" height=\"466\" src=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img_0099.png\" alt=\"\" class=\"wp-image-495\" srcset=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img_0099.png 320w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2019\/08\/img_0099-206x300.png 206w\" sizes=\"(max-width: 320px) 85vw, 320px\" \/><\/figure>\n\n\n\n<p>\nNovember 2015\n\n<\/p>\n\n\n\n<p>So Box Head and DRHead are done and fun but how does it all happen? \nIt\u2019s really simple when you look at it. The PC runs some simple voice \nrecognition stuff in VB.net and the Arduino listens for commands from \nthe PC and responds or does it\u2019s own thing like blinking, etc.\n\n<\/p>\n\n\n\n<p>Here\u2019s how I\u2019m doing this at least but I\u2019m sure there are many \nother ways of doing the same thing. i think I left enough examples in \nthe code to see how it works and how to add your own options. the code \nshould allow for sending commands to the microcontroller, getting text \nand RSS info from the web, and just making general conversation\u2026 albeit \nvery limited conversation.\n\n<\/p>\n\n\n\n<p>Sorry I tried to make this short and sweet but if you already \nknow how most of this works just get the code and build your bot. If not\n there are a few steps that may or may not be helpful here.\n\n<\/p>\n\n\n\n<h2>The PC Side<\/h2>\n\n\n\n<h3>Get VB.net 2008 installed<\/h3>\n\n\n\n<p>\n\nThe PC side is a VB.net Visual Studio 2008 (remember Box Head and DRHead\n are running on old XP laptops) and your normal Arduino stuff. It will \nwork on Win7 by uncommenting a few things or re-commenting a few things \nin the enable area. It\u2019s pretty obvious that Microsoft wants to get \npeople to move along off the old development, and other old products, \nand on to the new but I\u2019m still an old hack BASIC coder so I like the \nold VB.net 2008 version. You cannot find the download on the main MS \nsite anymore and if you find a small \u201csetup\u201d program it would work for \nme as if the main download MS server is gone. \n\n<\/p>\n\n\n\n<p>You may well be able to load this up and use it in a new version for \nVB Express, I just haven\u2019t tried so far. BUT I DID find this ISO link \nand used it to download and burn a VB.net 2008 instllation disc. \nActually Visual Studio 2008 but we only need VB.net to run this. \nhttps:\/\/go.microsoft.com\/fwlink\/?LinkId=104679  should give you an \napproximate 800mb download for the ISO. Burn it to an install disc and \ninstall the VB portion. This should be a setup file under the VBExpress \nfolder. I do NOT want to help MS with the \u201cexperience\u201d \u2026 especially \nsince there is no experience left for this product so I uncheck that \nbox. I also uncheck the MSDN Express Library and the Microsoft SQL \nServer 2005 Express install\u2026 not needed. Let the install run and keep \nreading\u2026 The install takes a while at least on my old machines.\n\n<\/p>\n\n\n\n<h2>Get the SAPI 5.x<\/h2>\n\n\n\n<p>\n\nI THINK you will need this but you might try it without the install. I \ndo not think it will hurt anything one way or another but I know it\u2019s \nneeded on Win XP systems. This appears to still be found on the MS sites\n located here: \nhttps:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=10121  &#8211; Click \nthe DOWNLOAD button to get the options. You really only need the \n\u201cSpeechSDK51.exe\u201d and maybe the \u201cmsttss22l.exe\u201d files I think unless you\n may want other languages but I haven\u2019t messed with that.\n\n<\/p>\n\n\n\n<h2>eSpeak Install (Optional)<\/h2>\n\n\n\n<p>\n\nIf you want to use or play with the eSpeak option then download and \ninstall eSpeak. I default the VB code to use eSpeak in the C:\\eSpeak \nfolder so either create that and copy the files in the \/command_line \nfolder in the eSpeak install or change the starting point in the \nspeaking subroutine. you can actually switch between the MS and eSpeak \nvoice options using voice commands if you want.\n\n<\/p>\n\n\n\n<h2>Getting the Code Into VB<\/h2>\n\n\n\n<p>\n\nCreate you a new VB project as a Windows Form Application, give it a \nname at the bottom and click on through. Get into the Form1 design area \nby double clicking the Form1 and copy\/paste the code here for the VB \nside. You\u2019ll have some errors if you try to run (debug) but add the form\n fields and button like the image shows here to get past them and just \nwork them one at a time. Any errors should be limited to the form fields\n as the code works for me with the right fields on the form. (No I\u2019m not\n good a standardized labeling so if you want to fix that you can do that\n now too.)\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"http:\/\/192.168.123.10\/robotics\/headbot\/form1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>You will also need to add the System.Speech .net object and maybe the\n Microsoft Speech Object Library COM reference from my experience and \nwhat I\u2019ve seen online so add that under the Project \/ Add Reference menu\n items. Make sure the .NET tab is selected and scroll down to the \nSystem.Speech item and click OK. Then if you want add the Speech Object \nLibrary under the COM tab.\n\n\n\n<\/p>\n\n\n\n<p>Now go back to the Form1 design and add the following fields from\n the image. They should be TextHeard multiline textbox, LastSaid \nmultiline textbox, LastCommandSent multiline textbox, lblStatus label, \nlblVoiceStatus label, cmbPorts combo box, cmbBitRate combo box, and \nButton1 button. You can update the text on the button to Open, OpenCom, \nConnect, Screw It, or whatever you want.\n\n<\/p>\n\n\n\n<p>Remember you DO have to have a microphone or some type of audio \ninput device to use voice recognition. Seems silly BUT I was stumped for\n a bit when I tested on a new machine without a mic instead of a laptop \nwith built in mic before. Yeah, I\u2019m stupid. Also make sure you run \nthrough the basic speech recog mic setup in the Control panel to make \nsure things are working. The Win7+ speech recog stuff has to work before\n this will work. You will yell less at your robot if you do this, I \npromise.\n\n<\/p>\n\n\n\n<p>Also make sure you have at least ONE Serial COM port to test the \ncode as it doesn\u2019t expect a machine with nothing in it as you are \nalready writing code for microcontrollers so you have COM ports.. right?\n\n<\/p>\n\n\n\n<p>There are a few variables you can use once the code is runnable \nincluding the Robot&#8217;s name, what you want he\/she\/it to call you when you\n wake it up if you leave that in, which COM port you want to default \nopen, etc. Read the comments and it should make sense. The code defaults\n to the Microsoft voices but you can change that to eSpeak by flipping \nthat variable in the DIM area. Or use the \u201cPlease use the eSpeak voice\u201d \ncommand.\n\n<\/p>\n\n\n\n<p>You should be able to turn OFF the GetComResponse flag and run \nthe code WITHOUT a microcontroller hooked up. That just polls the micro \nfor a response after sending a command. If you are getting slow choppy \nresponses you are likely waiting for the com data timeout and not \nsending a blip back to the VB app.\n\n<\/p>\n\n\n\n<h2>The Arduino Side<\/h2>\n\n\n\n<p>\n\nI am not going to discuss much here, it\u2019s Arduino so if you\u2019re using an \nArduino as your animation driver then you need to know a bit about it \nalready. The basic code is included that should work with the VB code \nand allow basic left\/right and up\/down head movement, eye blinking using\n RGB or single LEDs, and driving a jaw animation either by servo or by \nLED\u2026 or both if you so desire&#8230; That would actually be kind of cool but\n I haven\u2019t done that. Put an LED inside the mouth so it blinks as the \njaw opens\u2026 hmmm&#8230;\n\n<\/p>\n\n\n\n<p>If you change up the pin layout, which may be a good idea, make sure \nyou make the changes to the Arduino code to adjust for it. Otherwise \njust read through the code and find all my bugs for me, fix them, and \nrepublish please. \ud83d\ude42\n\n<\/p>\n\n\n\n<h2>Setting default Microsoft voices<\/h2>\n\n\n\n<p>\n\nYou can setup the default MS voice to use in the Control Panel \/ Speech \narea. Windows 7 is limited to the Anna voice for the most part I \nbelieve. One may be able to parse the SAPI5 voices and make a selection \nin the code for them. I\u2019ve done that in an old VB6 app but never looked \nat the option here since I\u2019ve only really run this under XP.\n\n<\/p>\n\n\n\n<h2>Limitations and Information<\/h2>\n\n\n\n<p>\n\nRemember, as this is designed so you have to use the pretty much the \nexact words to get the command recognized. You also have to have the \nExACt case in the IF statement as is in the grammar array or it \ngenerally won\u2019t work. I could have UCASED things etc or made the process\n better but I didn\u2019t.\n\n<\/p>\n\n\n\n<p>Also remember everything is hard coded here so you can\u2019t really add \ncommands on the fly. A well written app would have a front end to add \nthe phrase, command to send to the micro, field for what we are supposed\n to do such as RSS, URL, Speak, or multiple variations thereof, and so \non. For my purposes I just run it all in \u201cdebug\u201d mode as I\u2019m always \ntweaking something one way or another.\n\n<\/p>\n\n\n\n<p>Also be nice, I\u2019m a hack coder that have somehow made an IT \ncareer spanning from PDP 11\/34\u2019s through today\u2019s virtual everything and \ndo code web, script and automation at the gov I work for. Just saying \nyou are not going to see super nice, structured, professional code. But I\n have fun anyhow. \ud83d\ude42\n\n<\/p>\n\n\n\n<h2>Resources:<\/h2>\n\n\n\n<p>\n\nVisual Studio 2008 ISO Download\n<a href=\"https:\/\/go.microsoft.com\/fwlink\/?LinkId=104679\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/go.microsoft.com\/fwlink\/?LinkId=104679 <\/a><\/p>\n\n\n\n<p>\nSAPI 5.x SDK\n<a href=\"https:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=10121\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=10121<\/a>\n<\/p>\n\n\n\n<p>\neSpeak text to speech\n<a href=\"http:\/\/espeak.sourceforge.net\/\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/espeak.sourceforge.net\/<\/a>\n\n<\/p>\n\n\n\n<h2>Source Code<\/h2>\n\n\n\n<p><a href=\"\/robotics\/HeadBotBaseCode2VB.txt\">VB.Net Code &#8211; HeadBotBaseCode2VB.txt<\/a> &#8211; Copy \/ past into your VB Project form code to use <\/p>\n\n\n\n<p> <a href=\"\/robotics\/HeadBotBaseCodeArduino.txt\">Arduino Code &#8211; HeadBotBaseCodeArduino.txt<\/a> &#8211; Renamed to .ino to use in Arduino IDE <\/p>\n\n\n\n<h2>The Disclaimer<\/h2>\n\n\n\n<p> This software works for me. It may or may not work on your PC, setup,  configuration, version, etc. Please do not ask for help making it work. I  barely can get things to work on my own stuff, much less someone else&#8217;s.    <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Head Bot Example and Starting Code November 2015 So Box Head and DRHead are done and fun but how does it all happen? It\u2019s really simple when you look at it. The PC runs some simple voice recognition stuff in VB.net and the Arduino listens for commands from the PC and responds or does it\u2019s &hellip; <a href=\"https:\/\/www.protowrxs.com\/index.php\/robotics\/head-bots\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Head Bots&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":19,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"spay_email":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/pages\/494"}],"collection":[{"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/comments?post=494"}],"version-history":[{"count":1,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/pages\/494\/revisions"}],"predecessor-version":[{"id":496,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/pages\/494\/revisions\/496"}],"up":[{"embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/pages\/19"}],"wp:attachment":[{"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/media?parent=494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/categories?post=494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/tags?post=494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}