Troubleshooting
This chapter summarizes common problems and solutions to help users quickly diagnose and resolve various issues encountered during use.
Hardware Issues
Servos Not Responding
Possible causes:
- The servo power supply is not connected
- Poor connection between the servos and the driver board
- Serial port connection failed
- The servos are not enabled Solutions:
- Check that the servo power supply is connected correctly and powered on
- Check that the cables between the servos and the driver board are firmly connected
- Run
examples/diagnostic.pyto view diagnostic information - Make sure you have pressed
Cto connect the gimbal and that the servos are enabled
Servo Movement Direction Is Reversed
Possible causes:
- The servo mounting direction or the program's control parameters need adjustment Solutions: Modify the
calculate_movemethod insrc/trackers/tracking_controller.pyand negate the corresponding parameters:
If pan is reversed
delta_pan = -int(self.kp_pan * err_x)If tilt is reversed
delta_tilt = -int(self.kp_tilt * err_y)Servo Jitter
Possible causes:
- Tracking parameters are too sensitive
- The dead zone is too small
- The servo load is too heavy or the power supply is insufficient Solutions:
- Increase the
dead_zoneparameter - Increase
min_move_interval - Decrease
kp_panandkp_tilt - Check whether the power supply voltage is normal
Serial Port Connection Fails
Possible causes:
- The driver is not installed
- The serial port name is incorrect
- The serial port is occupied by another program
- The cable is faulty Solutions:
- On Windows, check Device Manager to confirm the driver is installed correctly
- Run
examples/list_ports.pyto find the correct serial port - Close other programs that may be occupying the serial port
- Try a different USB port or cable
Software Issues
Camera Cannot Be Opened
Possible causes:
- The camera index is incorrect
- The camera is occupied by another program
- Camera hardware connection problems
- Camera driver problems Solutions:
- Run
examples/list_cameras.pyto view available camera indexes - Close other programs that may be using the camera
- Check whether the camera is connected properly
- Try a different USB port
OpenCV Errors
Possible causes:
- OpenCV version issues
- Incomplete installation of dependencies
- Camera hardware problems Solutions:
- Try reinstalling the dependencies:
pip install --upgrade opencv-python numpy- Check that the Python version meets the requirement (>=3.8)
- Read the error stack trace to locate the problematic code
Dependency Installation Fails
Possible causes:
- pip is too old
- Network connection problems
- Permission problems Solutions:
- Upgrade pip first:
pip install --upgrade pip- Use a domestic mirror to speed things up:
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple- Check whether the network connection is working
Program Starts Slowly
Possible causes:
- DSHOW is not used on Windows
- Camera hardware initialization takes time Solutions:
- Confirm that the code uses
cv2.CAP_DSHOWas the camera backend - Check whether another program is using the camera
- Wait a few seconds; camera initialization usually takes some time
Tracking Issues
Inaccurate Target Detection
For color tracking:
- Check that the target color contrasts clearly with the background
- Adjust the color parameters (in
src/detectors/color_detector.py) - Make sure the lighting is adequate and even For face tracking:
- Ensure adequate lighting and avoid backlight
- The face should be facing the camera directly
- Keep an appropriate distance
Gimbal Does Not Move During Tracking
Possible causes:
- The gimbal is not connected
- The target is not locked
- The target is within the dead zone
- A program error occurred Solutions:
- Make sure you have pressed
Cto connect the gimbal - Make sure you have pressed
Tto lock the target - Check the console output for error messages
- Check whether the target is within
dead_zone
Tracking Direction Is Reversed
Solutions: Refer to the solution for "Servo Movement Direction Is Reversed".
Tracking Jitter
Solutions: Refer to the solution for "Servo Jitter".
Target Lock Fails
Possible causes:
- The target is not in the center of the frame when locking
- The target is too small or its color is not distinct
- No target is detected Solutions:
- Make sure the target is in the center of the frame when locking
- Use an appropriately sized target that can be detected correctly
- Check the console output to confirm whether the target is detected
- Adjust the target position and lock again
Using the Diagnostic Tool
Running the Diagnostic Program
The system provides a comprehensive diagnostic tool that can test the hardware of the entire system:
python examples/diagnostic.py --camera 0 --port COM3The diagnostic program tests the following in sequence:
- Whether the camera works properly
- Whether the serial port connects properly
- Whether the servos respond properly When the tests are complete, it displays the results to help you locate the problem.
Viewing Debug Output
While the program runs, the console outputs relevant debug information, including:
- Information about detected targets
- Target coordinates
- Error values
- Gimbal movement commands
- Any error messages Carefully observing this output helps you locate problems quickly.
Recovery Methods
Return the Gimbal to a Safe Position
- Press
Rto return the gimbal to center - Or call
gimbal.return_to_center()
Reset All Settings
- Press
Sto stop tracking - Press
Rto return to center - Lock the target again
Recalibration
If tracking performance is seriously poor, you can:
- Adjust the tracking parameters
- Lock the target again
- Restart the program if necessary
- Check the hardware connections
Getting Help
If the above methods do not solve the problem, please record the following information:
- Operating system information
- Python version
- Detailed error information
- Steps to reproduce the problem
- Results of running diagnostic

