Nowadays, the ongoing coverage of the logistics transportation industries is becoming a trend of era development with the boosting of economy and technology. While, it comes with a problem faced by all cargo distributing centers like port and storehouse---how to optimize truck’s loading efficiency?
The invention of AGV opened a new chapter in logistics transportation. Unmanned and intelligent ports and warehouses are established in cities. Compared with traditional docks and warehouses, it no longer depends on operators to control the equipment, since there are AGV car driving along the appointed route automatically to transport the goods to the designated place. This technology not only reduces the labor cost, but also improves positioning accuracy and reliability.
Automated Guided Vehicle (AGV) refers to an unmanned automatic vehicle with an electromagnetic or optical device that can drive along the marked path.
Can we turn Maqueen Plus into a small AGV truck? For instance, let it identify tags on the cargo, then transport cargo to the designated place according to the recognized result.
Function
This project will be mainly taking advantage of the HuskyLens Tag Recognition function. Each item has a unique tag. Maqueen Plus will select the corresponding path to drive along according to the ID number recognized by Huskylens sensor. For example, transport the cargo with tag ID1 to the endpoint of path 1, and so forth. Then all cargo can be placed into the designated position. The line-tracking sensors on Maqueen Plus will be used here.
Bill of Materials
Hardware Connection
1. Map: prepare a map like the one below. The calibration area will be the starting point. There are 9 endpoints marked in the image below, which also means 9 paths for Maqueen Plus, but only paths 1 to 4 will be used in this project.
2. Print Tags: select four tags from the object tags above, and print them out.
3. HUSKYLENS Assembly: install Huskylens sensor onto the top plate of Maqueen Plus, as shown below:
Knowledge Field
Tag recognition, a branch of machine vision, is widely used in all aspects of our production and daily life, such as product anti-counterfeiting, information acquisition.
1. What is tag recognition?
Tag recognition technology refers to a technical method for encoding and identifying goods in an effective and standardized way. There are many kinds of tags in our daily life, such as barcode, and QR codes.
AprilTag visual fiducial library is adopted in HuskyLens. AprilTag is a kind of vision positioning based on Quick Response Code road sign developed in recent years, it accurate three-dimensional position, direction and the tag ID of the two-dimensional code label relative to camera can be calculated.
Huskylens only supports for the built-in AprilTag visual fiducial library, as shown below:
2. Tag Recognition Principle
AprilTag algorithm mainly includes the following steps:
① Edge detection, find out the edge contour in the image.
② Quadrangle detection: find out the quadrangles in the contour.
③ Decoding: match and check the quadrangles.
3. Demonstration of HuskyLens Tag Recognition Function
① Tag Detection
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.
② Tag Learning
Point the “+” symbol at the tag, long or short press the “Learning button” to complete the first tag learning.
After releasing the”Learning button”, the screen will display: “Press the button again to continue! Press other buttons to end.” Please short press the “Learning button” within the countdown if you want to learn the next tag, if not, short press the “Function button” before the countdown ends, or do not press any button to wait for the ending of the countdown.
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 consistent with the sequence of the tag imported. This is to say, the ID will be marked as “tag: ID1”, “tag: ID2”, “tag: ID3”, and so forth. And the frame colors for different tags are different.
③ Tag Recognition
When HuskyLens encounters the tags that have been learned, 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 codes.
Project Practice
How will the tag recognition of HuskyLens be used in this project? How does Maqueen Plus select a path to go? Let’s break down the whole project into several small tasks and complete it step by step!
Task 1: Complete Basic Line-tracking Algorithms
1. Program Design
Step 1 Function Analysis
As an auto-driving truck, Maqueen Plus will identify the tag on the goods by using HuskyLens Tag recognition, select the corresponding path based on the recognized result, and then transfer the goods to the designated position.
The point-fixed transportation can be directly realized by the line-tracking sensors on Maqueen Plus itself.
The 6 line-tracking sensors should be calibrated before use.
Step 2 Flowchart Analysis
First of all, complete the function of sensor reading and line-tracking:
2. Sample Program
There are two functions encapsulated in the basic line-tracking algorithm: read grayscale and line tracking, as shown below:
Note: the function block is hidden due to the editing limit. The detailed functions are as follows.
Read grayscale function:
Line tracking function:
3. Effect Display
Turn on Maqueen Plus’s power switch, put it on the map, then it will drive along the black line.
Task 2: Determine Direction at the Road Junction
1. Program Design
Step 1 Function Analysis
Four transportation paths(1~4) are selected for Maqueen plus, and there are junctions on each path. So at first, it is necessary to make sure which direction Maqueen Plus needs to go at the road junction in order to arrive at the designated position.
Step 2 Determine Direction
Note: The junction programs above are only for paths 1 to 4. If other paths are used, the programs need to be revised accordingly.
Step 3 Junction Judgement Flowchart
How do we know whether Maqueen Plus will pass a junction in the program? If two similar situations are detected, what should Maqueen Plus do? Seems complicated, so we must carefully design the program, otherwise, the expected results couldn’t be achieved. Here, a variable “Junction” needs to be created to record whether the Maqueen Plus has arrived at a junction. As shown below:
2. Sample Program
Junction 1
Junction 2
Junction 3
Junction 4--Turn Left
Junction 4--Turn Right
Junction 5
Junction 6
Junction 7
3. Effect Display
When Maqueen Plus arrives at a junction, the corresponding program will be executed. More detailed effects will be discussed in Task 3.
Task 3: Complete the Junction Program
1. Program Design
Step 1 Route Planning
Four paths on the line-tracking map will be used in this tutorial, as shown below:
Step 2 Flowchart Analysis
For transferring goods on routes 1 to 4, which junctions will Maqueen Plus pass?
Path 1
From the image above we can see that path 1 includes junctions 1, 2, 3 4, and 5, so the functions required should be:
Note: when Maqueen Plus passed Junction 4, it can arrive at the endpoint of Path 1 using basic line-tracking function without calling the function of junction 5.
Path 2
Maqueen Plus has to pass junctions 1, 2, 3, 4, and 5 on Path 2. As shown below:
Path 3
Path 3 contains junctions 1, 2, 3 and 4.
Note: on Path 3, after Maqueen Plus passed junction 1, it can directly arrive at the endpoint of Path 3 using the basic line-tracking. So only the function junction-1 needs to be called here.
Path 4
For Path 4, Maqueen Plus will pass the junctions 1, 2, 3, 4, and 7. Seen as below:
2. Sample Program
3. Effect Display
Independently call the function route 1, route 2, route 3, route 4 in forever. Maqueen Plus will drive along the route 1/2/3/4.
Task 4: Select Route According to the Recognized Tag
1. Program Design
Step 1 Function Analysis
The basic fixed-point transportation can be realized after completing task 3. If we want Maqueen Plus to transfer 4 kinds of goods to 4 positions, how to design the program?
To make sure each kind of goods can be accurately placed at the designated position, we need to attach 4 different tags on the four goods. Maqueen Plus will select the corresponding route according to the tag ID the HuskyLens recognized. For instance, if the tag ID1 is recognized, Maqueen Plus will drive along path 1, and so forth.
Step 2 Flowchart Analysis
When the HuskyLens sensor recognized the tag ID1, then Maqueen Plus will drive along path 1 to arrive at its endpoint, and so on.
2. Sample Program
Based on the program of Task3, add the tag recognition function, and then add the function “route 1”, “route 2”, “route 3” and “route 4”. Of course, you can select different routes for Maqueen Plus when programming. The codes below are only for route 1 to 4.
3. Effect Display
Let the HuskyLens sensor learn these tags under the tag recognition mode. When the program starts, put Maqueen Plus in the starting position(calibration area). If the HuskyLens sensor recognized the Tag ID 1, Maqueen Plus will drive along route 1, and so forth.
Project Development
This project presents the basic working principle of object recognition and the usage of HuskyLens tag recognition. Combining with the line-tracking function, Maqueen Plus can automatically select a route and transfer goods. But it would be more awesome if Maqueen Plus can complete the whole goods loading and unload by itself, right? Put on the mechanic accessories on Maqueen Plus to make a more intelligent self-driving truck!