Project 2: Easy ETC (Electronic Toll Collection) System

When we drive on the expressway, we would find that it's nothing special at ordinary times, but if it comes to holidays, the toll stations are always jammed with vehicles!

With the promotion of ETC, congestion at toll stations has also reduced. The so-called ETC is a non-stop electronic toll collection system. It adopts a way of collecting user fee electronically, when cars owners with ETC drive through toll stations in a low speed, tolls are charged automatically.

projectImage

Can Maqueen Plus realize ETC function? In this project, let's make a simple and easy ETC system together, so that when the Maqueen Plus is on the "expressway", it can also achieve non-stop charge!

Function Description:

Tag recognition function of HuskyLens is applied in this project. Two tags stand for the entrance and exit of toll stations respectively. By recording the interval time, mileage and toll are calculated, thus realizing an easy ETC function of Maqueen Plus.

Materials Checklist:

projectImage

Knowledge Extension:

Tag recognition is a branch of machine vision and is widely used in production and life.

1. What is Tag Recognition?

Tag recognition technology refers to a technical method of effective and standardized encoding and identification for goods. In life, there are many kinds of tags, such as barcode and QR code.

projectImage

AprilTag visual reference library is adopted in HuskyLens. AprilTag can quickly detect labels and calculate relative positions through specific labels (similar to QR code, but with reduced complexity to meet real-time requirements).

HuskyLens only supports recognition of the built-in AprilTag visual reference library tags, as shown in the following picture.

projectImage

2. The Working Principle of Tag Recognition

AprilTag's algorithm mainly includes the following steps:

i. Edge detection, looking for the edge contour in the image.

projectImage

ii. Quadrangle detection, finding out quadrangles in all contour shapes.

projectImage

iii. Decoding, pairing and checking the quadrangles detected.

projectImage

3. Demonstration of HuskyLens Tag Recognition Function

1. Detecting Tag

When HuskyLens detects the QR code tags, all the detected tags of QR code will be automatically selected with a white frame on the screen.


projectImage
2. Learning Tag

Point the “+” symbol at the tag, and short press the “learning button” to complete the learning of the first Tag.

projectImage

After releasing the "learning button", the screen will prompt: "Click again to continue! Click other button to end". Please short press the "learning button" within countdown if you want to learn next tag. If not, short press the "function button" before the countdown ends, or do not press any button to wait for the countdown end.

In this project, two tags need to be learned, so before the countdown ends, press the "learning button", then point the "+" symbol at the next tag to be learned, and short press the "learning button" to learn.

The number of tag ID is in the same order as the tag learning, that is, the ID will be marked as "tag: ID1", "tag: ID2", "tag: ID3", and so on. And the frame colors for different tags are also different.

3. Recognizing Tag

When HuskyLens encounters the tags that have been learnt, a colored frame with an ID will be displayed on the screen. The size of the frame will change according to the size of the QR code, and the frames will automatically trace these QR code.

projectImage

Project Practice:

How is the tag recognition of HuskyLens used? How to calculate the interval time? Let's break down the whole project into several small tasks and complete the simple ETC step by step.

This project will be broken down to three steps to complete the task. First, we will learn to use tag recognition function of HuskyLens and display the tag ID on the LED screen of the mainboard. Then we will learn how to use "system runtime" to calculate the time difference between two recognitions. Finally, we’ll improve the whole project and achieve simple ETC function.

Task 1: Get to Know Tag Recognition

1.Hardware Connection

Like in the project of the numbered musical notation of color, HuskyLens is fixed on Maqueen Plus through a bracket and connected to the I2C connector.

The connection steps are the same in the following projects, so as not be repeated.

2.Program Design

STEP 1 Learning and Recognition

Here, you can choose two Tags at will to let HuskyLens learn. (Note: Firstly, switch to "learn multiple" mode)

projectImage

STEP 2 Mind+ Software Settings

Just like the color recognition project, open Mind+ software (163 version or above) and switch to "Upload mode".

Click "Extensions" and load "micro:bit" under "Board", click to load "Maqueen Plus" under "Expansion", and click to load "HuskyLens AI Camera" under "Sensor".

The software settings in the following projects are all the same and will not be repeated.

STEP 3 Instruction Learning

Let's take a look at some of the main instructions.

①Obtaining whether IDx is in the picture from the requested "result". The box corresponds to the algorithm targeted with box on the screen, and the arrow corresponds to the algorithm targeted with arrow on the screen. Currently, the arrow is only selected for line tracking algorithm, and the box is selected in all other algorithms.

projectImage

3.Program Example

projectImage

4.Execution Result

When HuskyLens recognizes the QR code in ID1, the LED screen of the mainboard displays 1; when HuskyLens recognizes the QR code in ID2, the screen displays 2.

projectImage

Task 2: Record recognition time point of two QR codes and calculate the time difference

1. Program Design

STEP 1 Function Analysis

From life experience, a car is charged from entering into one expressway toll station, and charging stops when it exits from another toll station.

Corresponding to our project, the start time point is recorded when ID1 QR code is identified and the ending time is recorded when the ID2 QR code is identified. After that, the time difference is concluded and the mileage fee is calculated.

There may be a problem here: what if the ID1 QR code is recognized twice by accident?

Each “in” corresponds to an “out” on expressway. We can adopt such a one-to-one correspondence method as well. When ID1 is recognized for the first time, the start time is recorded, and thereafter the end time is recorded only when ID2 is recognized afterwards.

STEP 2 Instruction Learning

Let's take a look at some of the main instructions.

①Indicating the real-time after the program starts running. The time unit for reading is millisecond.

projectImage

STEP 3 Flow Chart Analysis

projectImage
2. Program Example


projectImage

3. Execution Result

projectImage

When ID1 is recognized, the serial port outputs the system running time once, and then only when ID2 is recognized, the serial port outputs the system running time again and time difference as well.

Task 3: Start Maqueen Plus

1. Program Design

STEP 1 Function Analysis

In order to see the effect easily, we can start Maqueen Plus when the ID1 QR code is recognized and stop it when the ID2 QR code is recognized.

STEP 2 Instruction Learning

Let's take a look at some of the main instructions.

①Opening PID can control the rotation speed of the wheel in a closed loop, so that the actual rotation speed of the wheel is not interfered by the environment and is close to the set rotation speed.

Note: PID algorithm has a certain delay and is not recommended to be used together with greyscale line tracking.

projectImage

②Set the motor speed and direction.

projectImage

③Set motor stop

projectImage

STEP3 Speed Test

Using PID to control the wheel speed helps for precision of distance measurement. In order to calculate the actual mileage of Maqueen Plus, the speed must be measured first.

Test Program:

projectImage

Test Method: When the Maqueen Plus runs the above program, it will move forward for 10 seconds at a speed of 50. Record the starting and ending positions, measure the distance S (unit: cm), and then S/10 is the car mileage speed (unit: cm/sec).

2. Program Example
projectImage
3. Execution Result

When HuskyLens recognizes ID1 QR code, Maqueen Plus starts; after that, when HuskyLens recognized the ID2 QR code, Maqueen Plus stops.

Project Summary:

Project review

Understand the working principle of tag recognition in this lesson and learn the tag recognition function by using HuskyLens.

Combined with the PID function of Maqueen Plus, a simple ETC was created. The mileage and expressway toll were not calculated at the end of the project. Believing you can finish this part of data calculation on your own and display the final result on the LED screen.

Knowledge Nodes Recap

1.Understand the working principle of tag recognition;

2.Learn function and operation method of tag recognition of HuskyLens;

3.Learn PID control of Maqueen Plus

Project Extension:

After the completion of this project, you can search for local expressway toll rates on the Internet, and finalize the calculation of the toll in this project.

Please think about a question: expressway toll rates vary from provinces, but now some ETCs have already implemented trans-provincial charging, by which, no need to enter or exit trans-provincial toll stations. How does it work? Can we also simulate trans-provincial non-stop charging in our project?

(Tips: more QR codes can be used to represent different provinces. Each province is identified once. Finally, with the cost charged in each section, the total cost can be calculated.)

License
All Rights
Reserved
licensBg
0