pub trait CrowdObserver {
// Required method
fn observe(&mut self, agent_id: AgentId, ped: &Pedestrian);
}Expand description
Per-agent post-step observation hook.
Invoked by step_scratch_store_observed after the model has
finished the tick and the updated state has been written back to
the store, so ped reflects the post-tick position, velocity, and
destination. Closes the P1 “telemetry hooks” item from
docs/rustsim-crowd.md: downstream code can forward each row into
the workspace’s TelemetryPipeline::push_row, write it to a CSV
logger, update a live heatmap, or compute rolling flow-density
statistics — without rustsim-crowd itself taking a dependency on
any sink implementation.
The trait is blanket-implemented for every FnMut(AgentId, &Pedestrian), so in practice callers pass a closure:
step_scratch_store_observed(
&SocialForceModel, &mut store, &walls, ¶ms, dt,
&mut scratch, &mut peds_buf,
|id, ped| pipeline.push_row(&[tick.into(), id.into(),
ped.pos[0].into(), ped.pos[1].into(),
ped.vel[0].into(), ped.vel[1].into()])?,
);Implementations must not panic on valid inputs; the observer is called inside the tick loop and a panic aborts the whole tick.
Required Methods§
Sourcefn observe(&mut self, agent_id: AgentId, ped: &Pedestrian)
fn observe(&mut self, agent_id: AgentId, ped: &Pedestrian)
Observe the post-tick state of one pedestrian.