Class 6 - Coding, AI & Robotics Course
-
Coding
Session 1: Introduction to Coding3 Topics -
Session 2: Backdrop, Costume, and Animation3 Topics|1 Quiz
-
Session 3: Basics of Algorithm and Flowchart3 Topics|1 Quiz
-
Session 4: Basics of Pseudocode3 Topics|1 Quiz
-
Session 5: Getting Started with Quarky3 Topics|1 Quiz
-
Session 6: Variables: The Multitaskers4 Topics|1 Quiz
-
Session 7: Arithmetic Operators4 Topics|1 Quiz
-
Session 8: Conditional Statements3 Topics|1 Quiz
-
Session 9: Logical Operators4 Topics|1 Quiz
-
Session 10: Nested Conditional Statements2 Topics|1 Quiz
-
Session 11: Loops3 Topics|1 Quiz
-
Session 12: Touch Based Piano2 Topics
-
Session 13: Criterial in Loops5 Topics|1 Quiz
-
Session 14: Catch the Fruit Game - Part 12 Topics
-
Session 15: Catch the Fruit Game - Part 22 Topics|1 Quiz
-
Artificial IntelligenceSection 16: Introduction to Artificial Intelligence3 Topics|1 Quiz
-
Session 17: Basics of Face Detection2 Topics|1 Quiz
-
Session 18: Face Expression Detection2 Topics|1 Quiz
-
Session 19: Mimic Face with Quarky1 Topic
-
Session 20: Face Filter - Part 12 Topics
-
Session 21: Face Filter - Part 22 Topics
-
RoboticsSession 22: Basics of Robotics2 Topics|1 Quiz
-
Session 23: Wirelessly Controlled Robot2 Topics
-
Session 24: Introduction to Sensors3 Topics|1 Quiz
-
Session 25: Introduction to Actuators3 Topics|1 Quiz
-
Session 26: Face Tracking with Robot2 Topics
-
Session 27: Obstacle Avoidance Robot - Part 13 Topics
-
Session 28: Obstacle Avoidance Robot - Part 22 Topics|1 Quiz
-
Session 29: Edge Detector Robot - Part 13 Topics
-
Session 30: Edge Detector Robot - Part 22 Topics|1 Quiz
-
Capstone ProjectCapstone Project
Activity 2: Face Tracking Robot
Activity 2: Face Tracker
One of the most fascinating activities is face tracking, in which the Quarky 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 robot.
Logic
- If the face is tracked at the center of the stage, the servo angle should be straight.
- As the face moves to the left side, the servo angle will also move to the left side.
- As the face moves to the right side, the servo angle will also move to the right side.
Let’s Code!
- Open PictoBlox and create a New File.
- Select the coding environment as Block Coding.
- Drag and drop the when green flag clicked block from the Events palette.
- Then, add a turn () video on stage with () % transparency block from the Face Detection extension and select on from the drop-down. This will turn on the camera.
- Click on the green flag and your camera should start. Make sure this part is working before moving further.
- Add the forever block below turn () video on stage with () % transparency from the Control palette.
- Inside the forever block, add an analyse image from () block. This block will analyze the face the camera detects. Select camera from the dropdown.
- To change the position of your servo add the set servo on () to () angle below analyse image from ().
- 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.
- Place get () of face () at the first place of addition () + (), and 3 at the second place. From the dropdown select X position.
- Next, drag the addition ()+() block inside the set servo () to () angle block. Put 90 in the first space and put the ()/() block in the second space.
- Save the file with the name Face Tracking Robot.
Servo Block Explained
- At the center of the stage, we will get the X position value which is zero.
- 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.
- The x position value is divided by 3 which gives precise positioning.
- To set the servo angle at 90 when the face is at the center of the stage we have added 90 to the X position value.
- As we move to the left side the servo angle value will get decreased as the X position value is going in negative.
- As we move to the right side the servo angle value will get increased as the X position value is going in positive.
Testing
Our next step is to check whether it is working right or not. Whenever your face will come in the front of the camera, it should detect it and as you move to the right or left, the head of your robot should also move accordingly.
Assignment
Before you move on to the next lesson, a small assignment awaits you!
You must upload the PictoBlox program you created in this activity to the website. Submitting the assignment is a must in order to receive the certificate after completing the course.
Follow the steps below to upload your assignment:
- Click on Browse.
- Search and Select your saved Project file(.sb3) and Click Open.
- Click on Upload to submit the assignment.
Good luck!