spec cleanup

This commit is contained in:
Oleksandr Bezdieniezhnykh
2025-11-30 19:08:40 +02:00
parent b12f37ab01
commit 3d034e27ee
10 changed files with 270 additions and 152 deletions
@@ -27,7 +27,15 @@ class IResultManager(ABC):
pass
@abstractmethod
def mark_refined(self, flight_id: str, frame_ids: List[int]) -> bool:
def mark_refined(self, flight_id: str, refined_results: List[RefinedFrameResult]) -> bool:
"""
Updates results for frames that have been retrospectively improved.
Args:
flight_id: Flight identifier
refined_results: List of RefinedFrameResult containing frame_id and GPS-converted coordinates
(caller F02.2 converts ENU to GPS before calling this method)
"""
pass
@abstractmethod
@@ -35,7 +43,15 @@ class IResultManager(ABC):
pass
@abstractmethod
def update_results_after_chunk_merge(self, flight_id: str, merged_frames: List[int]) -> bool:
def update_results_after_chunk_merge(self, flight_id: str, refined_results: List[RefinedFrameResult]) -> bool:
"""
Updates results for frames affected by chunk merge.
Args:
flight_id: Flight identifier
refined_results: List of RefinedFrameResult with GPS-converted coordinates
(caller F02.2 converts ENU to GPS before calling this method)
"""
pass
```
@@ -141,35 +157,37 @@ FlightResults:
---
### `mark_refined(flight_id: str, frame_ids: List[int]) -> bool`
### `mark_refined(flight_id: str, refined_results: List[RefinedFrameResult]) -> bool`
**Description**: Updates results for frames that have been retrospectively improved (e.g., after loop closure or chunk merge).
**Called By**:
- F10 Factor Graph (after asynchronous refinement)
- F02.2 Flight Processing Engine (after factor graph optimization)
**Input**:
```python
flight_id: str
frame_ids: List[int] # Frames with updated poses
refined_results: List[RefinedFrameResult] # GPS-converted results from F02.2
```
**Output**: `bool`
**Note**: F14 does NOT call F10 or F13. The caller (F02.2) performs the following steps before calling mark_refined():
1. F02.2 gets refined poses from F10.get_trajectory(flight_id)
**Important**: F14 does NOT call F10 or F13. The caller (F02.2) performs the following steps before calling mark_refined():
1. F02.2 gets refined poses from F10.get_trajectory(flight_id) (ENU coordinates)
2. F02.2 converts ENU to GPS via F13.enu_to_gps(flight_id, enu_tuple)
3. F02.2 calls F14.mark_refined() with the GPS-converted results
3. F02.2 constructs RefinedFrameResult objects with GPS coordinates
4. F02.2 calls F14.mark_refined() with the GPS-converted results
**Processing Flow**:
1. For each frame_id in frame_ids:
- Receive GPS coordinates from caller (already converted)
1. For each refined_result in refined_results:
- Extract frame_id, gps_center, confidence from RefinedFrameResult
- Update result with refined=True via F03 Flight Database (part of transaction)
- Update waypoint via F03 Flight Database (part of transaction)
- Call F15 SSE Event Streamer.send_refinement()
**Test Cases**:
1. Batch refinement → all frames updated and published
2. GPS coordinates match converted values
---
@@ -194,25 +212,34 @@ since: datetime
---
### `update_results_after_chunk_merge(flight_id: str, merged_frames: List[int]) -> bool`
### `update_results_after_chunk_merge(flight_id: str, refined_results: List[RefinedFrameResult]) -> bool`
**Description**: Handling specific to chunk merging events.
**Description**: Updates results for frames affected by chunk merging into main trajectory.
**Triggered By**:
- `ChunkMerged` event from F11 (F14 subscribes to this event)
- Alternative: F02.2 Flight Processing Engine can coordinate this call after receiving ChunkMerged event
**Called By**:
- F02.2 Flight Processing Engine (after chunk merge completes)
**Input**:
```python
flight_id: str
merged_frames: List[int] # Frames whose poses changed due to chunk merge
refined_results: List[RefinedFrameResult] # GPS-converted results for merged frames
```
**Output**: `bool` - True if updated successfully
**Important**: F14 does NOT call F10, F13, or F11. F02.2 coordinates the chunk merge workflow:
1. F11 returns merge result to F02.2 (direct call return, not event)
2. F02.2 gets updated poses from F10.get_trajectory(flight_id) (ENU coordinates)
3. F02.2 converts ENU to GPS via F13.enu_to_gps(flight_id, enu_tuple)
4. F02.2 constructs RefinedFrameResult objects
5. F02.2 calls F14.update_results_after_chunk_merge() with GPS-converted results
**Processing Flow**:
1. Similar to `mark_refined` but triggered by `ChunkMerged` event context.
2. Ensures all frames in the merged chunk are updated to the global coordinate system.
1. For each refined_result in refined_results:
- Extract frame_id, gps_center, confidence from RefinedFrameResult
- Update result with refined=True via F03 Flight Database (part of transaction)
- Update waypoint via F03 Flight Database (part of transaction)
- Call F15 SSE Event Streamer.send_refinement()
**Test Cases**:
1. **Chunk merge updates**: All merged frames updated and published
@@ -286,6 +313,19 @@ class FrameResult(BaseModel):
updated_at: datetime
```
### RefinedFrameResult
```python
class RefinedFrameResult(BaseModel):
"""
GPS-converted frame result provided by F02.2 after coordinate transformation.
F02.2 converts ENU poses from F10 to GPS using F13 before passing to F14.
"""
frame_id: int
gps_center: GPSPoint # GPS coordinates (converted from ENU by F02.2)
confidence: float
heading: Optional[float] = None # Updated heading if available
```
### FlightResults
```python
class FlightStatistics(BaseModel):