Project: Motion Tracking Cat Toy
"Lazyer"
Un-mounted


Proof of concept mounting


Video of it in action

https://www.youtube.com/watch?v=JBTybxgcBr4


Complete parts list:
Arduino Uno - $30
MK802 Mini Android-based PC Hacked and running Gentoo linux to handle image processing - $45
2x 28BYJ-48 stepper with uln2003a controller  - $7
12v power brick to power steppers - Salvaged
Jumper wires - $5
5v Axiz Laser module - $10
Playstation Eye - $20
USB Hub - $20
Misc parts for mounting bracket - $25



It took 2 prototypes to settle on a design.
The original design was going to have the laser coordinates be based on a polar system, since this was to be mounted from the center of the ceiling. This made sense in my head, but in practice with the prototype it was very slow to respond any time the laser was near the center of the plane because many times nearly 90 degrees of rotation was required to get the laser to where it needed to be. I also had problems with wires getting tangled and had to implement a counter so that it would not rotate to the point of winding itself up.....
It was at that point that I decided I would scrap the design and start fresh with a standard Cartesian design that would solve all my problems.

I heavily modified the stepper library from sbright33 to suit my needs. This involved psudo-threading the library so that moth motors could move independently from each other at the same time (technically not the same time, but alternating every few hundred microseconds) as well as creating my own custom coordinate system for it to follow.


At first I also was planning to use wireless USB to transmit the webcam feed from the ceiling down to my main computer which would do motion analyzing and send back the coordinates that movement was detected at. I found an industrial-grade wireless hub, but regardless of what their claims said and after a week of trying different webcams out, it did not have the bandwidth support for HD webcam streams.
After some research, I settled on the MK802 Android MiniPC because of it's hack potential - planning to use it with linux to broadcast the webcam stream over my network to accomplish what the usb hub should have done.

Once I started playing with it, I realized that it had enough power to preform the image processing on its own - significantly slower (about 4fps instead of 60) but still quick enough to provide updates to the arduino faster than the motors could move.

The MK802 uses OpenCV and Python to handle the image processing, and communicates with the arduino over a serial port (the USB hub comes in here to support the webcam and the serial communication from one usb port). It sends the coordinates that the laser should point at, as well as a randomly chosen speed that it should travel on its way to those points. The python script waits until it receives a 'done' transmission from the arduino, and then sends the most recent set of coordinates for the laser.

It draws its power from the source that normally power the lights that connect to the fan, and can be turned on and off from the light switch. The fan can run while this is installed and operating, although I have noticed a bit of interference in the serial communication while the fan is running (magnetic interference, I assume) It can also be put into manual mode and controlled from any computer on the network.

Source code: http://burnshudson.com/laser/source/Lazyer.zip


Misc video dump


Promo my wife made


First prototype


Functional demo of first prototype


Early stages of cat tracking using OpenCV