Browse Source
feat(radar): restore physical 1/R^4 path loss and symmetric 120° FOV
feat(radar): restore physical 1/R^4 path loss and symmetric 120° FOV
Restores high-fidelity physical realism to the C-Shenron radar engine by aligning the synthesis pipeline with the pure Radar Range Equation. Core Improvements: - Physics: Restored 1/R^4 power-delay law (1/R^2 voltage) in Sceneset.py and heatmap_gen_fast.py. Stripped legacy 1/1000 normalizations and R^2 area-growth workarounds. - Geometry: Fixed FFT index asymmetry in radar_processor.py, achieving a perfectly symmetric 120° FOV sector. - Metrology: Implemented "Radar Blue" (Viridis) 120° fan-projection for diagnostic Range-Azimuth heatmaps. - Automation: Integrated RD/RA/CFAR heatmap persistence into the automated simulation-to-MCAP pipeline (data_to_mcap.py). - Docs: Comprehensive update of intel/ directory, including Iterations 17-26 and the Physics/Symmetry Milestone deep-dive. This milestone ensures that target brightness and spatial positioning correctly mimic real-world TI AWRL1432 radar hardware.1843_integration
14 changed files with 1416 additions and 39 deletions
-
8intel/radar/3D energy compression debug.md
-
48intel/radar/Physics_Symmetry_Milestone_R4.md
-
9intel/radar/Shenron_debug.md
-
87intel/radar/metrology_suite/Auto_MCAP_SHENRON.md
-
468intel/radar/metrology_suite/RARD_CFAR_Guide.md
-
56intel/radar/metrology_suite/agent_context_radar_metrology.md
-
365intel/radar/metrology_suite/shenron_radar_improvement_plan.md
-
76intel/radar/metrology_suite/walkthrough.md
-
18scripts/ISOLATE/e2e_agent_sem_lidar2shenron_package/shenron/Sceneset.py
-
9scripts/ISOLATE/e2e_agent_sem_lidar2shenron_package/shenron/heatmap_gen_fast.py
-
48scripts/ISOLATE/sim_radar_utils/radar_processor.py
-
126scripts/data_to_mcap.py
-
17scripts/generate_shenron.py
-
112scripts/test_shenron.py
@ -0,0 +1,48 @@ |
|||||
|
# 🏆 Milestone: Pure Physical 1/R⁴ & Zero-Tilt Symmetry |
||||
|
|
||||
|
**Date:** 2026-04-08 |
||||
|
**Iteration Range:** 20 — 26 |
||||
|
**Status:** **LOCKED-IN BASELINE** |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 🏗️ 1. The Physics Breakthrough: 1/R⁴ Power Law |
||||
|
|
||||
|
Prior to this milestone, the C-Shenron engine used various "normalization" workarounds (like Iteration 16's `DENSITY_REF = 1000`) to prevent distant buildings from overwhelming the scene. However, these were artificial and lacked dynamic fidelity. |
||||
|
|
||||
|
### The Problem: |
||||
|
- Distant buildings (massive surface area) were integrated with the same weight as near cars. |
||||
|
- Because distance-based attenuation was "neutralized" in the code, the building's magnitude (1600) was higher than a near car (1400). |
||||
|
- This made ADAS algorithm testing impossible as the SNR profiles were physically incorrect. |
||||
|
|
||||
|
### The Solution: |
||||
|
We have stripped all artificial normalizations and returned to **Pure Free-Space Physics**: |
||||
|
1. **Transmitter Power ($P_{inc} \propto 1/R^2$)**: Each LiDAR point's incident power now follows the inverse square law. |
||||
|
2. **Receiver Voltage ($V_{adc} \propto 1/R^2$)**: The final ADC signal is attenuated by the return path ($1/R^1 \text{ voltage} \implies 1/R^2 \text{ power}$). |
||||
|
3. **Result**: The total power follows the **$1/R^4$ Radar Range Equation**. A distant building is now physically $ \sim 50,000\times$ weaker in power than a near car, making the car the natural dominant peak. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 📐 2. The Geometric Breakthrough: Zero-Tilt Symmetry |
||||
|
|
||||
|
The Range-Azimuth "Fan" plot in earlier iterations appeared slightly tilted (sheared) toward the left. |
||||
|
|
||||
|
### The Problem: |
||||
|
- **Index Asymmetry:** Standard FFT indexing `np.arange(-N/2, N/2)` results in an asymmetric range (e.g., $-32 \to +31$ for 64 points). |
||||
|
- **Angular Mapping:** This created a ~15° mismatch between the left and right boundaries of the Field of View. |
||||
|
|
||||
|
### The Solution: |
||||
|
- **Symmetry-Lock:** We updated `radar_processor.py` to use perfectly centered index linear spaces: `np.linspace(-N/2 + 0.5, N/2 - 0.5, N)`. |
||||
|
- **Result:** The 120° FOV fan is now perfectly symmetric around the boresight. This is critical for ADAS verification where lateral accuracy is paramount. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 🖼️ 3. Visual Standard: "Radar Blue" |
||||
|
|
||||
|
We have standardized the diagnostic visualization suite for all future automated MCAP sessions: |
||||
|
- **Colormap:** `viridis` (Professional high-contrast blue/green/yellow). |
||||
|
- **Normalization:** **Global Frame Normalization**. No per-range-bin stretching is allowed, as it obscures the physical $1/R^2$ amplitude decay. |
||||
|
- **Dynamic Range:** Diagnostic heatmaps now preserve the "Energy Difference" between targets, ensuring human and AI agents can accurately judge target priority. |
||||
|
|
||||
|
--- |
||||
|
*Generated by Antigravity | Fox CARLA ADAS Pipeline Calibration Milestone | 2026-04-08* |
||||
@ -0,0 +1,87 @@ |
|||||
|
# 🚀 Auto MCAP & SHENRON Integration Architecture |
||||
|
|
||||
|
This document describes the automated pipeline for generating, processing, and visualizing high-fidelity radar data within the Fox CARLA Simulation project. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 🏗️ 1. The Three-Stage Pipeline |
||||
|
|
||||
|
Every time a simulation is triggered (e.g., via `run.bat`), the system follows a deterministic three-stage process: |
||||
|
|
||||
|
### Stage 1: Live Simulation (`src/main.py`) |
||||
|
- **Objective:** Generate raw multi-modal sensor data from the CARLA simulator. |
||||
|
- **Output:** `data/<session>/lidar/*.npy`, `camera/*.png`, and `frames.jsonl`. |
||||
|
- **Key Feature:** LiDAR is saved with **Semantic Tags** and **Radial Velocity** calculations, which are essential inputs for the physics-based radar model. |
||||
|
|
||||
|
### Stage 2: Shenron Synthesis (`scripts/generate_shenron.py`) |
||||
|
- **Objective:** Convert LiDAR point clouds into high-fidelity radar signals. |
||||
|
- **Logic:** Calls `ShenronRadarModel` to perform FMCW signal synthesis. |
||||
|
- **Improved Output:** |
||||
|
- `shenron_radar/*.npy`: 3D Radar Point Cloud (x, y, z, vel, mag). |
||||
|
- `metrology/rd/*.npy`: Range-Doppler Heatmaps. |
||||
|
- `metrology/ra/*.npy`: Range-Azimuth Heatmaps. |
||||
|
- `metrology/cfar/*.npy`: CFAR threshold masks. |
||||
|
- `range_axis.npy` & `angle_axis.npy`: Physical axis definitions for visualization. |
||||
|
- **Physics Constraint:** As of Iteration 26, all artificial normalizations (e.g. 1/1000) have been removed. Signals follow the pure **1/R⁴ Radar Range Equation**. |
||||
|
|
||||
|
### Stage 3: MCAP Conversion (`scripts/data_to_mcap.py`) |
||||
|
- **Objective:** Package all disparate files into a single Foxglove-compatible `.mcap` log. |
||||
|
- **Visual Enhancement:** Implements **Polar Scan Conversion** for the RA map, projecting the rectangular $(R, \theta)$ data onto a forward-facing BEV sector. |
||||
|
- **Final Output:** `data/<session>/<session>.mcap`. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 🛰️ 2. Core Metrology Algorithms |
||||
|
|
||||
|
The current system implements several state-of-the-art radar processing fixes to ensure simulation fidelity matches real-world hardware. |
||||
|
|
||||
|
### A. Doppler-Slice RA Accumulation |
||||
|
To prevent angular smearing, the Range-Azimuth map is generated by looping over Doppler bins. |
||||
|
1. Each bin is processed via a **Windowed Angle FFT**. |
||||
|
2. **Phase Preservation:** Magnitude is never taken before the FFT. Complex inputs ensure beamforming works. |
||||
|
3. Power is summed **Incoherently** across Doppler bins *after* the FFT. |
||||
|
|
||||
|
### B. Incoherent RD Integration |
||||
|
The Range-Doppler map uses **Incoherent Power Summation** across receiver antenna channels ($|FFT|^2$). This preserves signal energy from moving targets that would otherwise cancel out due to phase misalignment if simple averaging was used. |
||||
|
|
||||
|
### C. 120° Symmetric Sector Scan-Conversion |
||||
|
The RA visualizer uses a **Radial Projection** to create a true Birds-Eye View (BEV) fan. |
||||
|
- **Symmetry-Lock:** As of Iteration 21, the FFT indices are perfectly centered to ensure the fan is symmetric around the boresight (0°). |
||||
|
- **Aesthetic:** Uses the **Viridis (Radar Blue)** colormap with **Global Normalization**. |
||||
|
- **Physics Fidelity:** No per-range-bin normalization is allowed. Brightness must decay with distance ($M \propto 1/R^2$) to represent real-world sensor behavior. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 📁 3. Data Structure Reference |
||||
|
|
||||
|
A successful automated run will produce the following structure: |
||||
|
|
||||
|
```text |
||||
|
data/ |
||||
|
└── scenario_timestamp/ |
||||
|
├── frames.jsonl # Metadata & Synchronization |
||||
|
├── lidar/ # Semantic LiDAR [N, 7] |
||||
|
├── camera/ # Dashcam imagery |
||||
|
├── shenron_radar/ # 3D Radar Point Cloud [M, 5] |
||||
|
├── metrology/ # Diagnostic Heatmaps |
||||
|
│ ├── rd/ # Range-Doppler |
||||
|
│ ├── ra/ # Range-Azimuth |
||||
|
│ ├── cfar/ # CFAR mask |
||||
|
│ ├── range_axis.npy # Physical Range Axis (metres) |
||||
|
│ └── angle_axis.npy # Physical Azimuth Axis (radians) |
||||
|
└── scenario_timestamp.mcap # Final Foxglove Package |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 🧭 4. Interpretation Guide for AI Agents |
||||
|
|
||||
|
When evaluating a session, AI agents should look for the following "Success Indicators": |
||||
|
|
||||
|
1. **Azimuth Variance:** In the RA heatmap, energy should be non-uniform across the angle axis. Objects should appear as discrete blobs. |
||||
|
2. **Target Alignment:** The "Orange Blobs" in the RA Sector plot must spatially align with the "White Points" in the 3D LiDAR point cloud. |
||||
|
3. **V=0 Vertical:** In the RD heatmap, static geometry (ground/buildings) must form a sharp vertical line at the 0 m/s mark. |
||||
|
4. **Inverse Square Decay:** Target intensity in heatmaps should naturally decrease as range increases ($1/R^2$ in voltage, $1/R^4$ in power). Near-field objects must dominate the energy profile. |
||||
|
|
||||
|
--- |
||||
|
*Documented by Antigravity | Project: Fox CARLA ADAS | 2026-04-01* |
||||
@ -0,0 +1,468 @@ |
|||||
|
# RARDCFAR_guide.md |
||||
|
|
||||
|
## C-Shenron Radar Metrology Debugging & Correction Guide |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 1. System Architecture (Your Implementation) |
||||
|
|
||||
|
## Signal Chain |
||||
|
|
||||
|
```text |
||||
|
LiDAR → Physics Engine → Raw ADC → Range FFT → Doppler FFT → Angle FFT → CFAR → Point Cloud |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Your Actual Implementation (Code Verified) |
||||
|
|
||||
|
### Range FFT |
||||
|
|
||||
|
```python |
||||
|
fft(data * rangeWin * velWin, axis=0) |
||||
|
``` |
||||
|
|
||||
|
### Doppler FFT |
||||
|
|
||||
|
```python |
||||
|
fftshift(fft(rangeProfile, axis=1), axis=1) |
||||
|
``` |
||||
|
|
||||
|
### RD Heatmap |
||||
|
|
||||
|
```python |
||||
|
avgDopplerProfile = np.mean(dopplerProfile, axis=2) |
||||
|
rd_heatmap = |avgDopplerProfile|^2 |
||||
|
``` |
||||
|
|
||||
|
### RA Heatmap |
||||
|
|
||||
|
```python |
||||
|
ra_heatmap_raw = np.mean(dopplerProfile, axis=1) |
||||
|
ra_heatmap = |FFT(ra_heatmap_raw)|^2 |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 2. Current Observations (From Your Output) |
||||
|
|
||||
|
## ✅ Correct |
||||
|
|
||||
|
* Range axis correct |
||||
|
* RD vertical column at V=0 |
||||
|
* CFAR pipeline working |
||||
|
* FFT chain structurally valid |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## ❌ Issues |
||||
|
|
||||
|
| Component | Issue | |
||||
|
| --------- | ------------------------------------------ | |
||||
|
| RD | No Doppler spread | |
||||
|
| RA | Horizontal banding + no angular separation | |
||||
|
| CFAR | Over-detecting static clutter | |
||||
|
| RA | Phase cancellation artifacts | |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 3. ROOT CAUSE ANALYSIS (CODE LEVEL) |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# ❌ ISSUE 1 — RA Banding (CRITICAL) |
||||
|
|
||||
|
## Problem Line: |
||||
|
|
||||
|
```python |
||||
|
ra_heatmap_raw = np.mean(dopplerProfile, axis=1) |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Why This is WRONG |
||||
|
|
||||
|
You are doing: |
||||
|
|
||||
|
> **Coherent integration across Doppler (complex mean)** |
||||
|
|
||||
|
This causes: |
||||
|
|
||||
|
### 🔴 Phase cancellation |
||||
|
|
||||
|
For moving targets: |
||||
|
|
||||
|
[ |
||||
|
\sum e^{j\phi_k} ≈ 0 |
||||
|
] |
||||
|
|
||||
|
→ Signal disappears |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Result: |
||||
|
|
||||
|
* Horizontal banding |
||||
|
* Missing targets |
||||
|
* Weak angular structure |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## ✅ FIX (MANDATORY) |
||||
|
|
||||
|
Replace with: |
||||
|
|
||||
|
```python |
||||
|
ra_heatmap_raw = np.sum(np.abs(dopplerProfile), axis=1) |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Why This Works |
||||
|
|
||||
|
* Preserves energy |
||||
|
* Removes phase sensitivity |
||||
|
* Matches real radar power integration |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# ❌ ISSUE 2 — Missing Window on Angle FFT |
||||
|
|
||||
|
## Current: |
||||
|
|
||||
|
```python |
||||
|
fft(pointSel, axis=1) |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Problem: |
||||
|
|
||||
|
* No spatial window → sidelobes |
||||
|
* Poor angular resolution |
||||
|
* Leakage → smearing |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## ✅ FIX |
||||
|
|
||||
|
Apply Hann window: |
||||
|
|
||||
|
```python |
||||
|
window = np.hanning(N_antennas) |
||||
|
pointSel_windowed = pointSel * window |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
Then: |
||||
|
|
||||
|
```python |
||||
|
fft(pointSel_windowed, axis=1) |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# ❌ ISSUE 3 — Doppler Collapse |
||||
|
|
||||
|
## Problem Location: |
||||
|
|
||||
|
```python |
||||
|
avgDopplerProfile = np.mean(dopplerProfile, axis=2) |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Why This is WRONG |
||||
|
|
||||
|
* Averaging complex signals across antennas |
||||
|
* Phase misalignment → cancellation |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Result: |
||||
|
|
||||
|
* Everything collapses to V=0 |
||||
|
* No velocity separation |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## ✅ FIX |
||||
|
|
||||
|
Use power summation: |
||||
|
|
||||
|
```python |
||||
|
rd_heatmap = np.sum(np.abs(dopplerProfile)**2, axis=2) |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Why: |
||||
|
|
||||
|
* Preserves Doppler energy |
||||
|
* Matches real radar processing |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# ❌ ISSUE 4 — CFAR Too Permissive |
||||
|
|
||||
|
## Config: |
||||
|
|
||||
|
```yaml |
||||
|
threshold: 20 |
||||
|
win_param: [9, 9, 3, 3] |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Problem: |
||||
|
|
||||
|
* Large window → over-smoothing |
||||
|
* Static clutter dominates noise estimate |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Symptoms: |
||||
|
|
||||
|
* Entire vertical column detected |
||||
|
* Poor selectivity |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## ✅ FIX |
||||
|
|
||||
|
### Adjust: |
||||
|
|
||||
|
```yaml |
||||
|
win_param: [6, 6, 2, 2] |
||||
|
threshold: 25–35 |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Optional Upgrade: |
||||
|
|
||||
|
Switch to: |
||||
|
|
||||
|
* OS-CFAR (better robustness) |
||||
|
* Or adaptive threshold per range band |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# ❌ ISSUE 5 — Velocity Axis Compression |
||||
|
|
||||
|
## Code: |
||||
|
|
||||
|
```python |
||||
|
velAxis = ... |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Problem: |
||||
|
|
||||
|
* Likely too wide range |
||||
|
* Real velocities compressed near zero |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## ✅ FIX |
||||
|
|
||||
|
Limit: |
||||
|
|
||||
|
```python |
||||
|
vel_min = -20 m/s |
||||
|
vel_max = +20 m/s |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# ❌ ISSUE 6 — RA Formation Order |
||||
|
|
||||
|
## Current Flow: |
||||
|
|
||||
|
```text |
||||
|
Doppler → mean → angle FFT |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Correct Flow: |
||||
|
|
||||
|
```text |
||||
|
Doppler → magnitude → sum → angle FFT |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 4. CORRECTED PIPELINE |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## RD Generation |
||||
|
|
||||
|
```python |
||||
|
rd_heatmap = np.sum(np.abs(dopplerProfile)**2, axis=2) |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## RA Generation |
||||
|
|
||||
|
```python |
||||
|
ra_heatmap_raw = np.sum(np.abs(dopplerProfile), axis=1) |
||||
|
|
||||
|
window = np.hanning(N_ant) |
||||
|
ra_heatmap_raw *= window |
||||
|
|
||||
|
ra_heatmap = np.abs(fftshift(fft(ra_heatmap_raw, axis=1)))**2 |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Angle Estimation |
||||
|
|
||||
|
```python |
||||
|
aoaProfile = fft(pointSel * window, axis=1) |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 5. VALIDATION CHECKLIST |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## RD |
||||
|
|
||||
|
* [ ] Static → vertical line |
||||
|
* [ ] Moving → offset blobs |
||||
|
* [ ] No collapse to center |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## RA |
||||
|
|
||||
|
* [ ] Left/right separation |
||||
|
* [ ] Matches LiDAR geometry |
||||
|
* [ ] No horizontal banding |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## CFAR |
||||
|
|
||||
|
* [ ] Sparse detections |
||||
|
* [ ] Peaks only |
||||
|
* [ ] No full-column activation |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 6. KEY INSIGHT (IMPORTANT) |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Your Current System |
||||
|
|
||||
|
> FFT pipeline is correct |
||||
|
> BUT **integration strategy is wrong** |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Core Problem |
||||
|
|
||||
|
You are doing: |
||||
|
|
||||
|
> **Coherent integration where incoherent is required** |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Radar Rule |
||||
|
|
||||
|
| Stage | Integration Type | |
||||
|
| ----- | ---------------- | |
||||
|
| FFT | Coherent | |
||||
|
| Power | Incoherent | |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 7. Shenron vs Your System |
||||
|
|
||||
|
| Component | Shenron | Your Current | |
||||
|
| ----------- | ------------ | ------------------ | |
||||
|
| Integration | Incoherent | ❌ Coherent | |
||||
|
| RA | Energy field | ❌ Phase-sensitive | |
||||
|
| RD | Power-based | ⚠️ Mixed | |
||||
|
| CFAR | Tuned | ⚠️ Over-permissive | |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 8. Expected Outcome After Fix |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## RD |
||||
|
|
||||
|
* Clear moving targets |
||||
|
* Velocity separation visible |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## RA |
||||
|
|
||||
|
* Clean blobs |
||||
|
* Angular localization restored |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## CFAR |
||||
|
|
||||
|
* Sparse detections |
||||
|
* True target extraction |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 9. Next Steps |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Immediate |
||||
|
|
||||
|
1. Fix RD power calculation |
||||
|
2. Fix RA incoherent integration |
||||
|
3. Add Hann window |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Then |
||||
|
|
||||
|
4. Tune CFAR |
||||
|
5. Validate against LiDAR |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Optional (Advanced) |
||||
|
|
||||
|
* Add antenna array geometry |
||||
|
* Add beam pattern |
||||
|
* Add noise model |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 10. Offer |
||||
|
|
||||
|
If you want: |
||||
|
|
||||
|
👉 I can rewrite your `RadarProcessor` into a **correct, production-grade version** |
||||
|
👉 Or debug further edge cases (multipath, clutter, velocity aliasing) |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# FINAL TAKEAWAY |
||||
|
|
||||
|
> Your system is **architecturally correct** |
||||
|
> But **one fundamental mistake (coherent averaging)** is breaking RA and RD fidelity. |
||||
|
|
||||
|
Fix that → your system will jump to near **Shenron-quality radar output**. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
**End of Document** |
||||
@ -0,0 +1,56 @@ |
|||||
|
# 🤖 AI Agent Context: Radar Metrology Interpretation |
||||
|
|
||||
|
This document provides the technical context required for an AI agent to analyze and validate a **C-SHENRON Radar Metrology** display. Use this to determine if the simulation is physically sound and if the radar is correctly detecting targets. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 📐 1. Global Axis Definitions |
||||
|
Across all three heatmaps, the **Vertical Axis (Y)** is consistently **Range (Distance)**. |
||||
|
- **Top of Image:** Far field (maximum range). |
||||
|
- **Bottom of Image:** Near field (Range = 0 / Ego-vehicle). |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 🛰️ 2. The Three-Plot Metrology Suite |
||||
|
|
||||
|
### A. Range-Doppler (RD) Heatmap (Bottom-Right) |
||||
|
* **Colormap:** `Viridis` (Dark blue for noise, Yellow for peak energy). |
||||
|
* **X-Axis:** **Doppler Velocity (m/s)**. Center is typically $V=0$. |
||||
|
* **Y-Axis:** **Range (m)**. |
||||
|
* **Generation Logic:** Performed via a 2D FFT. The first FFT (Fast Time) extracts Range; the second FFT (Slow Time) extracts phase shifts across chirps to determine Velocity. |
||||
|
* **Success Criteria:** Stationary objects (walls, ground) must form a perfectly vertical column at $V=0$. Moving vehicles must appear as "Energy Blobs" offset to the left or right of center. |
||||
|
|
||||
|
### B. Range-Azimuth (RA) Heatmap (Top-Right) |
||||
|
* **Colormap:** `Magma` (Deep purple for noise, Bright orange for energy). |
||||
|
* **X-Axis:** **Azimuth Angle (Radians/Degrees)**. Center is $0^\circ$ (Forward). |
||||
|
* **Y-Axis:** **Range (m)**. |
||||
|
* **Generation Logic:** Doppler bins are averaged to collapse the velocity dimension, followed by an **Angle-FFT** across the receiver antenna channels. |
||||
|
* **Success Criteria:** This plot should look like a "Polar Bird's Eye View." The orange energy clusters must spatially correspond to the visible structures in the 1D Lidar point cloud. |
||||
|
|
||||
|
### C. CFAR Detection Gate (Bottom-Left) |
||||
|
* **Colormap:** `Plasma` (Dark for low threshold, Yellow for high threshold). |
||||
|
* **X-Axis:** **Doppler Velocity**. (Mirrors the RD map). |
||||
|
* **Y-Axis:** **Range**. (Mirrors the RD map). |
||||
|
* **Generation Logic:** Constant False Alarm Rate (CA-CFAR) sliding window. It estimates the local noise floor and multiplies it by a **Threshold Gain**. |
||||
|
* **Success Criteria:** This is the "Adaptive Filter." An RD peak only becomes a 3D point if its energy in the **RD Map** is GREATER than its value here. If the gate is too "bright" (Yellow), valid targets will be filtered out. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 🧭 3. 3D Cross-Validation (The Radar-to-Lidar Check) |
||||
|
|
||||
|
The **Main 3D View (Left)** shows the final output. When analyzing this for correctness: |
||||
|
|
||||
|
1. **Spatial Alignment:** If the **RA Heatmap** shows a strong orange blob in the **bottom-right** quadrant, there should be a cluster of Lidar points closely positioned to the **right of the front bumper** in the 3D view. |
||||
|
2. **NPC Motion Vectors:** As an NPC approaches the ego-vehicle, its corresponding peak in the **RD/RA Heatmaps** must move from the **Top** of the image towards the **Bottom**. A point moving towards the top represents an object moving away. |
||||
|
3. **Velocity Consistency Check:** If the **RD Heatmap** shows an energy blob at $+10 m/s$ (moving away), the corresponding points in the 3D view should be moving at that reported velocity. |
||||
|
4. **Ghosting Identification:** If the **RA Heatmap** shows energy where there is NO Lidar reflection, it indicates a **Multipath Return** or a **Ghost Point**. The agent should flag this as a potential simulation fidelity issue. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
### 🎨 Colormap Quick-Reference for Agents |
||||
|
- **Yellow/White:** High Energy / High Detection Threshold. |
||||
|
- **Deep Blue/Purple:** Noise Floor / Low Signal. |
||||
|
- **Center-Spike:** Usually indicates the Ego-Vehicle's own structure or a very strong static target directly ahead. |
||||
|
|
||||
|
--- |
||||
|
*Created by Antigravity | Project: Fox CARLA ADAS | 2026-04-08* |
||||
@ -0,0 +1,365 @@ |
|||||
|
# Shenron_Radar_Improvement_Plan.md |
||||
|
|
||||
|
## Target: Improve RA Fidelity, Understand RD Behavior, Prepare for CFAR Tuning |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 1. Objective |
||||
|
|
||||
|
This document defines **focused, implementable changes** to improve radar fidelity in the current Shenron-style pipeline. |
||||
|
|
||||
|
Scope is intentionally **controlled and staged**: |
||||
|
|
||||
|
* ✅ Fix RA angular fidelity (high impact) |
||||
|
* ⚠️ Understand RD anomalies (Radarbook 24 GHz) |
||||
|
* ⚠️ Improve visualization clarity |
||||
|
* ⏳ Defer CFAR tuning (final stage) |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 2. Current System Status |
||||
|
|
||||
|
## ✅ Working Well |
||||
|
|
||||
|
* FMCW signal chain is correct |
||||
|
* Range FFT, Doppler FFT functioning |
||||
|
* Incoherent integration implemented |
||||
|
* RA banding issue resolved |
||||
|
* Angle FFT stabilized with Hann window |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## ⚠️ Remaining Issues |
||||
|
|
||||
|
| Issue | Priority | Status | |
||||
|
| ---------------------- | --------- | ----------------- | |
||||
|
| RA angular smearing | 🔥 HIGH | To fix now | |
||||
|
| RD behavior (24 GHz) | ⚠️ MEDIUM | Needs explanation | |
||||
|
| Visualization contrast | ⚠️ LOW | Quick fix | |
||||
|
| CFAR tuning | ⏳ LOW | Later | |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 3. 🔥 ISSUE 1 — RA Angular Smearing (PRIMARY FIX) |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Problem Summary |
||||
|
|
||||
|
Current implementation: |
||||
|
|
||||
|
```python |
||||
|
ra_heatmap_raw = np.sum(np.abs(dopplerProfile), axis=1) |
||||
|
→ angle FFT |
||||
|
``` |
||||
|
|
||||
|
### Problem: |
||||
|
|
||||
|
* Doppler dimension is collapsed too early |
||||
|
* Angle diversity is lost |
||||
|
* Results in: |
||||
|
|
||||
|
* Blurred angular response |
||||
|
* Weak left/right separation |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## ✅ Required Fix: Doppler-Slice-Based RA |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Implementation |
||||
|
|
||||
|
Replace current RA generation with: |
||||
|
|
||||
|
```python |
||||
|
# Initialize RA heatmap |
||||
|
ra_heatmap = np.zeros((R, A)) |
||||
|
|
||||
|
# Loop over Doppler bins |
||||
|
for d in range(N_doppler): |
||||
|
doppler_slice = np.abs(dopplerProfile[:, d, :]) # (Range, Antenna) |
||||
|
|
||||
|
# Apply spatial window |
||||
|
doppler_slice_windowed = doppler_slice * self.spatialWin |
||||
|
|
||||
|
# Angle FFT |
||||
|
angle_fft = fftshift(fft(doppler_slice_windowed, fftCfg['NFFTAnt'], axis=1), axis=1) |
||||
|
|
||||
|
# Accumulate power |
||||
|
ra_heatmap += np.abs(angle_fft)**2 |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Why This Works |
||||
|
|
||||
|
| Aspect | Benefit | |
||||
|
| --------------------------- | --------------------------------- | |
||||
|
| Preserves Doppler diversity | Better object separation | |
||||
|
| Prevents angular averaging | Sharper peaks | |
||||
|
| Closer to real radar | Matches energy accumulation model | |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Expected Result |
||||
|
|
||||
|
* Clear left/right object blobs |
||||
|
* Improved angular resolution |
||||
|
* RA matches LiDAR geometry |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 4. ⚠️ ISSUE 3 — RD Behavior (24 GHz Radarbook) |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Observation |
||||
|
|
||||
|
You reported: |
||||
|
|
||||
|
* Faint Doppler peaks visible ✔ |
||||
|
* Strong vertical line still dominant ✔ |
||||
|
* RD behavior inconsistent vs expectation ❌ |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Explanation (IMPORTANT) |
||||
|
|
||||
|
This is **NOT a bug** — it is expected behavior for your setup. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Root Causes |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
### 1. Low Carrier Frequency (24 GHz vs 77 GHz) |
||||
|
|
||||
|
Doppler resolution: |
||||
|
|
||||
|
[ |
||||
|
f_D = \frac{2 v f_c}{c} |
||||
|
] |
||||
|
|
||||
|
At 24 GHz: |
||||
|
|
||||
|
* Doppler shift is **~3× smaller** than 77 GHz |
||||
|
* Harder to resolve velocity differences |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
### 2. Limited Chirps (Np) |
||||
|
|
||||
|
From config: |
||||
|
|
||||
|
```yaml |
||||
|
Np: 64 |
||||
|
``` |
||||
|
|
||||
|
Doppler resolution: |
||||
|
|
||||
|
[ |
||||
|
\Delta v = \frac{\lambda}{2 T_{frame}} |
||||
|
] |
||||
|
|
||||
|
→ With fewer chirps: |
||||
|
|
||||
|
* Poor velocity resolution |
||||
|
* Smearing toward zero |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
### 3. Scene Characteristics |
||||
|
|
||||
|
* Most objects are static → strong DC component |
||||
|
* Moving objects: |
||||
|
|
||||
|
* Weak reflections |
||||
|
* Low RCS variation |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
### 4. Incoherent Integration Effect |
||||
|
|
||||
|
```python |
||||
|
rd_heatmap = sum(|doppler|^2) |
||||
|
``` |
||||
|
|
||||
|
* Dominates strong static returns |
||||
|
* Weak dynamic targets get buried |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Resulting RD Behavior |
||||
|
|
||||
|
| Feature | Explanation | |
||||
|
| -------------------- | -------------------------- | |
||||
|
| Strong vertical line | Static clutter dominates | |
||||
|
| Faint offset blobs | Moving objects (correct) | |
||||
|
| Weak separation | Limited Doppler resolution | |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## ✅ Conclusion |
||||
|
|
||||
|
> Your RD is **physically correct**, not broken. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Optional Improvements (NOT REQUIRED NOW) |
||||
|
|
||||
|
* Increase chirp count (Np) |
||||
|
* Apply Doppler window (Hann) |
||||
|
* Normalize per Doppler bin |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 5. ⚠️ ISSUE 5 — RA Visualization (LOW EFFORT, HIGH IMPACT) |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Problem |
||||
|
|
||||
|
* RA heatmap appears saturated |
||||
|
* Low contrast in angular domain |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Fix |
||||
|
|
||||
|
Apply log scaling before visualization: |
||||
|
|
||||
|
```python |
||||
|
ra_display = np.log10(ra_heatmap + 1e-6) |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Optional Normalization |
||||
|
|
||||
|
```python |
||||
|
ra_display = ra_display / np.max(ra_display) |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Expected Result |
||||
|
|
||||
|
* Better contrast |
||||
|
* Clear object visibility |
||||
|
* Easier debugging |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 6. ⏳ ISSUE 4 — CFAR (DEFERRED) |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Current Status |
||||
|
|
||||
|
* CFAR working but not tuned |
||||
|
* Over-detection present |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Plan |
||||
|
|
||||
|
Defer until: |
||||
|
|
||||
|
* RA is fully correct |
||||
|
* RD behavior validated |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Future Work |
||||
|
|
||||
|
* Tune window size |
||||
|
* Adjust threshold |
||||
|
* Possibly implement OS-CFAR |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 7. Implementation Summary (FOR AI AGENT) |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Step 1 — Replace RA Generation |
||||
|
|
||||
|
* Remove current `np.sum(..., axis=1)` RA logic |
||||
|
* Implement Doppler-slice accumulation |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Step 2 — Keep Existing Fixes |
||||
|
|
||||
|
Do NOT modify: |
||||
|
|
||||
|
* RD power computation |
||||
|
* Spatial window (Hann) |
||||
|
* Angle FFT pipeline |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Step 3 — Add Log Visualization |
||||
|
|
||||
|
* Apply log scaling before rendering RA |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## Step 4 — Validate |
||||
|
|
||||
|
Check: |
||||
|
|
||||
|
* RA shows angular separation |
||||
|
* RD retains faint Doppler blobs |
||||
|
* No reintroduction of banding |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 8. Final Insight |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## What You Just Achieved |
||||
|
|
||||
|
You have moved from: |
||||
|
|
||||
|
> ❌ Signal processing approximation |
||||
|
|
||||
|
to: |
||||
|
|
||||
|
> ✅ Physically consistent radar simulation |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## What This Step Will Do |
||||
|
|
||||
|
This change will move you from: |
||||
|
|
||||
|
> ⚠️ Energy-correct but spatially blurred |
||||
|
|
||||
|
to: |
||||
|
|
||||
|
> ✅ Spatially and physically accurate radar |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# 9. Next Phase |
||||
|
|
||||
|
After this: |
||||
|
|
||||
|
👉 CFAR tuning |
||||
|
👉 Multi-target validation |
||||
|
👉 Optional realism (noise, clutter) |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
# FINAL TAKEAWAY |
||||
|
|
||||
|
> The biggest remaining limitation is **early dimensional collapse** |
||||
|
> Fixing that (this step) unlocks **true radar spatial fidelity** |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
**End of Document** |
||||
@ -0,0 +1,76 @@ |
|||||
|
# 🪐 Walkthrough: Radar Metrology Suite (Iteration 18) |
||||
|
|
||||
|
This walkthrough documents the full implementation and verification of the **Radar Metrology Suite**, a major architectural upgrade that exposes the internal signal processing states of the C-SHENRON radar engine for high-fidelity ADAS debugging. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 🚀 1. Overview of Achievements |
||||
|
|
||||
|
The Metrology Suite has successfully transitioned the simulation from generating "Points" to generating a complete **Signal Spectrum**. |
||||
|
|
||||
|
- **Phase 1 (Engine Extraction):** Modified the CA-CFAR and RadarProcessor to capture raw energy matrices. |
||||
|
- **Phase 2 (Visual Pipeline):** Implemented real-time image colormapping (Viridis/Magma/Plasma) and MCAP streaming. |
||||
|
- **Phase 3 (Persistence):** Established a structured hierarchy for raw `.npy` and `.jsonl` telemetry. |
||||
|
- **Phase 4 (Verification):** Completed a 250-frame simulation sweep (Iteration 18) proving system stability. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 📡 2. Visual Diagnostic Capabilities |
||||
|
|
||||
|
We have introduced three new specialized heatmaps, now available as live topics in Foxglove: |
||||
|
|
||||
|
| Topic | Channel | Colormap | Purpose | |
||||
|
| :--- | :--- | :--- | :--- | |
||||
|
| `/radar/heatmaps/range_doppler` | RD Heatmap | **Viridis** | High-contrast view of targets in Velocity vs. Range space. | |
||||
|
| `/radar/heatmaps/range_azimuth` | RA Heatmap | **Magma** | Top-down spatial energy distribution (Bird's Eye View). | |
||||
|
| `/radar/heatmaps/cfar_mask` | Detection Gate| **Plasma** | Visualizes the "Detection Wall" (Noise $\times$ Threshold). | |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 📊 3. Deep Telemetry & Data Structure |
||||
|
|
||||
|
For every frame processed, the system now persists bit-perfect data for offline engineering analysis. |
||||
|
|
||||
|
### Raw Signal Dumps (`metrology/`) |
||||
|
Saved in `Shenron_debug/iterations/<iter_name>/<radar_type>/metrology/`: |
||||
|
- **`rd/*.npy`**: 256x64 Raw Power floating-point matrices. |
||||
|
- **`ra/*.npy`**: 256x256 Angular energy polar-coordinates. |
||||
|
- **`cfar/*.npy`**: The adaptive threshold baseline for that specific frame. |
||||
|
|
||||
|
### Global Metrics (`metrics.jsonl`) |
||||
|
A frame-by-frame log of signal health, including: |
||||
|
- **`peak_snr_db`**: Signal-to-Noise ratio of the strongest target. |
||||
|
- **`avg_noise_floor`**: Estimated environment noise level. |
||||
|
- **`active_bins`**: Number of cells currently "breaking through" the CFAR gate. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 🏁 4. Verification Results (Iteration 18) |
||||
|
|
||||
|
The initial full-scale run of the suite confirmed **Optimal Signal Integrity**: |
||||
|
- **Peak SNR:** ~15.3 dB in peak frames (Confirmed by `metrics.jsonl`). |
||||
|
- **Processing Performance:** 16.63 Frames/Sec (Streaming images + PCD logic). |
||||
|
- **GPU Acceleration:** Confirmed active on `cuda:0:0`. |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
## 🛠️ 5. How to Use & Debug |
||||
|
|
||||
|
### Launching the Metrology Suite |
||||
|
To run a new iteration with full metrology extraction: |
||||
|
```powershell |
||||
|
cmd /c "C:\ProgramData\miniconda3\Scripts\activate.bat carla312 && python scripts/test_shenron.py --iter <your_name>" |
||||
|
``` |
||||
|
|
||||
|
### Signal Verification Utility |
||||
|
Use the specialized verification tool to check a single frame's signal chain: |
||||
|
```powershell |
||||
|
cmd /c "C:\ProgramData\miniconda3\Scripts\activate.bat carla312 && python scripts/analysis/verify_metrology_logic.py" |
||||
|
``` |
||||
|
|
||||
|
--- |
||||
|
|
||||
|
> [!IMPORTANT] |
||||
|
> **Engineering Note:** The RA Heatmap uses a 1D Angle-FFT reduction across all Doppler bins. This provides a spatial "snapshot" that ignores velocity, making it ideal for checking multipath and ghosting against the ground-truth LiDAR map. |
||||
|
|
||||
|
*Verified by Antigravity | Date: 2026-04-08* |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue