Introduction: Cookie Monster - a Talking Robot Integrated With Slack
Grove - Touch Sensor
Cookie Monster with a REST API integrated with Slack (www.slack.com) and Twitter
The robotic Cookie Monster was created by Pawel, Marcin and Anna during Intel IoT hackathon in NYC in May 2015. The Cookie Monster is an interactive toy suited for teenagers as well as grown-ups that love technology: talk to him on Slack, ask him to do things, let him tell you a joke - he will become your best friend at work and at home! From now on your friends will never miss your message on Slack - just ask the Cookie Monster to deliver the message to them and the toy will tell them your message out loud! Technical specifications: Slack integration: in a Slack chat write 'monster! say ...' and the actual toy will say those words out loudin the same chat ask the monster to move head, body, right or left hand to a specific angle, and the toy will move!Twitter integration: the Cookie Monster is looking for a specific hashtag in real time - #intelcookiemonster - and once a tweet is posted - the toy reads it out loudToy sensors: proximity sensor has replaced one of its eyes so when the user waves a hand in front of it - the Cookie Monster is asking for a cookie!touch sensor in his mouth - when a cookie (or a finger) is placed inside his mouth - he eats it! (or just pretends to chew on that saying 'om-nom-nom')Know what your monster has been up to! Use Intel IoT Analytics platform to read the information about what your Cookie Monster did/said lately. Technology used:1. Hardware: Servos, 3D printing (for the skeleton), touch sensors, proximity sensor, LED light2. Software: Text to speech, built a server and Slack API in Node.js, used Cylon.js to integrate all sensors, connected to Twitter and started reading a stream of tweets with specific hashtag. Used Intel XDK for development.3. Cloud connectivity - Intel IoT Analytics platform to track actions and generate reports about actions of the Cookie Monster.
List of hardware. Note that many things on the list is optional.
- Intel Edison with Arduino board
- 4 servo motors SG90
- Proximity sensor LV-MaxSonar-EZ
Grove - Starter Kit Plus https://software.intel.com/en-us/iot/hardware/devk... - Grove - Buzzer
- Grove - Sound Sensor
- 2x Grove - Touch Sensor
- Grove - LCD RGB Backlight
- Grove - Base Shield v2
- Bluetooth Speaker - any kind of speaker
- TIP120 Darlington Transistor
- 1N4004 Diode
- 2x 1k Resistor
- RED LED
- a lot of cables and conectors
- Edison Power adapter
- 4x Capacitors 100uF
- a smal breadboard
Cookie Monster base and skeleton
- plexiglass box from Walmart from the kitchenware section. Can be any shape.
- I printed the skeleton on a 3D printer, but It can be made of some pieces of plastic glued together if you don't have an access to a printer. The skeleton holds 4 servo motors and a little breadboard for the motors cables.
Tools
- soldering gun
- hot glue gun
- multimeter
- driller with a set of drills
- sharp knife
- plastic glue (Gorilla)
And at the end you are going to need Cookie Monster and a cookie! I bought my one on Amazon. http://www.amazon.com/Sesame-Street-Playskool-Cuddle-Monster/dp/B00A671ODO/ref=pd_sim_21_3?ie=UTF8&refRID=04D7B6EZCJGJ70PHH2ZA
Step 1: Hardware Components Overview
It is very unlikely that you are going to have all the hardware I have here. This is why you can modify your project as you want. Treat this tutorial here as an example of what can be done with Intel Edison.
If you want to build a robot like Cookie Monster you have to start from the hardware first. Next, once you have all the elements working, you can build the case, frame etc.
So let's see how different components are connected together.
I used Grove shield to connect most of the components. It makes things easier. But if you don't have the shield you can use just regular cables. The diagram attached to this step shows you how to connect everything.
I recommend you to use hot glue gun to insulate cables and make sure they will not unplug later on.
Why do I use a transistor in the circuit. The transistor is a hack to eliminate so called buzz effect. A buzz effect is caused by an unstable voltage in a circuit. The instability is caused by four servo motors running at the same time. They need a lot of current. When a current is used to move the servos, a voltage in the whole circuit slightly drops. This drop causes the PWM impulses which control the servos to drop as well (or changed with respect to the ground). A change in PWM causes motors to move again a bit because they think that was an intentional change. That generates another voltage change and so on. In result the servos are not able to find a stable position. It is called a buzz effect because a servo just buzzing trying to set itself at a desired angle. I added a Darlington transistor TIP120 to the circuit. I stabilizes a voltage and can handle a lot of current. Most importantly it works as a transistor key. I can control the voltage on the servos applying a voltage on a base of the transistor. When the servos are not supposed to move, a voltage is cut off. This is when the PIN 4 has a low state. When the servos are about to move, PIN 4 is set to HIGH what closes the circuit for the servos, they turn and then the voltage is cut off again. It is a hack. I also added 4 capacitors 100uF directly on the servo power line. They are also helping to reduce the buzz effect.
Step 2: A Base Container and Skeleton Frame
I bought the plexiglas container in Walmart. It looks nice and you can see all the components inside. This is important if you are a geek ;)
Once you get a container like my one you are going to have to adapt it to accommodate all the electronics. I just glued all the elements inside. With a driller you can make all the necessary holes for the touch switches and a power cable. Also, at the top, make sure you create a big enough hole to run all the cables through it. In my case the top hole is 10mm in diameter. You are going to have to stick the cookie monster skeleton on the top of the plexiglass container.
Cookie monster frame is quite important in the whole project. I printed it out on a 3D printer. But if you don't have an access to a printer you can build a frame yourself. Just use some plastic elements you find in any store and a bit of glue. Be creative. Make sure the servos fit well and they are not going to move when Cookie Monster moves his hands.
As you see on the first picture in the gallery, the transistor is glued to a wall of the container. Also the buzzer and the sound sensor cables are glued to the container. Do not let any cables to be loose inside because you may burn something.
Once you are done with the frame and the base, you can put a Cookie Monster skin on. Make sure your frame has the right size for whatever Cookie Monster mascot you have. You are going to have to leave some margin so hands and a head can move freely.
There is a small breadboard on the skeleton. It provides voltage for the servos so you don't have to run (+) and ground separately for each motor. It would be 3x4 = 12 cables. If you use one pair of cables for all the servos you are only going to need 6 cables. And don't forget about the proximity sensor and an red LED that go to Cookie Monster eyes.
Step 3: Software
Cookie Monster software is written in node.js. The code is on Github https://github.com/maestr0/intel-hackathon/
Please use Intel® XDK IoT Edition IDE as it provides the best integration with the Edison board.
I used Cylonjs framework to simplify writing the code. This tutorial is not intend to cover Node.js nor Cylonejs.
I will just give you a brief overview of what the code does. Feel free to fork and modify it.
All the components have to be connected to appropriate pins on the Edison board. You can find in the code in main.js which sensor goes to which pin.
Cookie Monster API
There is also a server side component you are going to need for Slack integration. It is a simple Node.js app that you have to deploy somewhere and configure your Slack account to talk to that app API. The app code is here: https://github.com/maestr0/intel-hackathon/blob/ma...
You can install the app on https://www.heroku.com/. It's free
Slack Integration
Go to www.slack.com. Create an account.
Go to you account settings, find Integrations section. Add Outgoing WebHooks.
As an URL put an url of your app: http://mycookiemonsterapi.com/add_command
Channels: Any
Key Word: monster! (this can be anything, when a slack user uses this word whole message will be sent to the API)
The API buffers messages, keeps them in an ordered queue. Cookie Monster software running on Edison pulls items from the API queue and executes commands sent from Slack.
Example commands look like this:
monster! joke- this is to trigger a joke command which pulls a random joke from internet and uses Text To Speech (espeak package you have to install on Edison) to speak text out-loud.
monster! head 10- this moves a CM head to position 10. (0-180 are available values)
monster! say This is a sentence you want Cookie Monster to tell
Twitter integration
You are going to need a Twitter dev token. Put it to the code in the right place. Also modify the hashtags you want Cookie Monster to listen on. When a new twitt shows up with certain hashtags Cookie Monster is going to tell it via a bluetooth speaker and TTS.
Joke API
One of the Cookie Monster slack commands uses a third party API to fetch jokes.
It is a JSON api.
Bluetooth and espeak TTS
I created some shell scripts to make a bluetooth pairing easier. Also I created a say.sh script that runs TTS command. A text passed to that script is sent to the synthesizer.
https://github.com/maestr0/intel-edison
Copy those scripts on your Edison linux. Look at them and change for your needs. Those scripts are used by the main Cookie Monster app to pair a bluetooth speaker when the app starts and for TTS.
Step 4: Demo
A video presents the final result.
https://www.youtube.com/watch?v=-GKD45P1DjI