Hello everyone.
Welcome back to our channel.
I hope you all are safe and sound.
In one of our previous videos, we showed you
how to make a gesture-controlled mobile robot
with evive using PictoBlox’s Machine Learning extension.
You can find its link in the card above.
In this video, we will show you how to control
an Arduino Uno Robot with hand gestures using
PictoBlox’s Machine Learning extension.
The robot should move forward if we keep our palm straight.
It should turn left If we tilt our hand left.
It should turn right If we tilt our hand right.
And the robot should stop if we close our fist.
Prerequisites are an assembled 2-wheel / 4-wheel drive Arduino robot,
Click on the card above to make the robot.
A laptop or a computer with a camera, the
latest version of PictoBlox, and
a good Internet connection.
Let’s begin by training the models.
Go to https://teachablemachine.withgoogle.com/.
Click the Get Started button.
A new page will open.
Click the Image Project tile.
Let’s begin by adding the first class, as
well be adding our sample image using Webcam,
click on the webcam button to start the camera.
We’ll first make the class for the robot
to move forward, thus, keep our palm open
and record the images.
Similarly, we will be creating the other three classes too i.e.
Right.
Left and
Stop.
Your training data is complete.
It will look something like this at the end.
Now, that we have included the sample image,
we need to train the model accordingly.
Thus, click the Train Model button and wait
for the model to get trained.
You can have a look/test the trained model.
Now, that the model is perfect, let’s export the model.
Click on the Export Model button.
A popup will open.
Click the Upload my model button.
A sharable link will appear, Copy it.
Open PictoBlox we will first add the Machine Learning Extension.
To work with the all-new AI and ML extension,
you need to keep two things in mind:
First,
That you must sign in / login in PictoBlox from here.
Second,
You must have a good internet connection.
Click on the board button and select Arduino.
Before working with Arduino, let’s upload
the firmware to it.
Connect your Arduino Uno to your computer
using a USB cable.
Select the appropriate serial port.
Click on the Upload Firmware button.
Your firmware will be uploaded successfully.
Disconnect Arduino from the computer.
Now, you connect Arduino via Bluetooth.
Click on Connect button, and choose Bluetooth Ports.
Select the appropriate Bluetooth port from the list.
We now need to add the Machine Learning extension.
Click on the Add extension button.
Choose the Machine Learning Extension.
Now we need to load our model into PictoBlox.
Thus, click on Load Model.
A dialog box will appear, paste the copied
link into space given, and click on Load Model.
Wait for a little while till the models get loaded.
You may now see that the Machine Learning blocks are loaded.
Let’s first set up the stage.
First, drag-and-drop the when flag clicked
hat block from the Events palette to execute
the program when the green flag is clicked.
As we need to recognize the hand gestures
from the camera feed, place the turn on video
on stage with 0 transparency block from the
Machine Learning palette.
Next, snap connect motor () direction 1 () direction
2 () & PWM () block.
Choose 1 from the first dropdown, 6, 5, and
3 from the second, third and fourth dropdown respectively.
Duplicate this block and choose 2, 9, 10,
and 11 from the first, second, third, and fourth dropdowns respectively.
Place a forever block to make the code run continuously.
Next, we will recognize the gestures from
the stage and perform actions accordingly.
Thus, let’s make a few custom function blocks.
Go to My Blocks palette.
Click on Make a Block button.
First, we will make the function to make the
robot move forward.
Thus, write go straight into the name and click on OK.
You’ll see a hat block onto the scripting area.
Place the run motor 1 in direction forward
with speed 100% block from the actuators block.
Duplicate the above block and place it below
it and choose 2 from the first drop-down.
Similarly, we will make the custom blocks
to Turn Left, Turn Right, and Brake one by one.
Duplicate the two motor blocks and place them
below turn left and turn right block.
Let’s make a few changes into these blocks.
Into the Turn Left block, select reverse from
the second drop-down of the first block.
Into the Turn Right block, select reverse
from the second drop-down of the second block.
Into the Brack block, drag and drop the free
motor 1 block from the actuators palette.
and choose 2 from the second block.
Now, let’s move onto the main script.
Place an if-else block from the controls palette.
Drag and drop the is identified class from
web camera is forward block from the machine
learning palette and choose stage from the
drop-down.
This will let us recognize the forward class
from the trained model.
Place the go straight block into the if arm.
Duplicate the if block and place it into the else arm.
Select left from the if block and
replace go straight block with the turn left block.
Repeat the same process for right and stop.
The script is now complete,
click on the green flag to run the script.
Don’t forget to share your creations and queries with us in our PictoBlox community on FaceBook.
Also, if you liked the video, subscribe to
STEMpedia and
follow us on Facebook, Instagram, and Twiter.
Bye.
Stay Safe.
