It goes without saying that The Child, or rather Baby Yoda, has become an icon in the Star Wars universe in the short time since its conception and appearance on the show, The Mandalorian. I've wanted to make a LEGO model of it for a long time, and finally found myself an opportunity to do so, all the while exploring Alexa voice-control for the first time as well.
I've had a blast building and programming this thing over the holidays, and it came out looking pretty good. (or so I'd like to believe!)
I've done my best to include step-by-step instructions that are easy to understand for beginners such as myself. Hope you enjoy :p
We'll be learning how to create an Alexa gadget, an Alexa skill, and adding/editing commands in that skill.
We'll also be installing the ev3dev operating system by writing the ev3dev disk file to a micro SD card which we'll insert into our Brick.
We'll be setting up Visual Studio Code, where we'll edit our program, and get familiar with the Alexa Skills environment and code editor as well.
Make sure to download and unzip the Alexa_EV3 Challenge.zip file while setting everything up!
Building the ModelI've attached building instructions for the model below, at the bottom of the page as well as a wiring diagram tell what motors/sensor ports we'll be using.
I knew I wanted a biped-type robot to replicate the waddle from the show, so I had several iterations or walking mechanisms- that all failed for a variety of reasons. They were not built to take weight or actually carry the robot forward, or the gears would slip no matter how much reinforcement.I eventually settled on the legs used in the NXT Alpha Rex model. I had memories of building this as one of my first Mindstorms project way back when I was 8 yo. Since the motor frame completely changed from NXT to EV3, I had to adjust and improvise a lot of steps while trying to maintain the same functionality. Hey, if it ain't broke, don't fix it!
With the lower body portion finished, I tried tackling the head. It was one of the harder features to get right. I knew I could get away with anything under the felt covers but the head was one thing that couldn't be simply draped over. A little bit of playing around with angular beams and I found an oval-ish shape that I was satisfied with. Used gears for the eyes, found two bright green Technic panels that I affixed to the back side, and the wing panels for ears.You can't say the semblance isn't there! I did what I could with what I had, I suppose... The arms were pretty easy, and simply attached near the front of the legs. It isn't much of a looker without the sheets, pretty bare I'd say, but when it's all covered up it all comes together very nicely!
. You can find a chart for wiring down below...
With the physical model all done, we can move on to programming and setting up our Alexa skills! You're gonna wanna pay extra attention from here!
- Start by downloading the ev3dev disk image file here.
- Format your micro SD card, and follow these instructions to write the image file to an SD card using balenaEtcher.You can also use win32DiskImager to write the image file, and you can download it at this link.
- Once your disk image is written, insert the micro SD card into your EV3 Brick and power it on. It might take a few minutes, and it'll go through quite a few splash screens until you reach the main menu.From here, follow these instructions to connect your brick to the internet using your laptop and a bluetooth connection.
At the end, you should have an IP address displayed at the top-right corner of your brick screen. Overall you should have a brick screen that looks something like this:
- Download and install Visual Studio Code.
- Download and unzip the file Alexa_EV
- 3 Challenge.zip
- Open Visual Studio Code, and select File > New Window from the top menu.
- Select the now unzipped
Alexa_EV3 Challenge
folder - Click on the Extensions icon on the left, and search for the ev3dev-browser extension.If you already have a version of python installed on your system, you can also download the Python extension(Don't install it if you don't have Python already installed).
- Once the extensions are done installing, navigate to the Explorer icon and click the arrow next to the EV3DEV DEVICE BROWSER to expand more options.
- Click "Click here to connect to a device".
- Select your EV3 brick. It should be called ev3dev by default. If you don't see your brick show up in the device list, try manually entering the IP address shown at the top-right corner of your EV3 brick.If you don't see an IP address on your brick, you'll need to reconnect your brick to the internet. Follow these instructions.
With this, your VS Code is all set up. If your brick is connected, you should be seeing a green dot next to it like so:
You can click on the Send workspace to device button to copy over the contents of the Alexa_EV3 Challenge folder to your EV3 brick.
- Log into your Amazon Developer account, or sign up for one, and open your developer console.
- Navigate to Alexa > Alexa Voice Service > Products, and create a new productor click here.
- Fill in the details as given below:
Name: MINDSTORMS EV3
Product ID: EV3_01
Product type: Alexa Gadget
Product category:Animatronic or Figure
Product description: Whatever you like
Skip upload image
Do you intend to distribute this product commercially?: No
Is this a children’s product or is it otherwise directed to children younger than 13 years old?:No
It should look something like this before you submit:
- Accept the service agreement and submit the form.
- Click on your new gadget, you should see your Amazon ID and Alexa Gadget Secret. Copy them into respective fields in the
run.ini
file in VS Code. - When you're done updating the file, click on the Send workspace to device button.
Now to actually create the skill we'll be using to control our robot!
- Log into your Amazon Developer account, and open your developer console.
- Navigate to Alexa > Alexa Skills Kit and click Create Skill.or click here.
- Enter any skill name. This will be the name we'll be using to invoke our skill, and we can change this any time. I made mine Mindstorms.Also select the language that matches the one set on your Amazon Echo device, which in my case is English (US).Select Custom model and Alexa-hosted (Node.js) backend resources.
- Scroll up and click on Create Skill.
- Choose the Hello World Skill template.
- Once your skill has been successfully created, click on the Interfaces icon in the left-side navigation menu, and enable Custom Interfaces, and then scroll back up and click Save Interfaces.
- Once your interface has been saved, click on the JSON Editor icon in the left-side navigation menu. Copy the contents of the
model.json
file from VS Code and paste into the JSON editor. Click on Save Model and then Build Model. - Now, in the top navigation menu, select the Code option.
- In the code editor, click on the new file icon and enter the path and file name as
/lambda/common.js
- Copy the contents of
common.js
,index.js
,package.json
, andutil.js
from VS Code to the Alexa Skill Code Editor. - Click on Save and then Deploy.
Now we're all set! Let's get to connecting our brick to our Echo device to test our new Alexa Skill!
Running the RobotWith all else out of the way, we can finally run our code and interact with our model!
- Ensure that VS Code is connected to your brick. It should be showing up in your EV3DEV Device Browser with a green dot next to it.
- Click on the Send workspace to device button to copy over the updated contents of the Alexa_EV3 Challenge folder to your EV3 brick.
- Once the files have been copied over, right-click on the python file
run.py
in the device browser and click Run. - Once the program starts for the first time, you'll see a prompt on both your EV3 brick and VS Code debug console saying that your device is in pairing mode. Use these instructions to pair your Alexa Gadget (your EV3 brick) to your Echo device using the Alexa app on your phone.This prompt will only show up on the first run, subsequent runs will automatically pair with your Amazon Echo.
- You should now see a prompt saying your gadget has paired on your brick screen and debug console.
Now we can start issuing commands!
The commands that you can use to control the robot have to be in the following format:
Move Intent:
{
Direction
} now
{
Direction
} {
Duration
} seconds
move {
Direction
} for {
Duration
} seconds
SetSpeedIntent:
set speed {
Speed
} percent
set {
Speed
} percent speed
set speed to {
Speed
} percent
SetCommand Intent:
activate {
Command
} mode
move in a {
Command
}
fire {
Command
}
activate {
Command
}
You can refer to the model.json
file for the intent formats, and possible slot values( for commands, speed, duration).
If everything is running great, you can now wrap up your robot nice and snug with some brown felt. I must admit, the model isn't much of a looker without it! It only starts to come together when its all covered up.
Here's a demonstration video I hastily put together, enjoy!
Comments