In 2017, Zeguang Chang and I built a cube robot using DSP and STM32. We open source all the code of CubeRobot in this repository.
You can find the complete restore process on BiliBili.
- In terms of hardware, we adopt a four-axis structure, with four mechanical arms to complete the blessing and rotation of the cube.
- In terms of software, the robot consists of two subsystems: sensing system and control system.
We use both DSP development board (TMS320C6748) and STM32 development board (STM32F407ZGT6 ARM). The DSP system is equipped with an ov5640 camera, which can complete the color recognition task, while the STM32 system controls 4 steering gears and 4 stepping motors to complete all actions of cube restoration.
In the CubeRobot_DSP
directory, we release all code of the sensing system. The src/main_camera.c
contains the main function, and the inc/
contains all subfunctions and head files.
- Note that the
inc/color.c
is the most important file because it performs the Color Recognition Task and Cube Solving Task. - The
src/main_camera.c
performs communication with STM32 and basic logic of trigger the solving action.
As we developed this project in CCS5.5 IDE environment, we have also provide the original CCS project files in others/CubeRobot_CCS-5.5_Project.zip
.
Note that the solving algorithm of the Rubik's Cube is borrowed from Thistlethwaite's 52-move algorithm. We thank Jaap Scherphuis for his wonderful realization. Please refer to others/Thistlethwaite's algorithm.cpp
for the original C++ code.
In the CubeRobot_STM32
directory, we release all code of the control system. These code aims to control the coordination of 4 stepping motors and 4 steering gears. The steering gear controls the forward and backward movement of the mechanical arm, and the stepping motor controls the rotation angle.
This project was completed by me and Zeguang Chang. Thank him for working side by side all the time. I feel very lucky for joining the Linear Motor Laboratory led by Jiwen Zhao during my undergraduate period in Anhui University, where I spent unforgettable and perfect four years.