Skip to content

Adding support to viz logs for all agents#449

Open
mpragnay wants to merge 1 commit into
emerge/temp_trainingfrom
pragnay/support_to_visualize_logs
Open

Adding support to viz logs for all agents#449
mpragnay wants to merge 1 commit into
emerge/temp_trainingfrom
pragnay/support_to_visualize_logs

Conversation

@mpragnay
Copy link
Copy Markdown

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:

  • drive.h: define CONTROL_NONE = 4, fix is_log_replay checks to include CONTROL_NONE, route active agents through move_expert instead of
    move_dynamics when mode is CONTROL_NONE
  • drive.py: wire "control_none" string to the new constant
  • render_scenario.py: document control_none in the script's usage header

Copilot AI review requested due to automatic review settings May 27, 2026 22:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = 4 in the C drive runtime and expanded “log replay” checks to include it.
  • Wired "control_none" string → integer control mode in drive.py.
  • Updated render_scenario.py usage 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);
}
@mpragnay mpragnay force-pushed the pragnay/support_to_visualize_logs branch from 97ff529 to 3645ad0 Compare May 30, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants