Files
2nd/10_Wiki/Topics/AI_and_ML/Dynamic-Environment-Handling.md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +09:00

242 lines
7.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
id: wiki-2026-0508-dynamic-environment-handling
title: Dynamic Environment Handling
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [dynamic environment, AV dynamic obstacles, MOT, scene flow, motion forecasting]
duplicate_of: none
source_trust_level: A
confidence_score: 0.92
verification_status: applied
tags: [autonomous-driving, robotics, perception, motion-forecasting, mot, dynamic-objects]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: Python / C++
framework: Apollo / Autoware / NuScenes
---
# Dynamic Environment Handling
## 매 한 줄
> **"매 static map 의 X — 매 moving object + 매 changing scene 의 reason"**. 매 autonomous driving 의 critical: 매 vehicle, pedestrian, cyclist, weather, occlusion. 매 modern: 매 transformer-based motion forecasting (Waymo MotionLM, Apollo).
## 매 핵심
### 매 problem
- **Static**: 매 building, lane.
- **Dynamic**: 매 vehicle, pedestrian, weather, occlusion.
- **Challenge**: 매 prediction + uncertainty.
### 매 pipeline
1. **Detection**: 매 3D bbox / pointcloud cluster.
2. **Tracking** (MOT): 매 ID 의 frame 의 maintain.
3. **Prediction**: 매 future trajectory.
4. **Planning**: 매 prediction 의 incorporate.
### 매 method
- **Detection**: PointPillars, CenterPoint, BEVFusion.
- **MOT**: SORT, DeepSORT, ByteTrack, JDE.
- **Prediction**: VectorNet, MTR, MotionLM, Wayformer.
- **Joint**: 매 perception + prediction unified.
### 매 modern AI
- **End-to-end**: 매 sensor → trajectory.
- **Transformer**: 매 multi-agent attention.
- **Diffusion forecasting**: 매 multi-modal future.
- **Foundation model**: 매 driving simulator (DriveGPT).
### 매 응용
1. **Autonomous driving**: 매 highway + urban.
2. **Robotics**: 매 mobile robot.
3. **Drone**: 매 obstacle avoid.
4. **AR**: 매 dynamic occlusion.
5. **Sports analytics**: 매 player tracking.
## 💻 패턴
### MOT (ByteTrack-style)
```python
class ByteTrack:
def __init__(self, high_thresh=0.5, low_thresh=0.1):
self.tracks = []
self.high = high_thresh
self.low = low_thresh
def update(self, detections):
# 매 1. high-conf 의 match (Hungarian + IoU)
high_dets = [d for d in detections if d.score > self.high]
matched_high, unmatched_tracks = match_iou(self.tracks, high_dets)
# 매 2. unmatched track + low-conf det 의 match (recover)
low_dets = [d for d in detections if self.low < d.score <= self.high]
matched_low, _ = match_iou(unmatched_tracks, low_dets)
# 매 3. update + new track
for t, d in matched_high + matched_low:
t.update(d)
for d in [d for d in high_dets if d not in matched]:
self.tracks.append(Track(d))
```
### Kalman filter (track state)
```python
class TrackKF:
def __init__(self, init_bbox):
# 매 state: [x, y, vx, vy, w, h]
self.x = np.array([*init_bbox.center, 0, 0, init_bbox.w, init_bbox.h])
self.P = np.eye(6) * 10
self.F = np.eye(6); self.F[0, 2] = self.F[1, 3] = 1 # 매 dt=1
self.H = np.eye(4, 6)
self.Q = np.eye(6) * 0.1
self.R = np.eye(4) * 1
def predict(self):
self.x = self.F @ self.x
self.P = self.F @ self.P @ self.F.T + self.Q
def update(self, measurement):
z = np.array([*measurement.center, measurement.w, measurement.h])
y = z - self.H @ self.x
S = self.H @ self.P @ self.H.T + self.R
K = self.P @ self.H.T @ np.linalg.inv(S)
self.x += K @ y
self.P = (np.eye(6) - K @ self.H) @ self.P
```
### Motion forecasting (Vector-style)
```python
class MotionPredictor(nn.Module):
"""매 simplified VectorNet."""
def __init__(self, hidden=64):
super().__init__()
self.poly_enc = nn.Linear(6, hidden) # 매 polyline encoder
self.attn = nn.MultiheadAttention(hidden, 4)
self.decoder = nn.Linear(hidden, 60) # 매 30 timesteps × (x,y)
def forward(self, polylines):
# 매 polylines: [B, N, T, 6] (x, y, vx, vy, type, idx)
B, N, T, _ = polylines.shape
feats = self.poly_enc(polylines).max(dim=2).values # 매 [B, N, hidden]
attn_out, _ = self.attn(feats, feats, feats)
ego_feat = attn_out[:, 0] # 매 ego 의 first
return self.decoder(ego_feat).reshape(B, 30, 2)
```
### Multi-modal prediction (Gaussian mixture)
```python
class MultiModalPredictor(nn.Module):
def __init__(self, K=6, T=30):
super().__init__()
self.K = K
self.head_mean = nn.Linear(64, K * T * 2)
self.head_var = nn.Linear(64, K * T * 2)
self.head_pi = nn.Linear(64, K)
def forward(self, feat):
means = self.head_mean(feat).reshape(-1, self.K, 30, 2)
vars = self.head_var(feat).exp().reshape(-1, self.K, 30, 2)
pi = self.head_pi(feat).softmax(-1)
return means, vars, pi
```
### Risk-aware planning
```python
def safe_speed(predicted_trajectories, ego_path, dt=0.1):
"""매 prediction 의 risk 의 minimum 의 follow."""
min_safe_v = float('inf')
for t in range(30):
for traj in predicted_trajectories:
if intersects(ego_path[t], traj[t], radius=2.0):
tt = t * dt
if tt > 0:
min_safe_v = min(min_safe_v, ego_path[t].dist / tt)
return min_safe_v
```
### Occlusion handling
```python
def handle_occlusion(tracks, current_dets, max_age=10):
for t in tracks:
if not t.matched:
t.age += 1
if t.age > max_age:
t.delete()
else:
# 매 predict-only mode
t.kf.predict()
t.is_visible = False
return [t for t in tracks if not t.deleted]
```
### Weather degradation handling
```python
def adapt_to_weather(sensor_data, weather):
if weather == 'rain':
# 매 lidar noise ↑ → 매 detection threshold ↑
return {'detection_threshold': 0.7, 'fusion_weight_camera': 0.3}
elif weather == 'fog':
# 매 camera 의 unreliable
return {'detection_threshold': 0.6, 'fusion_weight_camera': 0.1}
return {'detection_threshold': 0.5, 'fusion_weight_camera': 0.5}
```
### CARLA simulation (test rig)
```python
import carla
client = carla.Client('localhost', 2000)
world = client.get_world()
settings = world.get_settings()
settings.synchronous_mode = True
settings.fixed_delta_seconds = 0.05
world.apply_settings(settings)
# 매 spawn dynamic actors
for spawn_point in world.get_map().get_spawn_points()[:50]:
bp = world.get_blueprint_library().find('vehicle.tesla.model3')
actor = world.try_spawn_actor(bp, spawn_point)
if actor: actor.set_autopilot(True)
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Highway | Long-horizon (5s) prediction |
| Urban | Multi-agent + intent |
| Pedestrian | Short-horizon, multi-modal |
| Heavy occlusion | Long max_age, predict-only |
| Adverse weather | Sensor fusion reweight |
| Real-time | <100ms latency budget |
**기본값**: 매 BEV detection + ByteTrack + transformer multi-modal predict + risk-aware plan.
## 🔗 Graph
- 부모: [[Autonomous-Driving]]
- 변형: [[Motion-Forecasting]]
- 응용: [[Apollo]]
- Adjacent: [[End-to-End-Driving]]
## 🤖 LLM 활용
**언제**: 매 AV planning. 매 robot mobile. 매 dynamic scene.
**언제 X**: 매 static map only. 매 stationary robot.
## ❌ 안티패턴
- **Single-modal predict**: 매 future 의 multi modes 의 ignore.
- **Track without filter**: 매 noise.
- **Fixed weather config**: 매 degradation 의 adapt X.
- **Detection without ID**: 매 association 의 lose.
- **No occlusion handling**: 매 ghost track.
## 🧪 검증 / 중복
- Verified (NuScenes, Waymo Open, MOTChallenge).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-04-20 | Auto-reinforced |
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — MOT + prediction + 매 ByteTrack / KF / VectorNet / risk plan code |