Adding support to viz logs for all agents#449
Open
mpragnay wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new CONTROL_NONE control mode intended to enable full trajectory log replay visualization for all agents (including ego) by ignoring policy actions and replaying logged trajectories.
Changes:
- Added
CONTROL_NONE = 4in the C drive runtime and expanded “log replay” checks to include it. - Wired
"control_none"string → integer control mode indrive.py. - Updated
render_scenario.pyusage text to mention the new mode.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
scripts/render_scenario.py |
Documents control_none as an option for visualization. |
pufferlib/ocean/drive/drive.py |
Maps "control_none" to control mode 4 and updates validation error text. |
pufferlib/ocean/drive/drive.h |
Defines CONTROL_NONE, treats it as replay for actor selection, and routes active agents through move_expert when enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
3221
to
3225
| // In REPLAY mode, determine which agents to control | ||
| bool is_log_replay = (env->control_mode == CONTROL_SDC_ONLY); | ||
| bool is_log_replay = (env->control_mode == CONTROL_SDC_ONLY || env->control_mode == CONTROL_NONE); | ||
| // In log-replay mode, no cap on actors | ||
| int max_agents = is_log_replay ? env->num_total_agents : env->num_max_agents; | ||
|
|
Comment on lines
5076
to
5084
| for (int i = 0; i < env->expert_static_agent_count; i++) { | ||
| int expert_idx = env->expert_static_agent_indices[i]; | ||
| move_expert(env, env->actions, expert_idx); | ||
| } | ||
| // Move active agents with policy actions | ||
| // Move active agents with policy actions (or expert log if CONTROL_NONE) | ||
| for (int i = 0; i < env->active_agent_count; i++) { | ||
| env->logs[i].score = 0.0f; | ||
| env->logs[i].episode_length += 1; | ||
| int agent_idx = env->active_agent_indices[i]; |
Comment on lines
254
to
+260
| elif self.control_mode_str == "control_sdc_only": | ||
| self.control_mode = 3 | ||
| elif self.control_mode_str == "control_none": | ||
| self.control_mode = 4 | ||
| else: | ||
| raise ValueError( | ||
| "control_mode must be one of 'control_vehicles', 'control_agents', 'control_wosac', or " | ||
| f"'control_sdc_only'. Got: {self.control_mode_str}" | ||
| f"control_mode must be one of 'control_vehicles', 'control_agents', 'control_wosac', 'control_none', or 'control_sdc_only'. Got: {self.control_mode_str}" |
Comment on lines
5084
to
+5089
| int agent_idx = env->active_agent_indices[i]; | ||
| move_dynamics(env, i, agent_idx); | ||
| // move_expert(env, env->actions, agent_idx); | ||
| if (env->control_mode == CONTROL_NONE) { | ||
| move_expert(env, env->actions, agent_idx); | ||
| } else { | ||
| move_dynamics(env, i, agent_idx); | ||
| } |
97ff529 to
3645ad0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add control_none mode for full log replay visualization
Adds a new CONTROL_NONE control mode that replays all agents (including the ego vehicle) from logged trajectories, with no policy applied.
Previously, control_sdc_only only replayed non-ego agents while the ego was policy-controlled.
Changes:
move_dynamics when mode is CONTROL_NONE