Before starting the server, make sure the servos and laser diode are hooked up to power. Then start the server by executing the following command in the pi-catlaser directory on the Raspberry Pi:
Setting PWM frequency to 50 Hz
Estimated pre-scale: 121
Final pre-scale: 121
* Running on http://0.0.0.0:5000/
* Restarting with reloader
You can stop the server at any time by pressing Ctrl-C, and restart the server with the same command used to start it.
Now navigate to the web application in a web browser from a computer on your network. You will want to access http://your_raspberry_pi_IP_address:5000/ (if you don't know the IP address of your Raspberry Pi, run the command 'ifconfig' and look for the 'inet addr' value--likely something within 192.168.1.*).
For example if your Raspberry Pi's IP address is 192.168.1.120, you would access http://192.168.1.120:5000/ in a web browser.
If everything is setup correctly you should see a page with your camera's video stream load.
If you see an error message or no response, check that the server started successfully and that the previous steps were completed successfully.
Note, you might need to be logged in to your network camera before accessing the web page so the video will load.
Servo ControlIn the top right of the page you will see the raw X and Y axis servo values, and controls to manipulate these values up and down. You can also type a servo position value directly into the input control and tab to another control to update the servo.
Try changing the servo values to verify the servos and laser move.
Click the 'Start Calibration' button to walk through the calibration of the target area and the laser. See this video for an example of running the calibration.
The calibration process works by finding a transformation between a quadrilateral on the screen (the red target area) to a quadrilateral in laser servo coordinate space (the X and Y servo values together define a 2D coordinate system). Plugging these quadrilaterals into a perspective projection equation and solving for the coefficients allows the server to transform clicks inside the target area to servo positions that aim the laser. You can find more details on this process here.
Once the calibration is done you're ready to play! Click inside the red target area and the laser should be moved to aim at the location of your click. Have fun making your cat chase the laser around over the web!