Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/gallery.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ title: 效果展示
![鬼探头](img/scenario_occluded_crossing.gif)
<div align="center"><i>occluded_crossing(鬼探头)播放 6 秒:自车制动停止,行人从遮挡车尾横穿(红圈为行人,12 帧,0.5 秒/帧;底部为口语输入与命中模板)</i></div>

![借道超车遇对向来车](img/scenario_overtake_oncoming.gif)
<div align="center"><i>overtake_oncoming(借道超车遇对向来车)播放 8 秒:借对向车道超车 → 对向车接近 → 放弃超车回原车道(红圈为对向车,黄圈为慢车,11 帧;底部为口语输入与命中模板)</i></div>

![运行指标](img/scenario_run_metrics.gif)
<div align="center"><i>运行危险度指标:右上角实时显示自车速度、与行人距离与 TTC,末帧汇总碰撞/最小中心距/最小 TTC/最大减速度/末速</i></div>

Expand Down
Binary file added docs/img/scenario_overtake_oncoming.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions docs/new-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,78 @@ title: New Features

---

## 2026-11 · 借道超车遇对向来车场景

本版新增 `overtake_oncoming` 模板:自车借对向车道超越前方慢车,
对向有车驶来时放弃超车、减速并回到原车道。同时修正了播放器
"借对向车道变道后车头掉转 180°"的问题。

### 1. 用法

```text
借对向车道超车时对面有车驶来,只好放弃超车
超车到一半发现对向来车,赶紧回到原车道
```

语义层把 `超车遇对向来车`、`超车遇来车`、`放弃超车`、`对向有车驶来`
等说法路由到该模板;输入同时含"超车"和"对向"时额外加权,
避免落到只演示变道超越的 `overtake`。

```python
plan_scenario("超车到一半发现对向来车,赶紧回到原车道")
# → {"template": "overtake_oncoming", "confidence": 1.0, ...}
```

### 2. 场景编排

自车 20 m 处起步、12 m/s,前方 45 m 处慢车 7 m/s,对向车道 170 m 外
一辆 11 m/s 的车驶来。2 s 后自车借对向车道超车;双方中心距缩到 55 m 时,
自车在同一时刻触发两个动作:回到原车道、减速到 7 m/s。

| 时刻 | 事件 |
|---|---|
| 0 s | 自车 12 m/s、慢车 7 m/s、对向车 11 m/s 同时起步 |
| 2.0 s | 自车向左变道,进入对向车道开始超车 |
| 距对向车 55 m | 放弃超车:回原车道 + 线性减速 |
| 约 7.0 s | 自车回到原车道,跟在前车后方 |
| 约 7.4 s | 对向车从左侧驶过,无碰撞 |

参数:`ego_speed`、`lead_speed`、`gap`、`oncoming_speed`、`oncoming_gap`、
`lc_delay`、`abort_gap`,均可通过 `params_json` 覆盖。

### 3. 效果

![借道超车遇对向来车](img/scenario_overtake_oncoming.gif)
<div align="center"><i>overtake_oncoming:借左车道超车 → 对向车接近 → 放弃超车回原车道(红圈为对向车,黄圈为慢车,11 帧)</i></div>

### 4. 修正:借对向车道变道后掉头

播放器变道收尾时按**目标车道**的名义朝向对齐车头。对向车道的名义朝向
与自车相差 180°,于是自车刚并到对向车道就被转成反向行驶。
现改为:目标车道朝向与变道前的行驶方向夹角超过 90° 时,保留原行驶方向,
只在同一行驶方向内做收尾对齐。本次回归中自车全程保持 +x 行驶,
不再掉头。

### 5. 实测结果

| 项目 | 结果 |
|---|---|
| 离线回归(17 个模板) | 全部通过,3 实体 / 5 事件 |
| CARLA 实跑(`wide_straight`) | 5 个事件全部触发,5.15 s 放弃超车,约 7.0 s 回到原车道,无碰撞 |
| 会车最小中心距 | 3.41 m(t=7.65 s,相邻对向车道正常会车) |
| 最大减速度 | 6.02 m/s² |
| 语义识别 | `超车遇对向来车`、`放弃超车` 均命中 `overtake_oncoming` |

### 6. 已知限制

- 播放器的 TTC 只按纵向距离与相对速度计算,不区分车道;会车瞬间
两车横向相距 3.5 m,TTC 仍会接近 0,不代表碰撞风险。
- `abort_return` 的变道方向 `+1` 针对 `wide_straight` 的车道编号
(+1 车道需向中心线方向回到 -1),换用其他路网时需确认车道号方向。
- 既有 `overtake` 模板的回车道动作仍用 `-1`,在该路网上会走到更外侧
的车道;本版未改动该模板,留待单独修复。
---

## 2026-11 · 运行危险度指标

场景回放此前只给截图和事件,能看出“发生了什么”,但看不出“危险到什么程度”。
Expand Down
32 changes: 31 additions & 1 deletion docs/scenario.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ graph LR
|---|---|---|---|
| `file_path` | string | 必填 | 待校验的 `.xosc` 文件 |

## 3. 16 个场景模板
## 3. 17 个场景模板

| 模板 | 场景含义 | 实体数 | 主要触发 |
|---|---|---|---|
Expand All @@ -52,6 +52,7 @@ graph LR
| `junction_light` | 路口信号冲突 | 3 | 时间、速度、距离 |
| `close_follow` | 近距跟驰(TTC 触发减速) | 2 | TTC |
| `overtake` | 超车(变道 + 相对速度) | 3 | 时间、距离、到达 |
| `overtake_oncoming` | 借道超车遇对向来车 | 3 | 时间、相对距离 |
| `evasive_swerve` | 紧急避让(轨迹跟随) | 3 | 时间 |
| `signal_phase` | 红绿灯相位(红灯等待→切绿→起步) | 2 | 信号灯、时间 |

Expand Down Expand Up @@ -79,6 +80,35 @@ graph LR
与 `crossing_hazard` 的区别是多了遮挡车辆,且横穿起点位于停放车辆后方,
自车的反应距离更短。

### 3.2 借道超车遇对向来车 `overtake_oncoming`

双向直路上,自车以 12 m/s 接近前方 7 m/s 的慢车,2 s 后借对向车道开始超车;
对向车道有一辆 11 m/s 的车驶来。双方距离缩到 55 m 时,自车放弃超车,
回到原车道并线性减速到慢车速度,最终跟在前车后方,无碰撞。

```text
借对向车道超车时对面有车驶来,只好放弃超车
超车到一半发现对向来车,赶紧回到原车道
```

![借道超车遇对向来车](img/scenario_overtake_oncoming.gif)
<div align="center"><i>overtake_oncoming:借左车道超车 → 对向车接近 → 放弃超车回原车道(红圈为对向车,黄圈为慢车,11 帧)</i></div>

| 参数 | 默认 | 说明 |
|---|---|---|
| `ego_speed` | 12 m/s | 自车超车速度 |
| `lead_speed` | 7 m/s | 前方慢车速度 |
| `gap` | 45 m | 自车与慢车的初始距离 |
| `oncoming_speed` | 11 m/s | 对向车速度 |
| `oncoming_gap` | 170 m | 对向车与自车的初始距离 |
| `lc_delay` | 2.0 s | 开始借道超车的时刻 |
| `abort_gap` | 55 m | 放弃超车、回到原车道的相对距离阈值 |

触发用的是**相对距离**:`oncoming` 与自车的中心距小于 `abort_gap` 时,
同一时刻触发两个动作——自车回原车道、自车减速到 `lead_speed`。
与 `overtake` 的区别是多了对向车的存在与"放弃超车"的判定,
`overtake` 只演示变道超越,不处理会车冲突。

## 4. 对话示例

```text
Expand Down
Loading