With the development of industrial automation, many large factories now start to use intelligent robots to move workpieces, assemble, and transfer goods on production line.
Think about it, can Maqueen Plus also become an intelligent robot and move the goods from point A to point B?
This project mainly uses the color recognition of HUSKYLENS and the line tracking function of Maqueen Plus. First turn on the line tracking function and let Maqueen Plus drive along the black line. After HUSKYLENS recognizes the color, turn off the line tracking function, and then locate the goods according to the recognition result. When Maqueen Plus reaches the designated location, it will use the loader to scoop up the goods, turn around and turn on the line tracking function to transport the goods to the designated unloading point. This simply realizes the function of fixed-point transportation.
Bill of Materials
1. Map Designation: Choose a position on the oval map as the unloading point (point B), then mark it with black tape (the marked area should be larger than the black calibration area), and then choose another position as the loading point (point A), and place the color identification card (there should be no other colors behind the color identification card). Place goods in front of point A.
2. Assembly Diagram: Install the Loader and HUSKYLENS to Maqueen Plus.
Bill of Materials:
Installation Steps of HUSKYLENS:
After finishing installing the loader, install HUSKYLENS to the expansion bracket on the back of Maqueen Plus.
3. Connection Diagram: Connect HUSKYLENS to the I2C interface and the servo to the S1 interface. Pay attention to the order of wiring, do not connect wrongly or reversely.
Nowadays, automated production has become a development trend. Machine vision, as the eyes of "robots", is particularly paramount.
As one of the important technical directions, color recognition has experienced multiple generations of technology upgrades. This project is based on the color recognition function of the HUSKYLENS sensor.
1. What Is Color Recognition?
What is color recognition? First, we have to learn what color is.
Color is a visual effect on light produced by our eyes, brain and our life experience. The light we see with the naked eye is produced by electromagnetic waves which are with a very narrow wavelength range. Electromagnetic waves of different wavelengths show different colors.
Color recognition is to recognize and distinguish color attributes based on different brightness.
2. Principles of Color Recognition
Color recognition is based on Lab color space, with dimension L representing brightness, a and b representing opposite dimensions of color, which is based on the CIE XYZ color space coordinates of nonlinear compression.
Compare the Lab parameters of the recognized and learned colors. When the two colors match within a certain error range, they are judged to be the same color.
In our usual use of color recognition, the hue and saturation in the color attributes of the same module are fixed, but the brightness will change due to the influence of the ambient brightness, so you must try to ensure that when using the HUSKYLENS color recognition function the environment brightness during learning and recognition is consistent with that during actual work.
3. Application Scenario of Color Recognition
Industry: Color recognition is now widely used in industries such as printing, coatings and textiles for color monitoring and calibration.
Personal Life: Help people with color weakness or visual impairment recognize and enhance their understanding of color.
4. Demonstration of Color Recognition of HUSKYLENS
The color recognition function in the HUSKYLENS sensor uses the sensor's built-in algorithm to identify the ID of different colors and feed them back to the main control board by learning and recording different colors.
The HUSKYLENS sensor is set by default to learn, recognize and track only one color, but we can set it to recognize multiple colors.
1. Choose “Color Recognition” function
Dial the “function button” to the left until the words "Color recognition" is displayed at the top of the screen.
2. Color Learning
Point the “+” symbol at the color block, and long press the “learning button”. A yellow frame will be displayed on the screen, indicating that HuskyLens is learning the color.
After finishing the study, when encountering the same or similar color blocks, a frame with an ID will be automatically displayed on the screen, and the size of the frame changes with the size of the color blocks.
When there are multiple same or similar color blocks appear at the same time, the other color blocks cannot be recognized, that is, only one color block can be recognized at each time.
Tips: Color recognition is greatly affected by ambient light. Sometimes HUSKYLENS may misidentify similar colors. Please try to keep the ambient light unchanged.
1. What Is Line Tracking
Line tracking refers to the process of objects driving along a designated route. The fully functional line tracking robot uses a mobile robot as a carrier, a visible light camera, an infrared thermal imager, and other detection instruments as the load system, and a multi-field information fusion of machine vision-electromagnetic field-GPS-GIS as the robot's autonomous movement navigation system, an embedded computer as the software and hardware development platform of the control system.
2. Principles of Line Tracking
Line tracking means that the robot judges the position deviation between the robot and the line by detecting the intensity of the light reflected (the light is reflected on the white or light-color light surface; the light is absorbed on the black surface). For example: the line tracking sensor on the right detects white, indicating that the robot has shifted to the right; the line tracking sensor on the left detects white, indicating that the robot has shifted to the left; if it does not detect white, it means that the robot is not yaw and the robot will go straight.
How is the color recognition of HUSKYLENS used in the fixed-point transportation project? How to make Maqueen Plus locate the goods based on the recognition results of HUSKYLENS? After loading the goods, how to accurately transport the goods to the unloading point (point B)? Now, we are going to finish this project step by step.
First, design the Maqueen Plus line tracking function so that Maqueen Plus will drive along the black line. Then, learn to use the color recognition function of HUSKYLENS, adjust the position of Maqueen Plus and the loader to lift goods according to the orientation of the color card; finally, combine the line tracking and the color recognition function of HUSKYLENS to realize the fixed-point transportation from point A to point B.
Note: All the missions should be completed with a fully-charged battery.
Task1: Basic Tracking
The following is a map for reference.
1. Program Design
Step1: Function Analysis
For this kind of point to point accurate transportation, we can directly use the line tracking sensors on Maqueen Plus.
For Maqueen Plus, there are 6 line tracking sensors at the bottom, which can be used to detect black lines.
When the sensor faces a white background, the sensor’s indicator is off, and the line tracking sensor detection value is 0; when the sensor faces a black line, the sensor’s indicator is on, and the line tracking sensor detection value is 1.
Step2: Instruction Learning
Step3: Line Tracking Sensor Testing
Test the program through the feedback value output by LED matrix screen.
Test Results :
If the program does not work properly, troubleshoot the following problems:
① The black printed by the printer may not be correctly recognized. The black tape and printed map from DFRobot can be used normally.
② Ambient light may affect the line-tracking sensor. When the light changes greatly, recalibrate the sensors.
Method of calibration: Maqueen Plus comes with a one-button calibration function. The calibration button is as shown in the figure below. When using it, make sure that all line tracking sensors are in the black calibration area. Press the calibration button for 1 second, the two RGB light in front of the car flashes green, indicating that the calibration is completed. Release the button to complete the calibration.
Principle of line tracking sensor: Each line tracking sensor consists of an infrared transmitter and an infrared receiver. Because it is often used to control the robot to walk along the line, it is also called the line tracking sensor. The infrared transmitter continuously emits infrared light to the ground. If the infrared light is reflected (for example, when it encounters a white or other light-color surface), the receiver will receive the infrared signal, the output value will be 0, and the sensor indicator will go out; if the infrared light is absorbed or it cannot be reflected, the receiver cannot receive the infrared signal, the output value will be 1, and the indicator light will go on.
Step4: Flowchart Analysis
First, we use L1 and R1 to track the line. Select the ellipse line tracking map. If you want to design a map by yourself, note that the width of the black line needs to be 2cm and ensure that both L1 and R1 can be on the black line.
2. Sample Program
Note: Adjust the speed according to the situation of your own car to achieve the best effect.
3. Operating Effect
When the program is run, Maqueen Plus will automatically drive along the black line.
Task2: Color Recognition
1. Program Design
Step1: Learning and Recognition
Choose a color paper card you like and let HUSKTLENS learn it. Stick the card on a white background plate (to avoid other color interference when recognizing).
Step2: Instruction Learning
Step3: Function Analysis
After task 1 is completed, Maqueen Plus is able to drive along the black lines. Next, we will use the color recognition function to locate the position of the goods. When Maqueen Plus recognizes the color ID1, it will turn off the line tracking function, and adjust the location of Maqueen Plus by judging the position and distance to the color card. When Maqueen Plus arrives within the specified range, the loader will start to work. The program flow chart is as follows:
Note: Because the angle of installation may be different for each person, we need to find 0 degrees in advance, and then initialize the servo angle according to the situation.
3. Sample Program
4. Operating Effect
The Maqueen Plus initially drives along the black line. After HUSKYLENS recognizes the color of the card, it will use the recognition result to adjust the distance. When the identified X center and frame height do not meet the conditions (when Maqueen Plus is very close to the color paper), the loader will work.
Task3: Set up the scene and improve the program
1. Program Design
Step1: Function Analysis
After completing task two, the Maqueen Plus is able to locate the goods through the results of color recognition. Then we need to transport the picked goods to point B along the black track. After reaching point B, the car turns around and drives along the black track to point A to load goods. Just like this, it will go back and forth between A and B.
For the car to accurately find point B, we need to use black tape to stick a piece of unloading point that is the same size as the calibration area at point B (mainly covering the L3 and R3 sensor probes).
Use the L3 and R3 line tracking sensors on the Maqueen Plus to recognize the unloading point (point B). After reaching point B, unload the cargo.
Step2: Point B Judgment Program
Create a new function to discharge cargo. When the L3 and R3 line tracking sensors detect black, the Maqueen Plus stops. After putting down the cargo, it moves back and turns around.
Note: Pay attention to the pause time when debugging the program.
Step3 Flowchart Analysis
We can build the scene according to the following figure. The path from point A to point B is: if the vehicle starts from point B (L3, R3 cannot detect black), it will drive along the black track, and when HUSKYLENS recognizes the color, it will turn off the line tracking function. The distance between Maqueen Plus and the color card is controlled by the result of HUSKYLENS recognition. When Maqueen Plus reaches the designated position, it picks up the goods and turns around and drives along the black track. After reaching point B, it will unload the cargo, then turn around and repeat the previous steps.
The program flowchart is as follows:
2. Sample Program
3. Operating Effect
Maqueen Plus starts from point B (L3 and R3 cannot detect black line when starting), drives along the black line, installs the foam block at point A, turns around and drives back along the black line, unloads the foam block after reaching point B, and then turns around and continues moving along the black line to point A to carries the foam block. It will keep going back and forth between points A and B in this way.
In the project, a green card (ID1) is used to indicate that there are goods at point A. Every time HUSKYLENS recognizes the color of ID1, it will go to point A to transport the goods. If all the goods are transported, how should we let Maqueen Plus stop?
For example: when HUSKYLENS recognizes the color of ID1 (green) and Maqueen Plus goes to point A to transport the goods. When the goods are shipped, replace the card with a red one, and when HUSKYLENS recognizes the color of ID2 (red), tell Maqueen Plus that the goods are all shipped, and it will stop working.
Can you follow the instructions to complete this program?