Design of LEGO Parts Automatic Sorting Scheme

： With the continuous development of the economy and the growing differentiation of young people's interests, people are willing to spend a lot of energy and money on their favorite games to get a better experience. Nowadays, Lego has entered more and more families. However, due to too many types and quantities of Lego parts, people usually do not know how to effectively organize these parts after each game. Most people choose to throw all these parts into the box, but this will make the parts very confused and seriously affect the game experience when playing next time. To solve this problem, we try to design and develop a Lego classification device to automatically classify different types of Lego parts. We try to use a variety of technical solutions for comparison, from multiple dimensions such as cost calculation, technical implementation details and risk management to comprehensively compare, and finally select the best design scheme.


Brief Project Description
We need to design and develop a LEGO sorting device to automatically sort different types of LEGO parts that are mixed. This device should satisfy the following requirements.
 Automation: It sorts different types of LEGO parts and places them in the corresponding storage box.  Small Size: The footprint should not be too large, which is determined by its use scenario (homes and schools).  Reasonable Price: It is cheap enough to be affordable for the average family and school.  Safety: It is safe to protect users (especially children).

Original Design
The robotic arm is used in conjunction with a conveyor belt that is used to break up and flatten the LEGO blocks. The robot arm identifies the shape and color of the LEGO parts at the end of the conveyor belt and then sorts them into their corresponding storage boxes.  Strength: High efficiency and fast sorting.  Weakness a) Conveyor belts are too large in footprint, thus unsuitable as home or school devices.
b) The conveyor belt is prone to safety accidents (e.g. jammed belts). c) The device consumes a lot of power due to the conveyor belt.
d) The cost of the conveyor belt is close to RMB 1,000 [1], leading high price.
 Analysis This design scheme does not satisfy the requirements, as its high price and it is inappropriate for use in the home or school due to floor space and safety concerns.

Current Design
A movable device is assembled on the bottom of the robotic arm and a camera is used to patrol the line to avoid obstacles as well as to determine the general location of the LEGO blocks. The Raspberry Pi with another camera is used to identify the type of LEGO parts. The robotic arm is then controlled by the Raspberry Pi to enable the grasping and sorting of the LEGO parts.
 Strength a) The device has a small footprint suitable for home or school use.
b) It is safe with no devices that can easily harm people.
 Weakness a) It is costly due to the Raspberry Pi and 2 identification cameras.
b) It is slow to sort since it identifies the LEGO parts one by one.
 Analysis On balance, although the Raspberry Pi and 2 cameras lead to a higher cost, we will select cameras with high resolution and not too expensive to minimize the cost of this device. Rather than price, we should emphasize its safety and footprint. Therefore, we chose this design scheme.

Hardware
We have chosen the Raspberry Pi to identify different colored and shaped LEGO parts. After we provide the neural network with an image of a 3D model of a LEGO block, the Raspberry Pi uses a convolutional neural network to scan and identify the LEGO parts [2].
Owing to the 3D model image of the LEGO blocks, the device can recognize all types of LEGO parts, including different colors and shapes. Therefore, the device is not only able to fulfill the project requirements in completing the type of sorting, but also to accurately identify exactly which part it is, and also its size and color.  [4] ① Small object recognition ② Recognition of objects in close proximity to one another [5] Cumbersome program setup steps Based on Table 1, we found it hard to achieve accurate recognition of small objects with YOLO3 alone. Whereas LEGO parts are small. We consequently decided to use a combination of YOLO3 and OpenCV, which also enhances the speed and accuracy of object recognition.

Model Training[6]
First, collect samples. We purchased a range of common LEGO parts from the official LEGO website and took photos of the samples. We also do pre-process to suit the actual situation, as the accuracy may change depending on the different scenarios. We then create a directory, generate a sample description file, and start training samples. Based on Table 2. In terms of price, the wheels are cheaper; in terms of functionality, the device is generally moved on flat ground, so tracks are not necessary. The wheels are more cost-effective, which leads to a choice of them. Based on Table 3,the LEGO parts are small in size as target objects, and they are generally laid flat on the floor and picked up by the robotic arm. It can be inferred that we require a high level of movement of the robotic arm. Thus, six-degree-of-freedom is more in line with our requirements with a much better price-performance ratio. Based on Table 4. Taking into account the accuracy of real-time object recognition, the high pixel count of the camera is critical. The device must be as cheap as possible, which indicates Logitech C270 is the optimum choice. Based on Table 5. For security reasons, some peripherals require to be attached to the outside of the device. Because acrylic itself can be dangerous with its sharp edges, we chose sponges as peripheral equipment. Table 6 presents the cost price of the remaining hardware.

Summary
Considering the consumption of some hardware during the project, some parts will be purchased in excess. Based on all the above cost analyses, all hardware purchase costs can be derived as shown in Table 7. The project engineers are members of a trio within our group . Based on Table 8，,the project was expected to cost 100,000 RMB to develop and we spent a total of 8598 + 90,000 = 9,8598 RMB, which was in line with the project requirements. For a cheaper selling price, we minimized the budget for hardware costs and spent more on R&D, hiring professional engineers at a high salary.

PROJECT RISK MANAGEMENT
The risks involved in this project are divided into 4 sections: technical, external, organizational and project management. Each person thinks about the possible risks and then discusses with others the corresponding solutions.
We place possible risks and their solutions in Risk Register. Before performing each task, we should check it for risk response methods. Further details can be found in Table 9.
We have also listed probability rating, impact rating and exposure rating in Risk Register, with exposure rating implying which risks should be prioritized. We have found that risks are difficult to avoid completely, but can be reduced as much as possible.

CONCLUSIONS
Finally we preliminarily designed an automatic sorting scheme for Lego parts. This scheme can basically meet the needs of most people, and has the advantages of convenient operation, low price, long service life, easy storage, etc. At the same time, this scheme also has certain commercial value. I believe that this equipment can be used in large-scale practical production in the future to free Lego players' hands. Besides, our scheme also has some problems and risk points, which is also something we need to improve in the next stage.