|
| 1 | +# ST3215 Test Suite |
| 2 | + |
| 3 | +This directory contains individual test scripts for testing ST3215 servo motor functionality. Each test focuses on specific functionality and can be run independently. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +### Hardware Requirements |
| 8 | +- ST3215 servo motor with ID 1 connected to the system |
| 9 | +- USB-to-Serial adapter (RS-485 or TTL depending on your setup) |
| 10 | +- Proper power supply for the servo motor |
| 11 | + |
| 12 | +### Software Requirements |
| 13 | +- Python 3.10+ |
| 14 | +- st3215 library installed (`pip install -e .` from project root) |
| 15 | +- pyserial dependency |
| 16 | + |
| 17 | +## Environment Setup |
| 18 | + |
| 19 | +Set the USB device path in your environment: |
| 20 | + |
| 21 | +```bash |
| 22 | +export ST3215_DEV="/dev/ttyUSB0" |
| 23 | +``` |
| 24 | + |
| 25 | +## Running Tests |
| 26 | + |
| 27 | +Each test can be executed individually: |
| 28 | + |
| 29 | +```bash |
| 30 | +python test_01_ping_servo.py |
| 31 | +python test_02_list_servos.py |
| 32 | +# ... etc |
| 33 | +``` |
| 34 | + |
| 35 | +Or run all tests in sequence: |
| 36 | + |
| 37 | +```bash |
| 38 | +for test in test_*.py; do echo "Running $test"; python "$test"; echo; done |
| 39 | +``` |
| 40 | + |
| 41 | +## Test Descriptions |
| 42 | + |
| 43 | +### Test 01: PingServo |
| 44 | +Tests basic communication with servo ID 1. |
| 45 | +- **File**: `test_01_ping_servo.py` |
| 46 | +- **Purpose**: Verify servo is connected and responding |
| 47 | + |
| 48 | +### Test 02: ListServos |
| 49 | +Scans the bus for all connected servos. |
| 50 | +- **File**: `test_02_list_servos.py` |
| 51 | +- **Purpose**: Discover all servos on the bus |
| 52 | + |
| 53 | +### Test 03: Read Load, Voltage & Current |
| 54 | +Tests telemetry reading functions. |
| 55 | +- **File**: `test_03_read_load_voltage_current.py` |
| 56 | +- **Purpose**: Read motor load, supply voltage, and current consumption |
| 57 | +- **⚠️ Special Instructions**: Apply physical force to the servo motor shaft, then press Enter before running this test |
| 58 | + |
| 59 | +### Test 04: ReadTemperature |
| 60 | +Tests temperature sensor reading. |
| 61 | +- **File**: `test_04_read_temperature.py` |
| 62 | +- **Purpose**: Read internal servo temperature |
| 63 | + |
| 64 | +### Test 05: ReadAcceleration |
| 65 | +Tests acceleration parameter reading. |
| 66 | +- **File**: `test_05_read_acceleration.py` |
| 67 | +- **Purpose**: Read current acceleration setting |
| 68 | + |
| 69 | +### Test 06: ReadMode |
| 70 | +Tests operational mode reading. |
| 71 | +- **File**: `test_06_read_mode.py` |
| 72 | +- **Purpose**: Read current servo operation mode |
| 73 | + |
| 74 | +### Test 07: ReadCorrection |
| 75 | +Tests position correction reading. |
| 76 | +- **File**: `test_07_read_correction.py` |
| 77 | +- **Purpose**: Read position correction value |
| 78 | + |
| 79 | +### Test 08: ReadStatus |
| 80 | +Tests servo status reading. |
| 81 | +- **File**: `test_08_read_status.py` |
| 82 | +- **Purpose**: Read servo sensor status flags |
| 83 | + |
| 84 | +### Test 09: IsMoving |
| 85 | +Tests motion detection. |
| 86 | +- **File**: `test_09_is_moving.py` |
| 87 | +- **Purpose**: Check if servo is currently moving |
| 88 | + |
| 89 | +### Test 10: Complete Motion Control |
| 90 | +Comprehensive test of servo control functions. |
| 91 | +- **File**: `test_10_complete_motion_control.py` |
| 92 | +- **Purpose**: Test StartServo, SetAcceleration, SetSpeed, rotation mode, position mode, and StopServo |
| 93 | +- **⚠️ Important**: Ensure servo has enough physical clearance for movement |
| 94 | + |
| 95 | +## Safety Notes |
| 96 | + |
| 97 | +- Ensure proper power supply is connected before running tests |
| 98 | +- Verify servo has adequate clearance for movement in Test 10 |
| 99 | +- Stop execution immediately if unusual noises or behaviors occur |
| 100 | +- Test 03 requires manual interaction (applying force) |
| 101 | + |
| 102 | +## Troubleshooting |
| 103 | + |
| 104 | +### Common Issues |
| 105 | + |
| 106 | +1. **Permission denied on /dev/ttyUSB0**: |
| 107 | + ```bash |
| 108 | + sudo chmod 666 /dev/ttyUSB0 |
| 109 | + # or add user to dialout group |
| 110 | + sudo usermod -a -G dialout $USER |
| 111 | + ``` |
| 112 | + |
| 113 | +2. **Servo not responding**: |
| 114 | + - Check power supply |
| 115 | + - Verify correct baud rate |
| 116 | + - Ensure proper wiring |
| 117 | + - Confirm servo ID is set to 1 |
| 118 | + |
| 119 | +3. **Import errors**: |
| 120 | + - Install library: `pip install -e .` from project root |
| 121 | + - Check Python path |
| 122 | + |
| 123 | +## Expected Output |
| 124 | + |
| 125 | +Each test will display: |
| 126 | +- Test description |
| 127 | +- Connection status |
| 128 | +- Test results with actual values |
| 129 | +- Success/failure indication |
| 130 | + |
| 131 | +Example output: |
| 132 | +``` |
| 133 | +=== ST3215 Ping Test === |
| 134 | +Device: /dev/ttyUSB0 |
| 135 | +Testing ping to servo ID 1... |
| 136 | +✓ Servo ID 1 responded successfully |
| 137 | +Test completed successfully! |
| 138 | +``` |
0 commit comments