You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #325 from Emerge-Lab/ricky/merge_conflicts_3.0_beta_and_3.0
- merge 3.0 into 3.0_beta
- resolve conflicts on merge
- adopt resample_maps() refactoring in drive.py
- made the scenario_id string length attached to a constant.
Copy file name to clipboardExpand all lines: docs/src/interact-with-agents.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,30 @@ then launch:
18
18
19
19
This will run `demo()` with an existing model checkpoint.
20
20
21
+
## Arguments & Configuration
22
+
23
+
The `drive` tool supports similar CLI arguments as the visualizer to control the environment and rendering. It also reads the `pufferlib/config/ocean/drive.ini` file for default environment settings.
24
+
25
+
### Command Line Arguments
26
+
27
+
| Argument | Description | Default |
28
+
| :--- | :--- | :--- |
29
+
|`--map-name <path>`| Path to the map binary file (e.g., `resources/drive/binaries/training/map_000.bin`). If omitted, picks a random map out of `num_maps` from `map_dir` in `drive.ini`. | Random |
30
+
|`--policy-name <path>`|`Path to the policy weights file (.bin).`|`resources/drive/puffer_drive_weights.bin`|
31
+
|`--view <mode>`| Selects which views to render: `agent`, `topdown`, or `both`. |`both`|
32
+
|`--frame-skip <n>`| Renders every Nth frame to speed up simulation (framerate remains 30fps). |`1`|
33
+
|`--num-maps <n>`| Overrides the number of maps to sample from if `--map-name` is not set. |`drive.ini` value |
34
+
35
+
### Visualization Flags
36
+
37
+
| Flag | Description |
38
+
| :--- | :--- |
39
+
|`--show-grid`| Draws the underlying nav-graph/grid on the map. |
40
+
|`--obs-only`| Hides objects not currently visible to the agent's sensors (fog of war). |
41
+
|`--lasers`| Visualizes the raycast sensor lines from the agent. |
42
+
|`--log-trajectories`| Draws the ground-truth "human" expert trajectories as green lines. |
43
+
|`--zoom-in`| Zooms the camera mainly on the active region rather than the full map bounds. |
-`control_wosac`: WOSAC evaluation mode (controls all valid agents ignoring expert flag and start to goal distance)
26
26
-`control_sdc_only`: Self-driving car only
27
27
28
28
> [!NOTE]
29
-
> `control_vehicles` filters out agents marked as "expert" and those too close to their goal (<2m). For full WOMD evaluation, use `control_tracks_to_predict`.
29
+
> `control_vehicles` filters out agents marked as "expert" and those too close to their goal (<2m). For full WOMD evaluation, use `control_wosac`.
30
+
31
+
> [!IMPORTANT]
32
+
> **Agent Dynamics:** The simulator supports three types of agents:
33
+
> 1.**Policy-Controlled:** Stepped by your model's actions.
34
+
> 2.**Experts:** Stepped using ground-truth log trajectories.
35
+
> 3.**Static:** Remain frozen in place.
36
+
>
37
+
> In the simulator, agents not selected for policy control will be treated as **Static** by default. To make them follow their **Expert trajectories**, you must set `mark_as_expert=true` for those agents in the jsons. This is critical for `control_sdc_only` to ensure the environment behaves realistically around the policy-controlled agents.
38
+
39
+
### Init modes
40
+
41
+
-**`create_all_valid`** (Default): Initializes every valid agent present in the map file. This includes policy-controlled agents, experts (if marked), and static agents.
42
+
43
+
-**`create_only_controlled`**: Initializes **only** the agents that are directly controlled by the policy.
44
+
45
+
> [!NOTE]
46
+
> In `create_only_controlled` mode, the environment will contain **no static or expert agents**. Only the policy-controlled agents will exist.
@@ -33,11 +33,11 @@ resample_frequency = 100000 # No resampling needed (there are only a few Carla m
33
33
termination_mode = 0 # 0: terminate at episode_length, 1: terminate after all agents reset
34
34
35
35
# Map settings
36
-
map_dir = "resources/drive/binaries/carla"
37
-
num_maps = 2
36
+
map_dir = "resources/drive/binaries"
37
+
num_maps = 2# Number of Carla maps you're training in
38
38
```
39
39
40
-
this should give a good starting point. With these settings, you'll need about 2-3 billion steps to get an agent that reaches most of it's goals (> 95%) and has a combined collsion / off-road rate of 3 % per episode of 300 steps.
40
+
this should give a good starting point. With these settings, you'll need about 2-3 billion steps to get an agent that reaches most of it's goals (> 95%) and has a combined collsion / off-road rate of 3 % per episode of 300 steps in town 1 and 2, which can be found [here](https://github.com/Emerge-Lab/PufferDrive/tree/2.0/data_utils/carla/carla_data). Before launching your experiment, run `drive.py` with the folder to the Carla towns to process them to binaries, then ensure the `map_dir` above is pointed to these binaries.
41
41
42
42
> [!Note]
43
43
> The default training hyperparameters work well for both configurations and typically don't need adjustment.
Copy file name to clipboardExpand all lines: docs/src/visualizer.md
+36-2Lines changed: 36 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,8 +25,8 @@ bash scripts/build_ocean.sh visualize local
25
25
26
26
If you need to force a rebuild, remove the cached binary first (`rm ./visualize`).
27
27
28
-
## Run headless
29
-
Launch the visualizer with a virtual display and export an `.mp4`:
28
+
## Rendering a Video
29
+
Launch the visualizer with a virtual display and export an `.mp4` for the binary scenario:
30
30
31
31
```bash
32
32
xvfb-run -s "-screen 0 1280x720x24" ./visualize
@@ -43,3 +43,37 @@ puffer render puffer_drive
43
43
```
44
44
45
45
This mode parallelizes rendering based on `vec.num_workers`.
46
+
47
+
## Arguments & Configuration
48
+
49
+
The `visualize` tool supports several CLI arguments to control the rendering output. It also reads the `pufferlib/config/ocean/drive.ini` file for default environment settings(For more details on these settings, refer to [Configuration](simulator.md#configuration)).
50
+
51
+
### Command Line Arguments
52
+
53
+
| Argument | Description | Default |
54
+
| :--- | :--- | :--- |
55
+
|`--map-name <path>`| Path to the map binary file (e.g., `resources/drive/binaries/training/map_000.bin`). If omitted, picks a random map out of `num_maps` from `map_dir` in `drive.ini`. | Random |
56
+
|`--policy-name <path>`| Path to the policy weights file (`.bin`). |`resources/drive/puffer_drive_weights.bin`|
57
+
|`--view <mode>`| Selects which views to render: `agent`, `topdown`, or `both`. |`both`|
58
+
|`--output-agent <path>`| Output filename for agent view video. |`<policy>_agent.mp4`|
59
+
|`--output-topdown <path>`| Output filename for top-down view video. |`<policy>_topdown.mp4`|
60
+
|`--frame-skip <n>`| Renders every Nth frame to speed up generation (framerate remains 30fps). |`1`|
61
+
|`--num-maps <n>`| Overrides the number of maps to sample from if `--map-name` is not set. |`drive.ini` value |
62
+
63
+
### Visualization Flags
64
+
65
+
| Flag | Description |
66
+
| :--- | :--- |
67
+
|`--show-grid`| Draws the underlying nav-graph/grid on the map. |
68
+
|`--obs-only`| Hides objects not currently visible to the agent's sensors (fog of war). |
69
+
|`--lasers`| Visualizes the raycast sensor lines from the agent. |
70
+
|`--log-trajectories`| Draws the ground-truth "human" expert trajectories as green lines. |
71
+
|`--zoom-in`| Zooms the camera mainly on the active region rather than the full map bounds. |
72
+
73
+
### Key `drive.ini` Settings
74
+
The visualizer initializes the environment using `pufferlib/config/ocean/drive.ini`. Important settings include:
75
+
76
+
-`[env] dynamics_model`: `classic` or `jerk`. Must match the trained policy.
77
+
-`[env] episode_length`: Duration of the playback. defaults to 91 if set to 0.
78
+
-`[env] control_mode`: Determines which agents are active (`control_vehicles` vs `control_sdc_only`).
79
+
-`[env] goal_behavior`: Defines agent behavior upon reaching goals (respawn vs stop).
*Table: WOSAC baselines in PufferDrive on 229 selected clean held-out validation scenarios.*
64
64
65
-
66
-
> ✏️ Download the dataset from [Hugging Face](https://huggingface.co/datasets/daphne-cornelisse/pufferdrive_wosac_val_clean) to reproduce these results or benchmark your policy.
*Table: WOSAC baselines in PufferDrive on validation 10k dataset.*
77
-
78
-
79
-
> ✏️ Download the dataset from [Hugging Face](https://huggingface.co/datasets/daphne-cornelisse/pufferdrive_womd_val) to reproduce these results or benchmark your policy.
65
+
-**Random agent:** Following the [WOSAC 2023 paper](https://arxiv.org/abs/2305.12032), the random agent samples future trajectories by independently sampling (x, y, θ) at each timestep from a Gaussian distribution in the AV coordinate frame `(mu=1.0, sigma=0.1)`, producing uncorrelated random motion over the horizon of 80 steps.
66
+
-**Goal-conditioned self-play RL agent**: An agent trained through self-play RL to reach the end point points ("goals") without colliding or going off-road. Baseline can be reproduced using the default settings in the `drive.ini` file with the Waymo dataset. We also open-source the weights of this policy, see `pufferlib/resources/drive/puffer_drive_weights``.bin` and `.pt`.
80
67
81
68
69
+
> ✏️ Download the dataset from [Hugging Face](https://huggingface.co/datasets/daphne-cornelisse/pufferdrive_wosac_val_clean) to reproduce these results or benchmark your policy.
0 commit comments