Dependencies
To setup the software you'll need to install the following dependencies on the Raspberry Pi:- Python
- Flask, a python web application framework.
- NumPy, a python library for numeric computing.
- Git, revision control system to download the code used by this project.
sudo apt-get install python python-flask python-numpy python-smbus git
You might already have some of these dependencies installed on your Raspberry Pi. If a command exits with an "already the newest version" message you can ignore it and move on.
Code
Now you can download the software for the project from GitHub by executing the following command. This will create a 'pi-catlaser' folder in your current directory which will contain the code for the project.git clone https://github.com/tdicola/pi-catlaser.git
Navigate inside the newly created pi-catlaser folder to continue the software setup.
For reference some of the important files in the pi-catlaser directory are:
If your servo controller is not on the default 0x40 I2C address or your servos are not hooked up to channels 0 and 1 of the servo controller, edit server.py (using a text editor on the Raspberry Pi such as 'nano') and adjust these values at the top of the file.
With any changes to the code made, you're ready to start the server, test the servo movement, and calibrate the laser.
For reference some of the important files in the pi-catlaser directory are:
- server.py: The main web application python code. At the top of this file is a small set of configuration values for the I2C address of the servo controller, channels for each servo, and min/max/center servo values.
- model.py: The code for moving, targeting, and calibrating the laser.
- modeltests.py: Python unit tests for validating the model's functionality.
- servos.py: Code to interface with the servo controller and move the servos.
- Adafruit_I2C.py & Adafruit_PWM_Servo_Driver.py: Code from the Adafruit Raspberry Pi python code library to interface with the PCA9685 servo controller board.
- templates/main.html: The HTML code for the web application. The image tag which contains the MJPEG video stream for the network camera is in this file beneath a comment near line 19.
- static/js/calibration.js: The javascript code to calibrate and overlay graphics on the video.
- calibration.json: This file will initially not exist, but after calibration this file will save the calibration values.
If your servo controller is not on the default 0x40 I2C address or your servos are not hooked up to channels 0 and 1 of the servo controller, edit server.py (using a text editor on the Raspberry Pi such as 'nano') and adjust these values at the top of the file.
With any changes to the code made, you're ready to start the server, test the servo movement, and calibrate the laser.
Text editor powered by tinymce.