Motor control double-arm rubiks cube robot method based on robot vision recognition algorithm

By optimizing motor control and color recognition algorithms, and combining visual recognition and K-means clustering, the problem of precise control of the Rubik's Cube robot under uneven lighting and viewing angle conditions was solved, achieving efficient and reliable Rubik's Cube solving operation.

CN120680527BActive Publication Date: 2026-05-22HARBIN INSTITUTE OF TECHNOLOGY (SHENZHEN) (INSTITUTE OF SCIENCE AND TECHNOLOGY INNOVATION HARBIN INSTITUTE OF TECHNOLOGY SHENZHEN)
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HARBIN INSTITUTE OF TECHNOLOGY (SHENZHEN) (INSTITUTE OF SCIENCE AND TECHNOLOGY INNOVATION HARBIN INSTITUTE OF TECHNOLOGY SHENZHEN)
Filing Date
2025-08-04
Publication Date
2026-05-22

AI Technical Summary

Technical Problem

In existing technologies, Rubik's Cube robots lack precision in motor control and color recognition. Especially under conditions of uneven lighting and incomplete viewing angle coverage, it is difficult to achieve smooth and precise motor control and accurate color recognition, which affects the continuity of Rubik's Cube solving operations.

Method used

A motor control method based on robot vision recognition algorithm is adopted. By optimizing PWM parameters and camera layout, and combining Kmeans clustering algorithm, a PWM output adapted to STM32 and closed-loop stepper driver microstepping adjustment are generated. The color recognition process is optimized to achieve precise motor control and efficient color recognition.

Benefits of technology

It achieves high-accuracy Rubik's Cube color recognition and smooth motor control under different lighting conditions, improving the continuity of Rubik's Cube solving operations and the reliability of recognition, reaching a recognition accuracy of almost 100%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120680527B_ABST
    Figure CN120680527B_ABST
Patent Text Reader

Abstract

The application discloses a motor control double-arm Rubik's cube robot method based on a robot vision recognition algorithm and belongs to the technical field of motor control double-arm Rubik's cube robot methods. In matlab, the starting and ending speed, the maximum speed, the total time, the uniform speed time, the subdivision number of a stepping motor, the subdivision interval, the rotation angle parameter, the specified control curve T type and the S type are defined according to the subdivision number and the rotation angle. The total pulse number is calculated, the total pulse is distributed to the acceleration, uniform speed and deceleration stages, the specified control curve T type and the S type are defined according to the subdivision number and the rotation angle, the total pulse number is calculated, the total pulse is distributed to the uniform speed, acceleration and deceleration stages, the acceleration stage is divided into two sections, namely, the S type, the jerk acceleration is calculated, the speed change is calculated through integration, and the acceleration stage pulse cycle is generated. When the acceleration stage is the uniform acceleration stage, namely, the T type, the acceleration is calculated, the speed linearly grows in each pulse cycle, and the acceleration stage pulse cycle is generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for controlling a dual-arm Rubik's Cube robot with a motor, and more particularly to a method for controlling a dual-arm Rubik's Cube robot with a motor based on a robot vision recognition algorithm, belonging to the technical field of methods for controlling a dual-arm Rubik's Cube robot with a motor. Background Technology

[0002] Ideal stepper motor control requires precise planning of acceleration and deceleration processes, with S-curves and T-curves being common strategies. The S-curve subdivides the acceleration segment into acceleration-deceleration and deceleration phases, allowing for smoother speed changes by controlling the jerk. The T-curve employs uniform acceleration, ensuring linear speed growth per pulse cycle. However, current technologies still require further research to determine how to rationally generate the corresponding pulse sequence based on the cube's rotation requirements (e.g., angle, time), adapting it to the PWM output of controllers like STM32 and the microstepping adjustment of the closed-loop stepper driver to achieve smooth and precise motor control. For example, the lack of a mature, integrated adaptation solution for setting microstepping (400-40000 steps / revolution range) and adjusting PWM parameters (timer mode, clock frequency, auto-reload register value configuration) leads to inaccurate motor speed control, affecting the continuity of cube solving.

[0003] Solving a Rubik's Cube relies on accurate image acquisition and color recognition to obtain the state of each face. Existing visual acquisition solutions suffer from uneven lighting and incomplete viewpoint coverage. Ordinary light sources can easily cause reflections or shadows, interfering with color recognition; unreasonable camera placement makes it difficult to comprehensively and clearly capture images of all six faces of the Rubik's Cube, affecting subsequent algorithm analysis. Regarding color recognition algorithms, the Rubik's Cube has diverse colors and is easily affected by lighting, making it difficult to accurately distinguish white, red, orange, and other colors. Traditional color recognition relies solely on fixed HSV ranges, which are easily affected by ambient light. For example, red and orange partially overlap in their H value ranges, making it inaccurate to distinguish them using only a single threshold; white recognition, if solely relying on fixed S and V values, is prone to misjudgment under different lighting conditions. Although algorithms such as K-means clustering are used for color classification, existing technologies have not fully addressed how to optimize the initial category selection and iteration process to improve recognition efficiency and accuracy for the specific scenario of the Rubik's Cube (where only a limited number of color categories need to be distinguished, and the samples are the central color blocks). This leads to color recognition errors, ultimately preventing the Rubik's Cube solving algorithm from executing correctly. Summary of the Invention

[0004] The main objective of this invention is to provide a method for controlling a dual-arm Rubik's Cube robot with motors based on a robot vision recognition algorithm.

[0005] The objective of this invention can be achieved by adopting the following technical solution:

[0006] A method for motor-controlled dual-arm Rubik's Cube robot based on robot vision recognition algorithm includes the following steps:

[0007] Step 1: Define the start and end speeds, maximum speed, total time, constant speed time, stepper motor microstepping number, microstepping interval, and rotation angle parameters for single-step control in MATLAB.

[0008] Step 2: Specify the control curves T-shaped and S-shaped. Calculate the total number of pulses based on the subdivision number and rotation angle, and distribute the total pulses to the acceleration, constant speed, and deceleration stages.

[0009] Step 3: When the acceleration phase is divided into two segments, namely acceleration and deceleration (i.e., S-shaped), calculate the jerk, calculate the velocity change through integration, and generate the period of the acceleration phase pulse.

[0010] When the acceleration phase is a uniform acceleration phase, i.e., a T-shaped acceleration, the acceleration is calculated. The velocity increases linearly within each pulse cycle, generating the acceleration phase pulse cycle.

[0011] Step 4: In steps 3 and 4, maintain the maximum speed during the constant speed phase to generate a fixed pulse sequence. During the deceleration phase, symmetrically replicate the reverse process of the acceleration phase, with the pulse period being the reverse of the pulse period of the acceleration phase.

[0012] Step 5: Combine pulse periods, plot time and rotation speed curves, convert pulse frequency into PSC value representation based on system clock and ARR value, and export as text data.

[0013] Preferably, in step one, the stepper motor's microstepping level, microstepping interval, and rotation angle parameters specifically include adjusting the microstepping of the closed-loop stepper driver;

[0014] The HBS57 driver uses a six-bit DIP switch to set the microstepping frequency, adjustable within the range of 400-40000. The relationship between pulse frequency and microstepping frequency is as follows:

[0015] .

[0016] Preferably, the PWM parameters of the STM32 are adjusted, wherein the STM32F407VET is set to PWM output mode for timer TIM2, and the clock frequency of TIM2 and the value of the auto-reload register ARR are adjusted.

[0017] The output PWM pulse frequency is:

[0018] .

[0019] Preferably, the stepper motor drive pulse curve is generated in step four;

[0020] Using an S-curve, the starting and ending speeds of the control are first defined. Maximum speed Total time Uniform time The subdivisions include the step interval and the degree of rotation.

[0021] Preferably, the total number of pulses required, the number of pulses required for the constant speed segment, and the number of pulses required for the acceleration / deceleration segment are calculated, and then the rotational speed corresponding to each pulse is calculated.

[0022] The total acceleration time during the acceleration phase Divided into acceleration and deceleration Two sections;

[0023] Assuming acceleration during the acceleration phase During the acceleration phase Linear increase, during the deceleration phase Linear reduction, forming a symmetrical triangle. ;

[0024] The maximum acceleration is The area enclosed by acceleration *a* and time *t* in the first quadrant is the change in velocity. ,Depend on The maximum acceleration can be solved. Then the jerk can be calculated. Then calculate the cycle pulse by pulse and update the current speed. Each time the rotation speed is updated , bring in Obtain the current pulse period.

[0025] Preferably, in step six, the periods of acceleration, constant speed, and deceleration are combined into a complete velocity curve, based on the frequency of each pulse. Substitute into the formula Calculate the prescaler PSC value, generate a prescaler PSC array for embedded systems, record once every step pulse, and export as text data.

[0026] Beneficial technical effects of the present invention:

[0027] The present invention provides a method for motor-controlled dual-arm Rubik's Cube robot based on robot vision recognition algorithm. The recognition point is a fixed point found by preset parameters, and then the color is extracted. Therefore, as long as the mechanical structure does not change or shift, the recognition position is relatively reliable.

[0028] For color recognition, the most likely problems are with white and red-orange. If there is too much light in the environment, such as shining a strong flashlight directly on a surface, causing partial reflection, it may affect the S and V values ​​of the color block, which will directly affect the recognition of white and indirectly affect the recognition of red-orange.

[0029] After adjusting the camera parameters and turning off white balance, the problem was largely resolved. It now has a strong ability to adapt to the environment, and except for special conditions such as direct sunlight, the reliability and accuracy of recognition are high, achieving a recognition accuracy of almost 100%.

[0030] For the recognition of other colors, since the H value will have certain deviations in different environments, the K-means clustering algorithm was used. The H value of the central block excluding white, red and orange was used as the initial cluster center, which can reduce the number of iterations and effectively improve the accuracy. The recognition of other colors based on the K-means clustering algorithm has good robustness and reliability. Attached Figure Description

[0031] Figure 1 This is a flowchart of an algorithm of a preferred embodiment of the motor-controlled dual-arm Rubik's Cube robot method based on robot vision recognition algorithm according to the present invention;

[0032] Figure 2 The image above shows a continuous curve graph, and the image below shows a scatter plot of the rotational speed corresponding to each pulse, representing a preferred embodiment of the method for controlling a dual-arm Rubik's Cube robot based on a robot vision recognition algorithm according to the present invention.

[0033] Figure 3 This is a diagram showing the STM32 parameter settings for the stepper motor in a preferred embodiment of the method for controlling a dual-arm Rubik's Cube robot based on a robot vision recognition algorithm according to the present invention.

[0034] Figure 4 This is a visual illumination strategy and camera layout diagram of a preferred embodiment of the motor-controlled dual-arm Rubik's Cube robot method based on robot vision recognition algorithm according to the present invention;

[0035] Figure 5 This is a visual image showing the HSV values ​​of color blocks in a preferred embodiment of the motor-controlled dual-arm Rubik's Cube robot method based on a robot vision recognition algorithm according to the present invention. Detailed Implementation

[0036] To enable those skilled in the art to understand the technical solution of the present invention more clearly, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings, but the embodiments of the present invention are not limited thereto.

[0037] The entire motion process of a stepper motor includes three stages: acceleration, constant speed, and deceleration.

[0038] Traditional T-type and S-type control of stepper motors only determine the total travel time, not the rotation angle.

[0039] The control algorithm of this invention can obtain the corresponding PWM pulse frequency sequence through S-shaped or T-shaped curves given a rotation angle and rotation time.

[0040] The specific steps are as follows:

[0041] Step 1: Adjust the microstepping of the closed-loop stepper driver. In this example, the HBS57 driver uses a six-bit DIP switch to set the microstepping, which can be adjusted within the range of 400-40000 (steps / revolution). The relationship between pulse frequency and microstepping is as follows: ;

[0042] Step 2: Adjust the STM32's PWM parameters. In this example, the STM32F407VET is configured with timer TIM2 set to PWM output mode, and the TIM2 clock frequency and the value of the auto-reload register ARR are adjusted. The output PWM pulse frequency is... ;

[0043] Where f is the PWM pulse frequency;

[0044] clock frequency is the timer clock frequency;

[0045] ARR stands for Automatic Reload Register;

[0046] PSC stands for prescaler coefficient.

[0047] Step 3: Generating the stepper motor drive pulse curve. Taking an S-shaped curve as an example, first define the start and end speeds of the control. Maximum speed Total time Uniform time The calculation involves subdividing the interval (step) and rotation angle (degree). It calculates the total number of pulses required, the number of pulses needed for the constant speed phase, and the number of pulses needed for the acceleration / deceleration phases, then calculates the rotational speed corresponding to each pulse. Taking the acceleration phase as an example, the total acceleration time... Divided into acceleration and deceleration Two segments. Assume the acceleration during the acceleration phase... During the acceleration phase Linear increase, during the deceleration phase Linear reduction, forming a symmetrical triangle ( The maximum acceleration is The area enclosed by acceleration *a* and time *t* in the first quadrant is the change in velocity. ,Depend on The maximum acceleration can be solved. Then the jerk can be calculated. Then calculate the cycle pulse by pulse and update the current speed. Each time the rotation speed is updated , bring in Obtain the current pulse period.

[0048] Finally, the periods of acceleration, constant speed, and deceleration are combined into a complete speed curve, based on the frequency of each pulse. Substitute into the formula Calculate the prescaler PSC value, generate a prescaler PSC array for embedded systems, record once every step pulse, and export as text data;

[0049] Step 4: Add the prescaler PSC array exported in Step 3 to the STM32 control program. After each step pulse, update the prescaler PSC value of the current STM32 PWM corresponding clock, thereby controlling the current pulse frequency and motor speed.

[0050] The camera is a USB wide-angle, distortion-free 720P industrial camera, which is placed in the front, back, top, and bottom positions of the robot device and fixed with the robot's central aluminum frame.

[0051] The U and R faces of the Rubik's Cube can be observed from above; the D and L faces can be observed from below.

[0052] The F-side and B-side can be observed from the front and back respectively. The camera is connected to a host computer via USB for image transmission.

[0053] When supplementing the robot with lighting, a combination of soft light and industrial vision light source is used.

[0054] LED ring lights are placed in front of and behind the robot, with a camera embedded in the center of the light source. The upper industrial vision light source uses a 120mm diameter CCD machine vision lighting ring light source with a refraction angle of 0 degrees, while the lower one uses a 120mm diameter CCD machine vision lighting ring light source with a refraction angle of 90 degrees.

[0055] According to the previous implementation method, 54 HSV values ​​will be obtained.

[0056] White recognition: First, compare the S values ​​of 54 HSV values, select the 9 points with the smallest S values, and identify them as white.

[0057] Red-orange identification: Next, we identify red-orange colors. The H value for red-orange colors is between 150-180 and 0-20.

[0058] Therefore, we first perform interval judgment on the H value to obtain the sets of red and orange. Then, we judge the S and V values ​​of these points to distinguish between red and orange.

[0059] To distinguish between red and orange, an adjustable threshold judgment method is used. First, the V value is used for judgment: a V value less than 160 is judged as red, and a V value greater than 217 is judged as orange. When the V value is between 160 and 217, the S value is used for judgment: an S value greater than 145 is judged as red, and an S value less than 145 is judged as orange.

[0060] K-means clustering for other colors: Based on the identification of white, red, and orange, the H values ​​of other colors are clustered to obtain three color categories.

[0061] Specific implementation of the K-means algorithm:

[0062] (1) Select three samples of the center color blocks of the Rubik's Cube that exclude white, red and orange as the initial three class means;

[0063] (2) Divide each sample dataset into its nearest class;

[0064] (3) Update the mean vector of each category according to the category to which each sample belongs;

[0065] (4) Repeat steps (2) and (3). When the set number of iterations or the mean of the categories no longer changes, the model construction is complete, and the clustering algorithm results are output.

[0066] The above description is merely a further embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope disclosed in the present invention, based on the technical solution and concept of the present invention, shall fall within the scope of protection of the present invention.

Claims

1. A method for motor-controlled dual-arm Rubik's Cube robot based on robot vision recognition algorithm, including placing a camera at the front, back, top, and bottom positions of the robot device, observing the U and R faces of the Rubik's Cube from above; and observing the D and L faces of the Rubik's Cube from below; The front and rear sides are observed to be the F and B sides respectively. The camera is connected to a host computer via USB for image data transmission. Its features include: Includes the following steps: Step 1: Define the start and end speeds, maximum speed, total time, constant speed time, stepper motor microstepping number, microstepping interval, and rotation angle parameters for single-step control in MATLAB. Step 2: Specify the control curves T-shaped and S-shaped. Calculate the total number of pulses based on the subdivision number and rotation angle, and distribute the total pulses to the acceleration, constant speed, and deceleration stages. Step 3: When the acceleration phase is divided into two segments, namely acceleration and deceleration (i.e., S-shaped), calculate the jerk, calculate the velocity change through integration, and generate the period of the acceleration phase pulse. When the acceleration phase is a uniform acceleration phase, i.e., a T-shaped acceleration, the acceleration is calculated. The velocity increases linearly within each pulse cycle, generating the acceleration phase pulse cycle. Step 4: Maintain maximum speed during the constant speed phase to generate a fixed pulse sequence. During the deceleration phase, symmetrically replicate the reverse process of the acceleration phase, with the pulse period being the reverse of the acceleration phase pulse period. Step 5: Combine pulse periods, plot time and rotation speed curves, convert pulse frequency into PSC value representation based on system clock and ARR value, and export as text data; In step one, the stepper motor's microstepping level, microstepping interval, and rotation angle parameters specifically include adjusting the microstepping of the closed-loop stepper driver; The HBS57 driver uses a six-bit DIP switch to set the microstepping frequency, adjustable within the range of 400-40000. The relationship between pulse frequency and microstepping frequency is as follows: ; Adjust the PWM parameters of the STM32. Specifically, set the STM32F407VET timer TIM2 to PWM output mode and adjust the TIM2 clock frequency and the value of the auto-reload register ARR. The output PWM pulse frequency is: ; In step four, the stepper motor drive pulse curve is generated; Using an S-curve, the starting and ending speeds of the control are first defined. Maximum speed Total time Uniform time The subdivisions include the step interval and the degree of rotation.

2. The method for motor-controlled dual-arm Rubik's Cube robot based on robot vision recognition algorithm according to claim 1, characterized in that: Calculate the total number of pulses required, the number of pulses required for the constant speed segment, and the number of pulses required for the acceleration / deceleration segment, and then calculate the rotational speed corresponding to each pulse. The total acceleration time during the acceleration phase Divided into acceleration and deceleration Two sections; Assuming acceleration during the acceleration phase During the acceleration phase Linear increase, during the deceleration phase Linear reduction, forming a symmetrical triangle. ; The maximum acceleration is The area enclosed by acceleration *a* and time *t* in the first quadrant is the change in velocity. ,Depend on The maximum acceleration can be solved. Then the jerk can be calculated. Then calculate the cycle pulse by pulse and update the current speed. Each time the rotation speed is updated , bring in Obtain the current pulse period.

3. The method for motor-controlled dual-arm Rubik's Cube robot based on robot vision recognition algorithm according to claim 1, characterized in that: It also includes step six, in which the periods of acceleration, constant speed, and deceleration are combined into a complete velocity curve, based on the frequency of each pulse. Substitute into the formula Calculate the prescaler PSC value, generate a prescaler PSC array for embedded systems, record once every step pulse, and export as text data.