Software tests - SergeGit/rc-tank-platform GitHub Wiki
Manual Mode Integration Test
Objective: ✅ Validate that in Manual Mode, commands from the PS3 controller (or Web) are correctly interpreted and sent to the turret and movement systems.
Specifically:
- PS3 controller inputs are mocked: move forward, turn right, turret slight rotate right, and aim slightly up.
- Web inputs are mocked the same way.
- Auto-aim is disabled (mocked to pass inputs unchanged).
- Firing logic is mocked to allow firing instantly (
True). - Check that
i2c.send_command(mocked) would receive:
-
- Turret rotation commands (10%)
-
- Turret elevation commands (-5%)
-
- Fire commands when fire is True.
Result: ✔️ Confirms the system reacts to manual control input properly, and no auto-aiming modifies the manual joystick/web commands.
Semi-Auto Mode Integration Test
flowchart TD
A1[Manual Mode Start] --> A2[Read PS3 or Web Inputs]
A2 --> A3[Use inputs directly]
A3 --> A4[Send Turret Rotation & Elevation commands]
A4 --> A5[Check Fire Button Pressed]
A5 -->|Yes| A6[Send Cannon Fire Command]
A5 -->|No| A7[No Fire]
Semi-Auto Mode Integration Test
Objective: ✅ Validate that in Semi-Auto Mode (FIRE submode):
- The turret uses real AutoAimProcessor to auto-align.
- The system only fires if the target is:
-
- Detected
-
- Confident (> 0.7)
-
- Centered within aim tolerance
-
- Tracked long enough (> 1s)
Specifically:
- A simulated target is perfectly centered (x = 0.5, y = 0.5) and confident.
- Target is assigned a tracking_id to simulate it's been locked for >2 seconds.
- Web inputs allow safety override to permit firing.
AutoAimProcessoris active (real PID calculations based on target position).FireDecisionLogicis active (real logic to allow firing only if safe).
Result: ✔️ Confirms that auto-aim and fire decision work together correctly:
- Turret auto-corrects position (even though perfectly centered here).
- Cannon fires only when conditions are met (i.e., tracked target, safety confirmed).
flowchart TD
B1[Semi-Auto Mode Start FIRE] --> B2[Read Web Inputs]
B2 --> B3[Computer Vision detects target]
B3 --> B4[AutoAimProcessor corrects aim]
B4 --> B5[FireDecisionLogic checks:]
B5 --> B6{Is target centered, confident,\nand tracked long enough?}
B6 -->|Yes| B7[Send Cannon Fire Command]
B6 -->|No| B8[Hold Fire]
In short
| Test | What is checked? | Hardware involvement? | Fire? | Auto-aim? |
|---|---|---|---|---|
| Manual | Manual control flows properly | Mocked (no hardware) | Yes | No (manual) |
| Semi-Auto | Auto-aim and fire-decision flows correctly | Mocked (no hardware) | Yes | Yes (PID-driven) |
flowchart TD
A[Manual Mode Update]
A --> B1[Send TURRET_ROTATE manual value]
A --> B2[Send TURRET_ELEVATE manual value]
A --> B3{Fire Button Pressed?}
B3 -->|Yes| B4[Send CANNON_FIRE 100]
B3 -->|No| B5[No Fire]
C[Semi-Auto Mode Update]
C --> D1[Computer Vision target]
D1 --> D2[AutoAimProcessor adjust rotation/elevation]
D2 --> D3[Send TURRET_ROTATE auto-aimed value]
D2 --> D4[Send TURRET_ELEVATE auto-aimed value]
D4 --> D5{Fire Decision Logic OK?}
D5 -->|Yes| D6[Send CANNON_FIRE 100]
D5 -->|No| D7[No Fire]