api-summit-2017-apis-at-home
This repository contains the code for the API Bridge, Alexa Skill and EV3 program. For more in-depth information, please take a look at this blog post: https://manuel-rauber.com/2017/05/30/alexa-start-lego-robot-connecting-amazon-alexa-to-lego-mindstorms-ev3/
Architecture
The following image describes the architecture used to use Alexa to command an EV3 robot.
API Bridge
The API Bridge is currently hosted on Azure, but can run anywhere, where Node.js and WebSockets are available. It is used to translate HTTP(S) Web API calls, which are sent from the Alexa Skill, into WebSocket commands (currently done via Socket.io v1) which are sent to the EV3 robot. The following APIs are exposed:
claw/open
: Opens the claw.claw/close
: Closes the claw.move/forward
: Indefinitely moves forward, until amove/stop
command is issued.move/backward
: Indefinitely moves backward, until amove/stop
command is issued.move/stop
: Stops the robot.doitdude
: Runs a predefined program to grab some beer in front of the robot.
Alexa Skill
The Alexa Skill uses a Lambda Function running Node.js 6.10. The following intents (currently only in German) are available:
ClawIntent
: Can open and close the claw.- Voice Command:
Zange {ClawOperation}
with the followingClawOperation
s:schließen
: Closes the claw.öffnen
: Opens the claw.
- Voice Command:
MoveIntent
: Can move the robot.- Voice Command:
Fahre {MoveOperation}
with the followingMoveOperation
s:vorwärts
: Moves the robot forwards.rückwärts
: Moves the robot backwards.
- Voice Command:
StopIntent
: Stops any movement.- Voice Command:
halt
.
- Voice Command:
DoItDudeIntent
: Runs the predefined program.- Voice Command:
hop
.
- Voice Command:
All intents call the appropriate API rather then calling the function on the robot directly. By that architecture, the business logic has been moved to the API bridge, allowing more custom integration scenarios.
EV3 Program
The EV3 program has been written in Python by using the ev3dev operating system. The program opens a WebSocket connection to the API Bridge which is used for communication.