Skip to content

feat(cosim): optional seconds_stopped in set_agent_states - #581

Open
01Dami23 wants to merge 1 commit into
Emerge-Lab:yvonne/cosim_3.0from
01Dami23:damiano/cosim-seconds-stopped-setter
Open

feat(cosim): optional seconds_stopped in set_agent_states#581
01Dami23 wants to merge 1 commit into
Emerge-Lab:yvonne/cosim_3.0from
01Dami23:damiano/cosim-seconds-stopped-setter

Conversation

@01Dami23

Copy link
Copy Markdown

What:

  • Add an optional seconds_stopped array to c_set_agent_states (+ its binding and the Drive.set_agent_states wrapper) that injects each agent's stopped-time as external state. NULL / None keeps c_step's own per-tick accumulation.
  • Expose AGENT_STOPPED_SPEED_THRESHOLD to Python (mirrors MAX_SPEED / ACCEL_LONG_NORM) so co-sim callers read the threshold instead of hardcoding it when computing seconds_stopped.
  • Unit test covering both branches (NULL preserves, array overwrites).

Why:

  • When a co-sim overwrites an agent's kinematics every tick instead of letting PufferDrive simulate it, c_step derives seconds_stopped from the dummy/injected rollout speed at env.dt, not the true external speed at the real tick rate. For CARLA/nuplan the ego is PufferDrive-simulated (only background is injected), so their ego is unaffected; a caller that injects the ego itself needs to own the field. Injecting it also removes the partner/parked-slot staleness (the existing TODO(hack)).

Notes:

  • Backward compatible: every current caller passes no seconds_stopped (Python default None -> C NULL), so behavior is unchanged.

What:
- Add an optional `seconds_stopped` array to c_set_agent_states (+ its binding
  and the Drive.set_agent_states wrapper) that injects each agent's stopped-time
  as external state. NULL / None keeps c_step's own per-tick accumulation.
- Expose AGENT_STOPPED_SPEED_THRESHOLD to Python (mirrors MAX_SPEED /
  ACCEL_LONG_NORM) so co-sim callers read the threshold instead of hardcoding it.
- Unit test covering both branches (NULL preserves, array overwrites).

Why:
- When a co-sim overwrites an agent's kinematics every tick instead of letting
  PufferDrive simulate it, c_step derives seconds_stopped from the dummy/injected
  rollout speed at env.dt, not the true external speed at the real tick rate. For
  CARLA/nuplan the ego is PufferDrive-simulated (only background is injected), so
  their ego is unaffected; a caller that injects the ego itself needs to own the
  field. Injecting it also removes the partner/parked-slot staleness (the
  existing TODO(hack)).

Notes:
- Backward compatible: every current caller passes no seconds_stopped (Python
  default None -> C NULL), so behavior is unchanged.
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.

1 participant