2-Axis Pan-Tilt Camera Module Assembly and Configuration Guide
How to Assemble
Note: This tutorial includes how to install Raspberry Pi and how to configure the SD card, and you need to prepare the Raspberry Pi and SD card by yourself. Please refer to the Package Content for a detailed part list.
In the installation process of this video, there is no connection between the horizontal servo and the tilt servo. It is necessary to calibrate the servo according to the following guide before connecting.
- Product Assembly and Configuration Video:
Servo Calibration
Please do not power on it immediately after completing the assembly of the product.
Before configuring the Raspberry Pi environment, please set the IDs and the middle position for the servos first.
Connect your computer to the USB interface of General Driver for Robots using a USB cable (ensure it's the middle-side USB port) before powering on. This step prevents unexpected servo movements before setting the middle position.
Ensure the power switch is in the OFF position.
Then, use the provided 12V 5A power supply to connect to the power interface of the product, noting the crucial steps highlighted in red above.
Next, turn on the power switch to power up the product. As the Raspberry Pi does not have an SD card or system installed at this point, the slave pan-tilt functions (excluding camera-related functionalities) can be operated through the host device.
Upon booting, the OLED screen displays "PT CAM Version:0.9", which indicates the slave driver demo version is version 0.9. If this information is not displayed, you need to update it following this guide. For other information displayed on the LED screen:
- "AP" at the first line: the IP address of the slave device. It indicates the WiFi of the slave demo is in AP mode.
- "ST" at the second line: the STA mode is turned off. When the WiFi is in STA mode, the router will assign an IP address, and this IP address will be displayed on the screen.
- "MAC" at the third line: the MAC address of this device. This address is the only one for ESP-NOW communication.
- The fourth line indicates the power voltage of this product.
After booting up, connect your smartphone or computer to the WIFI: PT network with the password "12345678". Once connected, open the Google Chrome browser and enter 192.168.4.1 in the address bar to access the slave device's web-based pan-tilt control interface. Now, you can proceed with setting the servo IDs and the middle position.
ID Setting
The initial IDs for both the pan and tilt servos are 1, but the ID for the pan servo should be set to 2.
- During product assembly, the pan and tilt servos are not connected. If they are connected, please disconnect the tilt servo to ensure that you set the servo ID only for the pan servo.
- In the "FEEDBACK INFORMATION" module's input box, enter the command to set the servo ID in JSON format:
{"T":501,"raw":1,"new":2}
- T: JSON command value, fixed one, cannot be modified.
- raw: the old servo ID, the default servo ID is "1".
- new: the new servo ID to be modified. The pan servo ID needs to be set as "2".
You can also directly click on the INPUT button of the BUS_SERVO_ID_SET command below, which will automatically input the servo ID setting command in JSON format into the input box. Click "SEND" to confirm and successfully set the ID.
Middle Position Setting
Connect the pan servo and tilt servo together. Before setting the middle position, ensure both servos' torque locks are turned off. In the "FEEDBACK INFORMATION" module's input box, enter the JSON-formatted command to toggle the torque locks:
{"T":210,"cmd":0}
Once both servo torque locks are turned off, as shown in the diagram, manually adjust the angles of both servos to align the camera parallelly towards the front.
After adjusting the angle of two servos, you can input the command for setting the middle position of the servo in JSON format:
{"T":502,"id":1}
- "id" here refers to the servo's ID: 1 for the tilt servo and 2 for the pan servo.
After setting the middle position, use the directional buttons (up, down, left, right) to control the pan-tilt's movement to different angles. Then click on "FORWARD" button to check whether two servos can rotate to the middle position, or send the following JSON command to control the servo pan-tilt.
{"T":133,"X":0,"Y":0,"SPD":0,"ACC":0}
If the X and Y values of two servos both are "0", and the ID indicating the middle position is set correctly, then the calibration is finished. If the pan-tilt doesn't function correctly, recalibrate the servos by following all the calibration steps again. If it operates properly, confirming that the servo IDs and the middle position are set correctly, power off the device. Now, you can proceed with configuring the Raspberry Pi environment.
Raspberry Pi Environment Configuration Tutorial
The Raspberry Pi Foundation has developed a graphical SD card writing tool called the Raspberry Pi Imager, which is compatible with operating systems such as Windows, Mac OS, and Ubuntu.
This tool automatically downloads images and installs them onto an SD card. It can also be used to install images of other systems onto an SD card. Click on the Raspberry Pi Imager official website link to download the latest version of the Raspberry Pi Imager and install it.
Method One
Device Preparation (NOT included in the kit, please prepare them by yourself.)
- SD card reader
- SD card (at least 8GB)
Imager Download
- Download link: pan-tilt imager
- Username: ws, password: ws
Steps
- 1. Use the SD card reader to connect the SD card to the PC, open Raspberry Pi Imager, do not select "CHOOSE DEVICE" (this product only supports Raspberry Pi 4B/5), and then click on "CHOOSE OS" to select the operating system to be programmed.
- 2. Scroll to the bottom of the system image selection and click “Use custom” to select the configured image you downloaded earlier.
- 3. Then select "CHOOSE STORAGE" to program your SD card.
- 4. After selection, click on "NEXT". A custom settings dialog box will pop up, select "EDIT SETTINGS" to configure the username and WiFi settings.
- 5. Set the username and WiFi in the "GENERAL" column, and uncheck the boxes as shown in the picture below.
The username and password of the configured imager both are "ws". Here you do not need to configure it, if you want to set your WiFi, you can follow this guide.
- 6. Next, please cancel SSH service in "SERVICE". After programming the imager, you can refer to this link to enable SSH service. After setting, you need to click "SAVE". A pop-up window will appear that all data on the SD card will be deleted, select “Yes”.
Start to program the image, wait for a while to finish programming, the Raspberry Pi Imager will automatically pop up the SD card, remove the SD card and insert it into the Raspberry Pi. Turn on the main power switch, power on the Raspberry Pi, then refer to the product tutorial to learn how to use the product.
Method Two
We also provide a self-configuration method for the software, so you can install the pan-tilt demo on a new Bookworm system or on your existing system. Note: The current version of the demo currently only runs on official Raspberry Pi Bookworm systems, other versions are not supported.
Install Operating System
- 1. Use the SD card reader to connect the SD card to the PC, open Raspberry Pi Imager, do not select "CHOOSE DEVICE" (this product only supports Raspberry Pi 4B/5), and then click on "CHOOSE OS" to select the operating system to be programmed.
- 2. The Raspberry Pi demo we provided is based on the current newest system of the Raspberry Pi, so here we select Bookworem (64-bit).
- 3. Then select "CHOOSE STORAGE" to program your SD card.
- 4. After selection, click on "NEXT". A custom settings dialog box will pop up, select "EDIT SETTINGS" to configure the username and WiFi settings.
- 5. Set the username and WiFi in the "GENERAL" column, and uncheck the boxes as shown in the picture below. The username and password of the configured imager both are "ws". Here you do not need to configure it, if you want to set your WiFi, you can follow this guide.
- Then, enable "SSH" service on "SERVICES". So you can remotely control your Raspberry Pi system with SSH connection. By now, after setting, click on "SAVE". Then, a pop-up window will remind you that all the data will be deleted, just click on "Yes".
Start to burn the image, wait for a while to finish programming, the Raspberry Pi Imager will automatically pop up the SD card, remove the SD card and insert it into the Raspberry Pi. Turn on the main power switch and power on the Raspberry Pi.
Demo Download
The Raspberry Pi will automatically connect to the hotspot set above to get the Raspberry Pi IP address. You can click here to see how to get IP address. Type cmd in the Start menu bar to open a command prompt and use SSH to connect to the Raspberry Pi remotely, input:
ssh username@IP address
Enter, type yes, and then enter the password you set earlier. It is a normal phenomenon that there is no change on the screen when you input the password, after you finish inputting the password, you can access the Raspberry Pi by pressing the Enter key. As shown in the following picture:
Clone the project files from Waveshare's Github to the system locally:
git clone https://github.com/waveshareteam/ugv_rpi.git
Software Installation
After unzipping, install the software, and enter "ugv_rpi" project file folder:
cd ugv_rpi
Respectively input the following two commands to add executable permissions for "setup.sh" and "autorun.sh:
sudo chmod +x setup.sh sudo chmod +x autorun.sh
Execute "./setup.sh" to install the script file to install the software and inputs:
sudo ./setup.sh
The installation process will last a few minutes, after the installation is complete, the window will show Successfully and Setup completed that means the installation is successful, as shown below.
Execute ./autorun.sh to automatically run the script file:
./autorun.sh
Install AccessPopup for the product to automatically establish the hotspot:
cd AccessPopup sudo chmod +x installconfig.sh
Execute and install the configuration file:
sudo ./installconfig.sh
Input "1" to install. After installation, "Press any key to continue" shows, you can press any key, and then input "9" to exit the installation configuration:
#If you use Raspberry Pi 4B, you need to delete "v4l2.py" from the Python environment and user environment. This makes the demo automatically use "v4l2.py" on the system, input the following commands on the terminal: cd ugv_rpi/ sudo rm ugv-env/lib/python3.11/site-packages/v4l2.py sudo rm /home/[your_user_name]/.local/lib/python3.11/site-packages/v4l2.py #Raspberry Pi 5 does not require the above operation.
At last, you need to reboot the device:
sudo reboot
After rebooting, the installation and environment configuration of the pan-tilt is completed. Next, you can refer to this link to learn how to use the product.