# How to Dance with Your Robot
With the rapid changes in digital technology, the ways in which people and machines interact are becoming more and more diverse and intelligent. Robots are no longer just cold machines, they are gradually learning to understand and mimic human movements, and even participate in our daily entertainment activities.
With Machine Learning 2.0 functionality it is possible to capture human movements through a computer camera and program these movements to be transmitted to robots so that they can react and move accordingly.
This #How to will show how to achieve dancing with robots through simple programming and machine learning. Not only does this provide an interesting entry point for learning programming and AI, it also shows us new possibilities for future human-robot interaction.
What does Machine Learning 2.0 do?
• Action Recognition:
Through machine learning algorithms, the system can learn and recognize different human actions. When you make specific actions in front of the camera, the system is able to compare these actions with previously trained data and recognize the actions you have made.
• Pattern Matching and Classification:
The machine learning model learns to classify the input action data into different action categories during the training process. This allows the robot to accurately categorize a particular action into a predefined action type when it is recognized.
• Mapping of actions to responses:
The machine learning model recognizes actions and associates these actions with the corresponding robot's physical responses and music playback. Whenever an action is recognised, the robot will react accordingly, e.g. move, turn, play a specific music clip, etc., based on predefined rules or patterns.
• Adaptive Learning:
If the model is able to learn continuously through a feedback mechanism, the recognition accuracy and reaction speed of the system will gradually improve as you continue to interact with the robot. This means that the robot will mimic your movements more and more accurately and react more naturally.
How to make robots dance together
Step1:Preparation
- An assembled mBot 2 cart
- Type C cable*1
- A computer with internet access
After assembling the mBot2, use the data cable to connect the mBot2 to your computer, open the Wise Programming Tool (desktop, web, mobile), connect to the mBot2, and switch to upload mode.
Open mBlock
- Visit the mBlock website: https://mblock.cc/
- Click【Code with Block】to open the editor
Step 2: Machine learning
Substep 2.1: Add Extension
- Click on【extension】in 【Sprites】
- Download and add Machine Learning 2.0
- Create/Manage model in 【Machine learning】
Substep 2.2: Training model
- Create a new 【Pose project】 project
- And then the first thing we need to do is add an audio sample of the background noise
Add more image samples from different angles or magnitudes to be more accurate in recognition.
Capture and record the recognizable actions of the corresponding notes in the way described above.
After all the recordings are finished, click 【Train model】 to start training the model
Step 3: Built-in program
Start by creating a hat block
- Then drag in the trained recognition block
- Repeat execution: send an upload pattern message with the recognition results
Once built, the webcam captures human body movements and sends signals back to the robot via the mBlock to make it act accordingly.
- Select 【Devices】 to start programming
- Add 【Upload Mode Broadcast】
- Select 【Upload】
- Creating hat blocks for program building
- After creating the hat block, set the size of volume and audio speed first
- Then set the decision condition: upload mode information = duo
- Adding music blocks and action blocks to conditional blocks
After this step, click 【Upload Code】, wait for the upload to be successful, and you'll be able to dance with a robot!
Full Program & Download
Click to download