{"id":409,"date":"2017-03-04T17:41:23","date_gmt":"2017-03-04T22:41:23","guid":{"rendered":"https:\/\/www.mcgurrin.info\/robots\/?p=409"},"modified":"2020-06-21T23:19:40","modified_gmt":"2020-06-22T03:19:40","slug":"the-yorick-project","status":"publish","type":"post","link":"https:\/\/www.mcgurrin.info\/robots\/409\/","title":{"rendered":"The Yorick Project"},"content":{"rendered":"<p>I like to <a href=\"https:\/\/www.mcgurrin.info\/robots\/?p=137\">decorate for Halloween<\/a>, including various talking skeletons that I&#8217;ve set up over the years. For Christmas 2015, my wife gave me a great <a href=\"http:\/\/audioservocontroller.com\/\">3 axis talking skull with moving eyes<\/a> so I could upgrade one of the skeletons from just a moving jaw skull. Then a friend suggested that there had to be other applications for the rest of the year. This got me thinking, and when I saw the <a href=\"https:\/\/youtu.be\/zBqiW1R5_JM\">Alexa Billy Bass<\/a> I knew what I had to do, and the Yorick project was born. I&#8217;m pretty happy with the result:<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/3Nss_2_rwdE\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>Now, if you put this project together from scratch, it&#8217;s pretty expensive, due to the cost of the 3-axis talking skull, but if you are looking to re-purpose one you have, or a similar device, then you may want to develop a similar project. The key elements are the talking skull, a Raspberry Pi and the<a href=\"https:\/\/github.com\/alexa-pi\/AlexaPi\"> AlexaPi <\/a>software for turning the Pi into an Alexa client device, the audio servo controller for turning the output sound into servo commands for the jaw, and the servo controller for controlling the nod, turn, tilt, and eye servos of the skull.<\/p>\n<div id=\"attachment_431\" style=\"width: 251px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/block-diagram.png\"><img aria-describedby=\"caption-attachment-431\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-431\" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/block-diagram-300x241.png\" width=\"241\" height=\"193\" srcset=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/block-diagram-300x241.png 300w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/block-diagram-768x616.png 768w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/block-diagram-374x300.png 374w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/block-diagram.png 802w\" sizes=\"(max-width: 241px) 100vw, 241px\" \/><\/a><p id=\"caption-attachment-431\" class=\"wp-caption-text\">Block diagram for Yorick<\/p><\/div>\n<div id=\"attachment_420\" style=\"width: 250px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/IMG_20170219_141335.jpg\"><img aria-describedby=\"caption-attachment-420\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-420\" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/IMG_20170219_141335-240x300.jpg\" alt=\"\" width=\"240\" height=\"300\" srcset=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/IMG_20170219_141335-240x300.jpg 240w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/IMG_20170219_141335-768x960.jpg 768w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/IMG_20170219_141335.jpg 800w\" sizes=\"(max-width: 240px) 100vw, 240px\" \/><\/a><p id=\"caption-attachment-420\" class=\"wp-caption-text\">Bench testing the set-up<\/p><\/div>\n<p>The AlexaPi software provides output to two GPIO pins, intended to light up LEDs as the Pi hears the wakeup word, listens to the input, gets the response from the Amazon Alexa service, and then speaks the response. All the directions for AlexaPi are on the creator&#8217;s GitHub site. For this project, we also linked the same pins to input pins on the Maestro servocontroller. The Maestro I used allows pins to be used as output (primarily for servos, but also for other purposes) or as analog inputs. Other models also have digital input pins. By reading the status of the input pins, we know which state to be in, as there is a separate routine of head motions for inactive, wake, listen, get response, and speak response.<\/p>\n<p>The servo sequences are developed using the GUI-based controller software provided by Pololu, and then custom control commands are added using their stack-based scripting language. The partial script is included at the end of the article. The short first section that is provided is the control code I wrote, the rest (not shown) are the automatically generated subroutines based on the sequences I defined using their GUI driven software.<\/p>\n<p>The skull motions for each state are predefined and fixed (the routines are looped as needed for the typically longer lasting states (get response and speak response). The one key tip is to slow down the servos in order to look more realistic. The Maestro controller software lets you limit the speed and acceleration of each servo, and with the exception of the jaw servo, which had to have quick response to changing audio, I set both the speed and acceleration values to 20.<\/p>\n<p>The audio servo driver board converts the audio put out by the Pi into servo commands for the jaw, while also passing the audio through to the powered speakers. Others have developed their own software do drive motor (rather than servo) based devices such as <a href=\"http:\/\/www.instructables.com\/id\/Animate-a-Billy-Bass-Mouth-With-Any-Audio-Source\/\">Billy Bass <\/a>and <a href=\"https:\/\/www.hackster.io\/chip\/c-h-i-p-py-ruxpin-5f02f1\">Teddy Ruxpin<\/a>, based on the amplitude of the sound. I&#8217;m sure the same could be done to drive the jaw servo by extracting the volume of the sound, but I already had an audio servo driver board that is otherwise unused except for Halloween, so I used that. (Update: I&#8217;ve since developed my own <a href=\"https:\/\/www.mcgurrin.info\/robots\/690\/\">Raspberry Pi based audio servo controller<\/a> and there&#8217;s also the <a href=\"http:\/\/buttonbanger.com\/?page_id=137\">Jawsduino<\/a> project that uses an Arduino.)<\/p>\n<div id=\"attachment_416\" style=\"width: 245px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/skull.jpg\"><img aria-describedby=\"caption-attachment-416\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-416 \" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/skull-238x300.jpg\" width=\"235\" height=\"294\" \/><\/a><p id=\"caption-attachment-416\" class=\"wp-caption-text\">3-axis talking skull with moving eyes<\/p><\/div>\n<div id=\"attachment_417\" style=\"width: 243px\" class=\"wp-caption alignright\"><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/IMG_20170219_141408.jpg\"><img aria-describedby=\"caption-attachment-417\" decoding=\"async\" loading=\"lazy\" class=\" wp-image-417\" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/IMG_20170219_141408-225x300.jpg\" alt=\"\" width=\"233\" height=\"307\" \/><\/a><p id=\"caption-attachment-417\" class=\"wp-caption-text\">Raspberry Pi with Kinobo USB microphone<\/p><\/div>\n<div id=\"attachment_418\" style=\"width: 247px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/IMG_20170219_141345.jpg\"><img aria-describedby=\"caption-attachment-418\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-418\" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/IMG_20170219_141345-300x225.jpg\" width=\"237\" height=\"181\" \/><\/a><p id=\"caption-attachment-418\" class=\"wp-caption-text\">Audio servo controller board<\/p><\/div>\n<div id=\"attachment_421\" style=\"width: 242px\" class=\"wp-caption alignright\"><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/IMG_20170219_141354.jpg\"><img aria-describedby=\"caption-attachment-421\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-421\" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/IMG_20170219_141354-300x225.jpg\" width=\"232\" height=\"177\" \/><\/a><p id=\"caption-attachment-421\" class=\"wp-caption-text\">Mini Maestro Servo Controller board<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>I put it all in a project box, and covered the threaded rod supporting the skull with a short length of PVC pipe, painted black, to produce the final result:<\/p>\n<div id=\"attachment_453\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/internals.jpg\"><img aria-describedby=\"caption-attachment-453\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-453 size-medium\" src=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/internals-300x225.jpg\" width=\"300\" height=\"225\" srcset=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/internals-300x225.jpg 300w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/internals-400x300.jpg 400w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2017\/02\/internals.jpg 512w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-453\" class=\"wp-caption-text\">Rather messy (mainly with the 5 servo cables), but it all fits in the box.<\/p><\/div>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/3Nss_2_rwdE\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<div style=\"border: 1px solid #0505f8; background-color: #ddddf9; padding: 1.2em;\">\n<h1>Hardware Components<\/h1>\n<ul>\n<li>3-axis talking skull with moving eyes. Mine is from <a href=\"http:\/\/audioservocontroller.com\/\">audioservocontroller.com<\/a><\/li>\n<li>Powered speakers \u2013 The Raspberry Pi puts out very little volume from the audio jack, so you want amplified speakers, whether battery powered or from line current. I used an old pair of inexpensive computer speakers<\/li>\n<li><a href=\"https:\/\/www.raspberrypi.org\/products\/raspberry-pi-3-model-b\/\">Raspberry Pi 3<\/a> \u2013 Other models with WiFi should also work<\/li>\n<li><a href=\"https:\/\/www.amazon.com\/gp\/product\/B00IR8R7WQ\/ref=oh_aui_detailpage_o07_s01?ie=UTF8&amp;psc=1\">Kinobo &#8211; USB 2.0 Mini Microphone<\/a> &#8211; You need a microphone for input, and I was quite happy with the performance of this one, considering it only cost $5.25!<\/li>\n<li><a href=\"https:\/\/www.pololu.com\/category\/102\/maestro-usb-servo-controllers\">Pololu Mini Maestro Servo Controller<\/a> \u2013 I used the 12 channel version, larger versions should also work.<\/li>\n<li>Audio servo driver board \u2013 I used an ST-200 board from <a href=\"http:\/\/www.cowlacious.com\/scary-terry-audio-servo-driver-board\/\">Cowlacious<\/a> that I had for a Halloween project. That model has been replaced by the newer and improved ST-400 model, which should work fine. <a href=\"http:\/\/audioservocontroller.com\/\">audioservocontroller.com<\/a> also sells a similar board<\/li>\n<li>Misc., including project box, LEDs (optional), resistors (optional, if LEDs used), breadboard (optional, if LEDs used), PVC pipe, and jumper wires.<\/li>\n<\/ul>\n<h1>Software Components<\/h1>\n<ul>\n<li><a href=\"https:\/\/github.com\/alexa-pi\/AlexaPi\">AlexaPi<\/a> open source client software for Amazon\u2019s Alexa service<\/li>\n<li><a href=\"https:\/\/www.pololu.com\/docs\/0J40\/3\">Pololu\u2019s Maestro Controller Software<\/a> \u2013 I used the Windows version, but they have versions for Linux as well.<\/li>\n<li>Custom script for the Maestro servo controller to control the skull. An excerpt to give you a feel for the scripting language is posted below. The full script I used is posted as a gist on Git Hub: https:\/\/gist.github.com\/ViennaMike\/b714fc2c9b7eaaaaff952175536a4942<\/li>\n<\/ul>\n<\/div>\n<p>&nbsp;<\/p>\n<div style=\"border: 1px solid #0505f8; background-color: #dddddd; padding: 1.2em;\">\n<pre>begin     # Loop until input 9 goes high\r\n  9 get_position # get the value of the red trigger, 0-255\r\n  155 greater_than # test whether it is greater than 155 \r\n  if      # Wakeup word detected, run wake movement sequence\r\n    wake     \r\n    750 delay\r\n    1 # flag for getting out of loop\r\n    begin\r\n      dup\r\n      while\r\n      9 get_position\r\n      10 get_position\r\n      plus\r\n      300 greater_than\r\n      if     # If after wake, both inputs high, then getting reply\r\n        think\r\n      else\r\n        9 get_position\r\n        155 greater_than\r\n        if     # if just input on 9 high, then speaking reply\r\n          answer\r\n        else\r\n          10 get_position\r\n          155 greater_than\r\n          if   # if just input on 10 high, then listening to query\r\n            listen\r\n          else     # when both inputs at zero, back to rest mode\r\n\t    Rest\r\n            1 minus\r\n          endif\r\n        endif\r\n      endif \r\n    repeat\r\n  endif\r\nrepeat\r\n\r\n### Sequence subroutines: ###\r\n# Sequence subroutines removed not included for brevity\r\n<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I like to decorate for Halloween, including various talking skeletons that I&#8217;ve set up over the years. For Christmas 2015, my wife gave me a great 3 axis talking skull with moving eyes so I could upgrade one of the &hellip; <a href=\"https:\/\/www.mcgurrin.info\/robots\/409\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[62,30,31,40,61,63,70],"_links":{"self":[{"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/posts\/409"}],"collection":[{"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/comments?post=409"}],"version-history":[{"count":10,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/posts\/409\/revisions"}],"predecessor-version":[{"id":701,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/posts\/409\/revisions\/701"}],"wp:attachment":[{"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/media?parent=409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/categories?post=409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/tags?post=409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}