tag:www.mathworks.com,2005:/matlabcentral/fileexchange/feedMATLAB Central File Exchangeicon.pnglogo.pngMATLAB Central - File Exchange - type:Video product:"Image Processing Toolbox" type:ExampleUser-contributed code library2015-03-04T11:13:17-05:0031100tag:www.mathworks.com,2005:FileInfo/494342015-02-11T20:13:13Z2015-02-11T20:13:13ZRubik's Cube® Solver using an Arduino and MATLABSolve Rubik’s Cube® using image processing and Arduino-controlled servo motors<p>In this entry, we build a robot that solves a Rubik’s Cube® using MATLAB, a SparkFun RedBoard (Arduino Uno clone), two servo motors, and a webcam. The submission contains all of the code used to control the robot, a detailed article describing how the robot was built and programmed, and several videos of the final result. Download this submission if you’re interested in learning about our project. Or use it as a starting point for building and controlling your own Rubik’s Cube solving robot.
<br />In addition to hardware components, this project requires MATLAB and Image Processing Toolbox. It also uses MATLAB Support Package for Arduino® Hardware, which can be downloaded for free here: <a href="http://www.mathworks.com/matlabcentral/fileexchange/47522-matlab-support-package-for-arduino%C2%AE-hardware">http://www.mathworks.com/matlabcentral/fileexchange/47522-matlab-support-package-for-arduino%C2%AE-hardware</a>
<br />The initial setup of the project involved building the robot from readily available materials. In addition to the Arduino device, webcam, and servos, we used LEGO bricks, an acrylic sheet, and hard polystyrene foam. The robot was designed with two main parts. A holder holds the cube from below in an open-topped box and can rotate the cube in the horizontal plane. A gripper arm can be lowered over the cube from above to hold two layers still while the holder rotates one face from below. The gripper arm can also be pushed forward to flip the cube to a different side.
<br />With the entire robot assembled and calibrated, solving the cube involves two steps:</p>
<p>1. Read the initial state of the scrambled cube.</p>
<p>MATLAB functions were written to control the servo motors on the Arduino so they could rotate the entire cube in the holder and flip it to a different side. These functions are used to rotate the cube so each of the 6 faces are facing up and capture an image of the face with a webcam. Using Image Processing Toolbox, the color of each facelet is determined. A custom MATLAB UI is used to validate the results and correct any errors.</p>
<p>2. Solve the cube.</p>
<p>The algorithm used for solving the cube is the Thistlethwaite 45 (T45) algorithm. It was used because a MATLAB implementation of the algorithm was already available on the MATLAB Central File Exchange as part of the submission here: <a href="http://www.mathworks.com/matlabcentral/fileexchange/31672-rubik-s-cube-simulator-and-solver">http://www.mathworks.com/matlabcentral/fileexchange/31672-rubik-s-cube-simulator-and-solver</a></p>
<p>The output of the T45 algorithm determines which faces should be turned. This is then converted to a sequence of moves on the robot that could rotate the cube, flip it to a different side, and turn a single face. Once all the steps are complete, the cube is solved.</p>MathWorks MATLAB Hardware Teamhttp://www.mathworks.com/matlabcentral/profile/authors/4922363-mathworks-matlab-hardware-teamMATLAB 8.3 (R2014a)Image Processing ToolboxMATLABMATLAB Support Package for Arduino Hardwarefalsetag:www.mathworks.com,2005:FileInfo/327702011-09-02T01:41:36Z2011-10-30T18:00:57ZMuscle fascicle tracking - UltrasoundImplementation of an optical flow algorithm to track muscle length changes imaged with ultrasound.<p>This Matlab GUI demonstrates how muscle fascicles from the medial gastrocnemius (MG) muscle in humans that are imaged using B-mode ultrasound can be automatically tracked using optical flow algorithms utilising an affine transformation to track end points of muscle fascicles as determined in an initial frame.</p>
<p>Please cite the following manuscripts in any academic work which uses this algorithm -</p>
<p>1. Cronin, NJ, Carty, CP, Barrett, RS & Lichtwark G. (2011) Automatic tracking of medial gastrocnemius fascicle length during human locomotion. Journal of Applied Physiology. In Press. doi:10.1152/japplphysiol.00530.2011</p>
<p>2. Gillett, J, Barrett, R & Lichtwark, G. (2011) Reliability and accuracy of an automatic tracking algorithm to measure passive and active muscle fascicle length changes from B-mode ultrasound. Computer Methods in Biomechanics and Biomedical Engineering. In Press.</p>
<p>This toolbox requires the Image Processing toolbox.</p>
<p>This toolbox utilises Dr David Young's (Susses University) excellent algorithms for calculating the optical flow using the affine transformation
<br />extension - <a href="http://www.mathworks.com/matlabcentral/fileexchange/27093-affine-optic-flow">http://www.mathworks.com/matlabcentral/fileexchange/27093-affine-optic-flow</a></p>
<p>It also uses Sandra Martinka's Rubberband Line function -
<br /><a href="http://mathworks.com/matlabcentral/fileexchange/1552-rubberband-line">http://mathworks.com/matlabcentral/fileexchange/1552-rubberband-line</a></p>
<p>The GUI comes with an example video file and represents a passive rotation of the ankle which in turn changes the length of the MG muscle. This may require DivX codecs to be installed. Please read README.txt file for full information.</p>Glen Lichtwarkhttp://www.mathworks.com/matlabcentral/profile/authors/854171-glen-lichtwarkMATLAB 7.10 (R2010a)Image Processing ToolboxMay require DivX codecs to run the example video (www.divx.com). falsetag:www.mathworks.com,2005:FileInfo/235922009-04-08T10:16:45Z2009-04-08T10:16:45Zcontest clockjoke visualization of solitaire contest<p>Animation showing how the results versus the execution times
<br />evolved over the contest. The trajectory shows how results change hours by hours during the contest.</p>Rafal Kasztelanichttp://www.mathworks.com/matlabcentral/profile/authors/1788759-rafal-kasztelanicMATLAB 7.6 (R2008a)Image Processing Toolbox23468false