4. Lesson 4

../_images/4_110.png

4.1. Introduction

Welcome to Micro : bit Smart Car! In the lesson, we will explore Micro : bit, and learn how to control the Micro : bit Smart Car through programming.

4.2. Objective

Students will fully understand the theory, and the function of the Micro : bit of the AI lens in the Smart Car. Also, they will learn how to program the AI lens for achieving more functions of the Smart Car.

4.3. HuskyLens tag recognition function

4.3.1. what is tag recognition?

Tag recognition technology refers to the technical method of encoding and identifying commodities, which is an effective and standardized way. There are many kinds of tags in our daily life, such as barcodes and QR codes.

In Huskylens, it distinguishes different tags by learning new tags. The color ID will be displayed when the Huskylens senses the same tag.

4.3.2. Applications of tag recognition

Logistics: cargo tracking in the logistics process, automatic information collection, warehousing applications, port applications, express delivery.

Retail: real-time statistics of commodity sales data, replenishment, anti-theft.

Manufacturing: real-time monitoring of production data, quality tracking, automated production.

Apparel industry: automated production, warehouse management, brand management, single product management, channel management

Medical: medical device management, patient identification

../_images/4_210.png

4.3.3. Huskylens tag recognition

The tag recognition function of HuskyLens can be divided into three parts: detecting tag, learning tag and identifying tag.

4.3.3.1. Detecting tag

When HuskyLens detects tags, all tags detected will be automatically framed with white boxes on the screen.

../_images/4_39.png

4.3.3.2. Learning tag

Align the "+" in the center of the HuskyLens screen with the tag that needs to be learned. short or long press the "Learning Button" to complete the learning of the first tag. After releasing the "learning button", the screen will prompt: "Press the button again to continue! Press other buttons to end".

To continue learning the next tag, press the "Learning Button" before the end of the countdown. Then align the "+" in the center of the HuskyLens screen with the next tag to be learned, and short or long press the "Learning Button" to complete the second tag learning.

If you no longer need to learn other tags, just press the "function button" before the countdown ends, or do not operate any buttons and wait for the countdown to end.

../_images/4_41.png

4.3.3.3. Identifying tag

When HuskyLens encounters the learned tags again, there will be colored borders on the screen to select these tags and display their IDs. The size of the border changes with the size of the tags, and the border automatically tracks those tags.

../_images/4_5.png

4.3.4. AprilTag

What is AprilTag ?

AprilTags is a visual reference system from the University of Michigan project team, mainly used in fields such as AR, robotics and camera calibration. The tag acts like a barcode, storing a small amount of information (tag ID) while also allowing simple and accurate 6D (x, y, z, roll, pitch, yaw) pose estimation of the tag.

Huskylens only supports the built-in AprilTag visual benchmark library, as shown below:

../_images/4_61.png

4.4. Exercise 1

Let's familiarize yourself with the HuskyLens tag recognition function and learn five tags. Design a program to move forward, backward, turn left, turn right and stop when HuskyLens recognizes different labels. The following tags are available:

../_images/4_71.png

Tags and street signs can be arranged as shown in the figure below to distinguish the direction/action corresponding to the tag.

../_images/4_8.jpg

4.5. Exercise 2

Improve the program of exercise 1, so that the car will recognize and change the movement when it reaches a certain distance from the label. Set up simple routes yourself and let the car do it.

Tip: Calculate the distance using the height of the label

Concept map:

../_images/4_91.png

4.6. Exercise 3: Self-service supermarket cash register

4.6.1. Mission 1:Identify goods

HuskyLens learns and recognizes the tag affixed to three different goods. Design a program to display the corresponding goods names on the Micro:bit's dot-matrix display light. (Examples: water bottle, biscuits, knife)

../_images/4_101.png

4.6.2. Mission 2:Start and end scan

Improve the program of task 1, let the customer press the A button of the Micro:bit to enter the goods scanning program. After pressing the B key, the microbit board will display all the goods' names that are recognized by HuskyLens and end the scanning process. The next customer presses the A key to restart scanning.

4.6.3. Mission 3:goods settlement

When the products to be purchased are all within the range of the HuskyLens screen, press the B key. The selling prices of all the products will be added up to become the total price, and the scan code will be completed. The dot-matrix light will display the names of all products purchased by the customer and the total price.

Tip: Create a variable to store the state of the B button and use this variable to decide whether to end the scan program.

../_images/4_11.jpg

4.7. Answer

4.7.1. Exercise 1

../_images/4_12_1.png

4.7.2. Exercise 2

After identifying that the height of the label is less than 50 (about one-fifth of the height of the screen), the program determines that the car has reached a suitable distance to change the action.

../_images/4_131.png

4.7.3. Exercise 3

Create a new variable "total" to store the total price of the item. Every time you press the A button to start identifying the product, the total price of the previous customer will be reset to zero.

../_images/4_141.png