2-Axis Pan-Tilt Camera Module

From Waveshare Wiki
Jump to: navigation, search
2-Axis Pan-Tilt Camera Module
2-Axis Pan-Tilt Camera Module.jpg

I2C, UART, TTL Buse Servo Control Interface
2-DOF Pan-Tilt Camera
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Introduction

The pan-tilt camera module adopts high-torque 2-DOF bus servos, achieving a wide range of rotation in both the horizontal PAN axis (±180°, total range of 360°) and the vertical TILT axis (-45° to 90°, total range of 135°), significantly broadening the coverage area of the camera.
Based on General Driver for Robots, it seamlessly integrates with Raspberry Pi 4B/5, offering enhanced hardware flexibility. An open-source WEB control demo allows users to effortlessly control the pan-tilt via Google Chrome, enabling adjustments in the pan-tilt's orientation and image capture functionalities. Beyond basic photography and video capabilities, this pan-tilt camera also features facial and motion detection, delivering a more intelligent and precise monitoring experience. Not only are the pan-tilt's slave computer demos open-sourced, but also the demos about Raspberry Pi camera functionalities, empowering users for secondary development based on their specific requirements.

Both joints adopt a high-precision bus servo direct-drive solution, equipped with 360° 12-bit magnetic encoders for angle sensing, capable of relaying joint angles, load and other information, facilitating closed-loop control. Despite utilizing compact bus servos, they achieve a maximum joint torque of 30kg.cm, ensuring seamless integration of the pan-tilt camera module into various projects. Additionally, we provide a Picatinny rail along with 1/4 screws, open-source models, and drawings, enabling users to expand and create further possibilities according to their needs.

Driver Board Specifications

  • MAIN CONTROL: ESP32-D0WD-V3
  • SERVO ROTATION SPEED: 40rpm
  • JOINT ANGLE SENSOR: 12-bit 360° magnetic encoder
  • SERVO TORQUEZ: 30kg.cm
  • POWER SUPPLY: 12V
  • WIRED CONTROL MODE: USB, UART
  • LED POWER: <1.5W
  • WEIGHT: 441g

Assembly & Configuration Guide

Product Firmware Update

  • If "PT CAM Version:0.9" is displayed on the OLED screen when your product is booted, it means that the driver on the product is already a new version, and you do not need to execute this section to update the product.
  • If "PT CAM Version:0.9" is not displayed on the OLED screen when your product is booted, it means that the driver on the product is still the old version, and you need to perform this part of the content to update the product; If you need to restore factory settings, you can also do so through this section.

We offer the ESP32 download tool of pan-tilt, which allows users to quickly update the firmware or restore the product to the factory program.
1. First, use a USB cable to connect the middle-side USB port of General Driver for Robots to your computer.
2. Download the ESP32 download tool of pan-tilt, decompress it, and double-click "flash_download_tool_3.9.5.exe" to open the program. After opening, two windows will pop up. What we need to operate is the UI interface of the download tool, and the other window is used as a terminal to display the working status of the download tool.
3. In the "DOWNLOAD TOOL MODE" interface, set Chip Type to "ESP32" and WorkMode to "Factory". With "Factory", the relative path is used when binary files are invoked. Therefore, users do not need to manually enter the binary file path. Click OK after selecting.
Download tool mode.png
4. In this software interface, keep the "LockSettings" checked, the right side represents that you can upload the program to 8 pan-tilts at the same time. Click "COM" and select the new COM (the new COM here is COM31); BAUD is the download speed, the higher the value, the faster the speed, and ESP32 can use up to 921600.
PAN-TILT CAMERA FACTORY.png
5. After the selection, click "START" to upload the program. After the upload is completed, "IDLE" will change to "FINISH", you can disconnect the USB connection between the driver board and the computer, use the matching 12V 5A power supply to power the product, turn on the switch on the driver board, and the robot can be controlled after the power is turned on.
PAN-TILT CAMERA FACTORY1.png

Usage Guide

The slave control unit of this product is driven by ESP32 by default, communicating with the host device (such as a Raspberry Pi) via a GPIO serial or USB connection. The current host control demos provided are Raspberry Pi-based. The pan-tilt functions of the slave device demos (excluding camera-related functions) can operate independently without reliance on the host device. In the assembly and configuration guide, the Raspberry Pi communicates with the slave device via a GPIO serial connection.

Product Usage

First Time Use

Please follow the #Assembly & Configuration Guide to assemble the camera module, flash the Raspberry Pi OS to the SD card and configure it.
Connect the 12V 5A power supply to the power port of the pan-tilt, power on it and boots. The OLED screen will display the initialization content. If you configure it with the imager we provide, the Raspberry Pi will automatically create a hotspot, after the main demo automatically runs, the IP address will display on the OLED screen. The OLED screen will display a series of system initialization messages below:
RaspRover-LED-screen.png

  • The first line E: the IP address of the Ethernet port for remotely accessing the Raspberry Pi. "No Ethernet" means that the Raspberry Pi has no Ethernet cable connection.
  • The second line W: In AP mode, the robot will automatically establish a hotspot and display the default IP: 192.168.50.5. In STA mode, the Raspberry Pi will connect to a known WiFi network and display the IP address for remote access.
  • The third line F/J: Ethernet port number, "5000" is for accessing the robot control Web UI, and "8888" is for accessing the JupyterLab interface.
  • The fourth line AP: means the WIFI is in AP mode, and the time means the usage period of the robot, the value in dBm represents the Received Signal Strength Indicator (RSSI) in STA mode.

After the Raspberry Pi boots:

  • If the product does not connect to the known WIFI, it will automatically establish the hotspot. You can use a mobile phone or PC to access this hotspot, the name of the hotspot is AccessPopup, and the password of the hotspot is 1234567890. After connecting, open the browser, and input the default IP address in AP mode (the address displays on the W line of the OLED screen). This step is to visit the WEB control interface of the product main demo by inputting " 192.168.50.5:5000 " on the browser.
  • If the product connects to the known WIFI, you can enter the WEB control interface by visiting the IP address of the Raspberry Pi: 5000.

Note: the device to be visited and the Raspberry Pi should be connected to the same LAN.

Network Configuration

The network needs to be configured in the JupyterLab interface, and there are two methods to open JupyterLab interface:

  1. You can click on Rasprover LAB.png on the Web application UI to enter the JupyterLab interface.
  2. You can access the IP address of the robot: 8888 to enter the JupyterLab interface. If the robot is under the AP mode, you need to input "192.168.50.5:8888" to enter JupyterLab interface.

First Time to connect a known WiFi

The default WiFi mode of the robot is AP mode, you can refer to the following steps to switch to STA mode and connect to known WiFi:
1. After accessing the JupyterLab interface, click the "Terminal" at the bottom of the page, and enter the following command and press Enter to enter the project folder.

bash

RaspRover WiFi.png
2. The current location is ~/ugv_rpi, and then enter the file folder of WIFI configuration tool, and input the following commands and press "Enter":

cd AccessPopup/

3. Enter the following command and press Enter to grant executable permission for the WiFi configuration script in the AccessPopup folder:

sudo chmod +x installconfig.sh

4. Run the WiFi configuration script by the following command and pressing Enter:

sudo ./installconfig.sh

5. After running the script, you will see the following interface. Here, you need to enter "5" and press Enter to set up a new WiFi Network connection.
RaspRover-WIFI-connect-01.png
6. The script will redirect to the next page, Wait for a while, the robot will search for nearby WIFI and list out the WiFi names as follows. Each WIFI has a serial number in front of it. Enter the number corresponding to the WiFi network you want to connect to, and then press Enter.
RaspRover WiFi3.png
7. Then, enter the password of this WiFi network and press Enter. Once the Wifi is connected successfully, the new IP address of the robot will display in the "W" line of the OLED screen.
8. As the IP address of the robot has changed, you now need to input the new IP address to access the JupyterLab interface as below, it is in STA mode after successful connection, and you will see the same content as before. Press any key to continue.
RaspRover WiFi4.png
9. And then you can press "9" and press Enter to exit the WiFi configuration script.
Note: If the robot moves out of the range of the connected WiFi network or loses the connection while running, it will automatically enter the AP mode and establish a hotspot. In this case, you can access its hotspot name AccessPopup for control or configuration again.

WIFI Mode Switching

  • Switch STA mode to AP mode:

After connecting to a known WIFI, if you need to switch the robot to AP mode and establish a hotspot, open a "Terminal" on the JupyterLab interface. Enter bash to enter the project folder and input the following command to establish a hotspot:

sudo accesspopup -a
  • To switch back from AP mode to STA mode:

After configuring the known WiFi, you need to switch AP mode to STA mode, enter the following command to reconnect to the known WiFi:

sudo accesspopup

Note: After switching WiFi mode, you need to refresh the interface so that the control interface of the main demo and the IP address of JupyterLab.

Delete Known WIFI

1. Open a "Terminal" on the JupyterLab interface, enter bash to enter the project folder:
2. Then, use the following command to check all network connections:

nmcli connection show

3. Use the following command to delete a known WiFi connection: replace <connection_name> with the name of the WiFi network you want to delete:

sudo nmcli connection delete <connection_name>

Note: If you delete the current connected WiFi network, the robot will automatically switch to AP mode and establish a hotspot. In this case, the IP address of JupyterLab interface should be updated before using.

Enable SSH Service

If you program the imager we provide. you can enable SSH service. The SSH service can be enabled on the JupyterLab interface. There are two ways to enter JupyterLab interface:

  1. Enter JupyterLab interface by clicking on the Jupyterlabbutton.png button.
  2. Enter JupyterLab interface by visiting the device IP address: 8888. If you program the imager we provide, it is AP mode by default. You need input 192.168.50.5:8888 on the URL bar to open the JupyterLab interface.

1. Enter JupyterLab interface, click on the Terminal below, and input the following commands to enter the project file folder:

bash

Jupyterlab-1.png
2. Input the following commands on the terminal, use raspi-config tool to enable SSH service:

sudo raspi-config

Sshserveropen-1.png
3. Enter raspi-config tool and use up and down key to select “Interface Options”, and press "Enter" to confirm.
Sshserveropen-2.png
4. Select "SSH" and then press "Enter" to confirm.
Sshserveropen-3.png
5. Select "Yes" to enable SSH service.
Sshserveropen-4.png
6. After enabling SSH service, you can select "Finish" to exit. Input "sudo reboot" to reboot the system.

Raspberry Pi WEB Usage

In this part, we will introduce how to use the product when the Raspberry Pi communicates with the slave device through GPIO headers.
After accessing successfully, you can see the picture captured by the Raspberry Pi camera, and the following respectively introduces the key functions of the Raspberry Pi WEB control interface.

  • Clicking the 屏幕截图 2024-06-11 152344.png button in the center of the camera view initiates the photo-capturing function. The taken photos will be stored in the Photo Gallery module below.
  • If you click the "Record" button, it activates the video recording function. The videos captured by the camera will be stored in the Video Files module below.
  • Clicking once on the 屏幕截图 2024-06-11 152842.png button enlarges the current camera view by a factor of 1, clicking twice zooms it in by a factor of 2, and clicking a third time restores it to its original size.
  • Dragging the transparent circular button in the bottom right corner of the camera view controls the rotation of the camera pan-tilt. When using a PC with a keyboard, you can control the rotation of the pan-tilt through the classic "WASD" shortcut.
  • The square control panel below the camera view also manages the rotation of the camera pan-tilt in different directions. Clicking the "AHEAD" button restores the camera position to the set midpoint.
  • Enter Command: Here is an input box, can be used to input commands from the web to control the pan-tilt to achieve the corresponding functions, the specific commands will be described in detail in the #Raspberry Pi WEB Terminal Command Line Application.
  • Simple Detection Type: sets the type of object detection for the camera.
    • None: no object detection is active.
    • Movtion: the detection of moving objects.
    • Faces: detection for human faces.
  • Simple Detection Reaction: sets the automatic response upon detecting an object. If there's no detected object, this function remains inactive.
    • None: no automatic response.
    • Capture: automatic photo capturing upon detection.
    • Record: automatic video recording upon detection.
  • Advance CV Funcs: sets the type of detection.
    • OBJECTS: object recognition.
    • COLOR: color recognition.
    • HAND GS: gesture recognition.
  • Head Light Ctrl: turn the LED above the camera on or off.

Use7.png

Photo Gallery: Stores captured photos. If multiple images are taken, clicking "View Photo Gallery Page" displays all images (the number in parentheses represents the total). Clicking on an image allows zooming in for a closer view while clicking the button in the top right corner of an image deletes it.

Video Files: Stores recorded videos. If multiple videos are recorded, clicking "View Video Files Page" displays all videos (the number in parentheses represents the total). Clicking on a video plays it, and clicking the button that appears to the right of the video deletes it.

Bus Servos Initialization Setup: Servo calibration settings. Since servo calibration is typically performed during product assembly, there might not be a need to configure settings here. However, if adjustments are necessary for servo ID or center position settings, clicking "Setting Page" allows access to the setup page to follow the steps provided.
Use6.png

Raspberry Pi WEB Terminal Command Line Application

To configure the product better and help users customize the product, we design the "Enter Command"f function. You can enter commands in the input box to realize the corresponding functions. Here we will introduce these functions in detail.
Use9.png

Slave Control

  • Directly send JSON command to the slave. Please refer to #Slave JSON Command Set.
    • base -c +JSON command, for example: base -c {"T":133,"X":0,"Y":0,"SPD":0,"ACC":0}
    • base --cmd +JSON, for example: base --cmd {"T":133,"X":0,"Y":0,"SPD":0,"ACC":0}
  • If the above formats are sent successfully, you only need to replace the specific JSON commands.
  • Open the camera screen to display the slave information:
    • base -r on
    • base -recv on

Use8.png

  • Close the camera screen to display the slave information:
    • base -r off
    • base --recv off

Adjust Host Function Parameters

  • Set the target color range:
    • cv -r [90,120,90] [120,255,200]
    • cv -range [90,120,90] [120,255,200]
  • Select the color (Only red, green, and blue by default):
    • cv -s red
    • cv --select red
  • Set the tracking parameters of the pan-tilt:
    • Color tracking iteration ratio:
      • track -c 0.023
    • Face/Gesture Tracking Iteration Ratio:
      • track -f 0.068
    • Tracking speed
      • track -s 60
    • Motion Acceleration Ratio:
      • track -a 0.4

Slave JSON Command Set

In the Raspberry Pi WEB side command line application, we introduced that you can send motion control commands to the slave via the host. There are a lot of commands that the lower unit can receive, and we will introduce them in this section.
You can see the definitions of these commands in the json_cmd.h file of our open-source downconverter routine, or add new downconverter functionality to it yourself!
CMD_LED_CTRL

  • {"T":132,"IO4":255,"IO5":255}
    • 12V switch output setting.
    • The slave controller of the product has two 12V power ports, two ports for each one and four ports in total. You can set the output voltage of these interfaces through this instruction. The product defaults to use these ports to control the LED lights, you can use this command to control the brightness of the LED lights. For the pan-tilt LED brightness, you can modify the number after "IO5" in this command. The value 255 here indicates the 3S battery voltage. 255 means the maximum brightness, 0 means the brightness is off, the bigger the value between 0-255, the bigger the brightness.

CMD_GIMBAL_CTRL_SIMPLE

  • {"T":133,"X":0,"Y":0,"SPD":0,"ACC":0}
    • Basic control command for the pan-tilt
    • This command is used to control the orientation of the pan-tilt. X represents the horizontal direction, and the unit is degree. The positive value is to the right, and the negative value is to the left. The range of value is -180 to 180. Y represents the vertical direction, and the unit is degree. The positive value indicates moving upward, and the negative value indicates moving downward. The range of value is -30 to 90. SPD is the speed, ACC is the acceleration, when the value is 0, it is the fastest speed/acceleration.

CMD_GIMBAL_CTRL_MOVE

  • {"T":134,"X":45,"Y":45,"SX":300,"SY":300}
  • Continuously controls the pan-tilt.
    • This command is used to control the direction of the pan-tilt continuously. X is the horizontal orientation in degree. The positive values indicate turning right, and the negative values indicate turning left. And the range is -180 to 180. Y represents the vertical orientation in degree. The positive value indicates moving upward, and the negative value indicates moving downward. The range is -30 to 90. SX and SY respectively represent the speeds of the X-axis and Y-axis.

CMD_GIMBAL_CTRL_STOPE

  • {"T":135}
    • The command to stop pan-tilt.
    • After using the above commands to move the pan-tilt, you can use this command to stop its movement at anytime.

CMD_GIMBAL_STEADY

  • {"T":137,"s":0,"y":0}
    • The pan-tilt self-stabilization function.
    • This function is turned off when s=0, and is turned on when s=1. When this function is turned on, the gimbal will automatically adjust the vertical angle of the pan-tilt through the IMU data, and y is the target angle of the pan-tilt to the ground (even if the pan-tilt self-stabilizing function is turned on, the camera can still look up and down).

CMD_GIMBAL_USER_CTRL

  • {"T":141,"X":0,"Y":0,"SPD":300}
    • Pan-tilt UI control.
    • This command is used for the UI interface to control the pan-tilt. X value could be -1, 0 and 1. "-1" means moving left, "0" means stop, "1 means moving right. Y value could be -1, 0 and 1. -1 means moving downward, 0 means stop, 1 means moving upward. SPD represents speed.

Arduino IDE development tools

General Robot Driver Board Resources

General Driver for Robot02.jpg

No. Onboard Resources Description
1 ESP32-WROOM-32 main controller Can be developed with the Arduino IDE
2 IPEX1 WiFi connector For connecting the WIFI antenna to increase the wireless communication distance
3 LIDAR interface Integrated radar adapter board function
4 IIC peripheral expansion interface Can be used to connect OLED screens or other IIC sensors
5 Reset button Press and release to reboot the ESP32
6 Download button The ESP32 will enter the download mode when the power is turned on by pressing
7 DC-DC 5V voltage regulator circuit Power supply for host computers such as Raspberry Pi or Jetson nano
8 Type-C connector (LIDAR) LIDAR data interface
9 Type-C connector (USB) ESP32 UART communication interface, can upload programs for ESP32
10 XH2.54 power port Input DC 7~13V, this interface directly powers the serial bus servo and motor
11 INA219 Voltage/current monitoring chip
12 Power ON/OFF Switches to control external power supply (switch on in the above figure)
13 ST3215 serial bus servo interface For connecting to ST3215 serial bus servo
14 Motor interface PH2.0 6P Group B interface for motor with encoder
15 Motor interface PH2.0 6P Group A interface for motor with encoder
16 Motor interface PH2.0 2P Group A interface for motor without encoder (it is LED interface for this product)
17 Motor interface PH2.0 2P Group B interface for motor without encoder
18 AK09918C 3-axis electronic compass
19 QMI8658 6-axis motion sensor
20 TB6612FNG Motor control chip
21 Serial bus servo control circuit Can be used to expand multiple ST3215 serial bus servos and obtain servo feedback
22 SD card slot Can be used to store logs or WIFI configurations
23 40PIN extended header Easy access to Raspberry Pi or Horizon Sunrise X3 Pi
24 40PIN extended header Easy to use the pins of the host computer installed on the driver board
25 CP2102 UART to USB for radar data transfer
26 CP2102 UART to USB for ESP32 UART communication
27 Automatic download circuit Upload demos for the ESP32 without pressing the EN and BOOT buttons

Resource

Open-source Demo

Drawing

STEP Model

Driver Board Schematic

FAQ

 Answer:

First, you need to check whether General Driver for Robots is connected to the USB connector ⑨, if it is connected, you need to check whether the COM port is on the Device Manager of the PC; if it is not here, you can check whether there is unidentified device with "CP2102" on the Other Devices; if you find the "CP2102" device here, you need to install the CP2102 serial port driver as it requires the driver installation to be identified. If you cannot find the device with "CP2102" on the Other Device, you need to contact store customer service to return to the factory for repair.

{{{5}}}


 Answer:

You can connect the servo cable to the DVG port, the power cable to the DC port. The lamp is connected to the A1/A2 port.
2-Axis Pan-Tilt Camera Module-h.jpg

{{{5}}}


 Answer:

Because it may have bugs when we use the GPIO serial port for communication. The Raspberry Pi has assigned the full-featured serial port to Bluetooth and the mini UART to the GPIO UART by default.

{{{5}}}


Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)