We soon realized that creating an algorithm powerful enough to perform efficient shape recognition and calculate optimal route would require much more time than the one we had allotted for the project. The problem we had initially sought out to solve resembled the Traveling Salesman problem. A problem that is over 150 years old that involves combinatorial optimization and has not yet been solved. To work around this issue, we decided to try a different approach. The image processing algorithm would convert the input image into a shade intensity matrix. Intensities were mapped to a discrete values of shading or cross-hatching. The intensity matrix would later be converted into a set of PWM (Pulse-Width Modulation) commands that would later be streamed from the computer to the Luminary board using a client/server TCP/IP socket connection.
All the programming on both, the computer and the ARM micro-controller side was done using LabVIEW. LabVIEW made the implementation of the more difficult aspects of the project really simple. This is mostly due to the fact there are already a lot of built-in libraries for everything. For example:
- The code that creates the shade intensity matrix, the NI Vision module was very useful when dealing with images. Using NI Vision, we were able to iterate through an image to create a ROI and to take intensity values of an sub-image quite easily. We also used NI Vision to create the preview path of the Etch-A-Sketch.
- The TCP protocol library allowed us to communicate between the board and the PC. We initially tried using network variables, unfortunatelly that path had to be discarded due to its unreliability in establishing a stable connection over TCP/IP.
Through the use of two modified servo motors and two optical quadrature encoders we were able to reproduce the input image (i.e. the Cal logo as seen on screen). The servos were modified to allow a full 360 degree turn by sacrificing the built-in closed loop feedback functionality. This functionality was partially recovered by connecting two optical encoders directly to the output shaft of the servos.