Table of Contents

turn () video on stage with () % transparency

Description

turn () video on stage with () % transparency block controls the control the camera feed on the stage.

You can change the following parameters of the block:

  1. Camera state:
    1. OFF – The video feed on the stage will stop.
    2. ON – The video feed on the stage will start.
    3. ON flipped – The video feed on the stage will start with the video mirrored. So, your right hand will show left and vice versa.
  2. Transparency: This parameter makes the video translucent. O is defined as the camera feed shown on the stage, and 100 is the video that will fade out entirely from the stage.

Example

A waste management system that will differentiate the waste based on its type. If it detects biodegradable waste, the LEDs Quarky’s matrix will turn green. If it’s non-biodegradable waste, the LEDs will turn blue.

Script

Output

Read More
Learn about face-tracking, and how to code a face-tracking Quadruped robot using sensors and computer vision techniques.

Introduction

A face-tracking robot is a type of robot that uses sensors and algorithms to detect and track human faces in real-time. The robot’s sensors, such as cameras or infrared sensors, capture images or videos of the surrounding environment and use computer vision techniques to analyze the data and identify human faces.
Face-tracking robots have many potential applications, including in security systems, entertainment, and personal robotics. For example, a face-tracking robot could be used in a museum or amusement park to interact with visitors, or in a home as a companion robot that can recognize and follow the faces of family members.

One of the most fascinating activities is face tracking, in which the Quadruped can detect a face and move its head in the same direction as yours. How intriguing it sounds, so let’s get started with the coding for a face-tracking Quadruped robot.

Logic

  1. If the face is tracked at the center of the stage, the Quadruped should be straight.
  2. As the face moves to the left side, the Quadruped will also move to the left side.
  3. As the face moves to the right side, the Quadruped will also move to the right side.

Code Explain

  1. Drag and drop the when green flag clicked block from the Events palette.
  2. Then, add a turn () video on stage with () % transparency block from the Face Detection extension and select one from the drop-down. This will turn on the camera.
  3. Add the set pins FR Hip () FL Hip () FR Leg () FL Leg() BR Hip () BL Hip () BR Leg () BL Leg () block from the Humanoid extension.
  4. Click on the green flag and your camera should start. Make sure this part is working before moving further.
  5. Add the forever block below turn () video on stage with () % transparency from the Control palette.
  6. Inside the forever block, add an analyzed image from the () block. This block will analyze the face the camera detects. Select the camera from the dropdown.
  7. Create a variable called Angle that will track the angle of the face. Based on the angle, the robot will move to adjust its position.
  8. Here comes the logical part as in this, the position of the face on the stage matters a lot. Keeping that in mind, we will add the division () / () block from the Operator palette into the scripting area.
  9. Place get () of the face () at the first place of addition () + (), and 3 at the second place. From the dropdown select X position.
  10. If the angle value is greater than 90, the Humanoid will move left at a specific speed. If the angle is less than 90, the Humanoid will move right at a specific speed. If the angle is exactly 90, the Humanoid will return to its home position.
Block Explained

  1. Create a variable called Angle and assign it the value of the face’s position.
  2. At the center of the stage, we will get the X position value which is zero.
  3. As we move to the left side the X position value will give you the negative value and as we move to the right side the X position value will give you the positive value.
  4. The x position value is divided by 3 which gives precise positioning.
  5. To set the angle at 90 when the face is at the center of the stage we have added 90 to the X position value.
  6. As we move to the left side the angle value will get decreased as the X position value is going in negative.
  7. As we move to the right side the angle value will get increased as the X position value is going in positive.

Code

Output

Our next step is to check whether it is working right or not. Whenever your face will come in front of the camera, it should detect it and as you move to the right or left, the head of your  Quadruped robot should also move accordingly.

Read More
Explore the power of machine learning in recognizing hand gestures and controlling the movements of a Quadruped robot.

Introduction

This project demonstrates how to use Machine Learning Environment to make a machinelearning model that identifies the hand gestures and makes the Quadruped move accordingly. learning model that identifies the hand gestures and makes the qudruped move accordingly.

We are going to use the Hand Classifier of the Machine Learning Environment. The model works by analyzing your hand position with the help of 21 data points.

Hand Gesture Classifier Workflow

Follow the steps below:

  1. Open PictoBlox and create a new file.
  2. You can click on “Machine Learning Environment” to open it.
  3. Click on “Create New Project“.
  4. A window will open. Type in a project name of your choice and select the “Hand Gesture Classifier” extension. Click the “Create Project” button to open the Hand Pose Classifier window.
  5. You shall see the Classifier workflow with two classes already made for you. Your environment is all set. Now it’s time to upload the data.

Class in Hand Gesture Classifier

There are 2 things that you have to provide in a class:

  1. Class Name: It’s the name to which the class will be referred as.
  2. Hand Pose Data: This data can either be taken from the webcam or by uploading from local storage.

Note: You can add more classes to the projects using the Add Class button.
Adding Data to Class

You can perform the following operations to manipulate the data into a class.

  1. Naming the Class: You can rename the class by clicking on the edit button.
  2. Adding Data to the Class: You can add the data using the Webcam or by Uploading the files from the local folder.
    1. Webcam:
Note: You must add at least 20 samples to each of your classes for your model to train. More samples will lead to better results.

We are going to use the Hand Classifier of the Machine Learning Environment.

 

Training the Model

After data is added, it’s fit to be used in model training. In order to do this, we have to train the model. By training the model, we extract meaningful information from the hand pose, and that in turn updates the weights. Once these weights are saved, we can use our model to make predictions on data previously unseen.

The accuracy of the model should increase over time. The x-axis of the graph shows the epochs, and the y-axis represents the accuracy at the corresponding epoch. Remember, the higher the reading in the accuracy graph, the better the model. The range of the accuracy is 0 to 1.

Testing the Model

 

Hand Pose Classifier

The model will return the probability of the input belonging to the classes.You will have the following output coming from the model.

Logic

The Quadruped will move according to the following logic:

  1. When the forward gesture is detected – Quadruped will move forward.
  2. When the backward gesture is detected – Quadruped will move backward.
  3. When the left gesture is detected – Quadruped will turn left.
  4. When the right gesture is detected – Quadruped will turn right.

Code

Output

Read More
In this activity, learn how to create a new Machine Learning model that will be able to identify and detect different types of hand poses and that can help us to control the Mecanum Pick and Place Robot.

In this activity, we will try to create a new Machine Learning model that will be able to identify and detect different types of hand poses and that can help us to control the Mecanum Pick and Place Robot. This activity can be quite fun and by knowing the process, you can develop your own customized hand pose classifier model easily!

We will use the same model that we have created in the previous Hand Pose Controlled Mecanum model to avoid any misdirection and confusion.

Note: You can always create your own model and use it to perform any type of functions as per your choice. This example proves the same point and helps you understand well the concept of Machine Learning models and environment.

Hand Gesture Classifier Workflow

Follow the steps below:

  1. Open PictoBlox and create a new file.
  2. Select the Block coding environment as appropriate Coding Environment.
  3. Select the “Open ML Environment” option under the “Files” tab to access the ML Environment.
  4. Click on “Create New Project“.
  5. A window will open. Type in a project name of your choice and select the “Hand Gesture Classifier” extension. Click the “Create Project” button to open the Hand Pose Classifier window.
  6. You shall see the Classifier workflow with two classes already made for you. Your environment is all set. Now it’s time to upload the data.

Class in Hand Gesture Classifier

There are 2 things that you have to provide in a class:

  1. Class Name: It’s the name to which the class will be referred as.
  2. Hand Pose Data: This data can either be taken from the webcam or by uploading from local storage.

Note: You can add more classes to the projects using the Add Class button.
Adding Data to Class

You can perform the following operations to manipulate the data into a class.

  1. Naming the Class: You can rename the class by clicking on the edit button.
  2. Adding Data to the Class: You can add the data using the Webcam or by Uploading the files from the local folder.
    1. Webcam:
Note: You must add at least 20 samples to each of your classes for your model to train. More samples will lead to better results.
Training the Model

After data is added, it’s fit to be used in model training. In order to do this, we have to train the model. By training the model, we extract meaningful information from the hand pose, and that in turn updates the weights. Once these weights are saved, we can use our model to make predictions on data previously unseen.

The accuracy of the model should increase over time. The x-axis of the graph shows the epochs, and the y-axis represents the accuracy at the corresponding epoch. Remember, the higher the reading in the accuracy graph, the better the model. The range of the accuracy is 0 to 1.

Testing the Model

To test the model, simply enter the input values in the “Testing” panel and click on the “Predict” button.

The model will return the probability of the input belonging to the classes.

Export in Block Coding

Click on the “Export Model” button on the top right of the Testing box, and PictoBlox will load your model into the Block Coding Environment if you have opened the ML Environment in the Block Coding.

Logic

The mecanum will move according to the following logic:

  1. If the detected class is “forward”, we will make the Mecanum move forward.
  2. When the backward gesture is detected – Mecanum will move backwards.
  3. When the Lateral Left gesture is detected – Mecanum will move towards the left direction laterally with the help of its omnidirectional wheels.
  4. When the Lateral Right gesture is detected – Mecanum will move towards the right direction laterally with the help of its omnidirectional wheels.
  5. When the Normal Right gesture is detected – Mecanum will rotate on a single point towards the right direction.
  6. When the Normal Left gesture is detected – Mecanum will rotate on a single point towards the left direction.
  7. When the Stop gesture is detected – Mecanum will stop and initiate the Pick Mechanism using the Pick function.
  8. When the Circular Motion gesture is detected – Mecanum will initiate the Place Mechanism using the Place function.

Code

Initialization

Main Code

Output

Forward-Backward Motion:

Circular Right-Left Motion:

Lateral Right-Left Motion:

Pick and Place Mechanism with Hand Pose:

Read More
All articles loaded
No more articles to load