decision_pipeline¶
decision_pipeline
¶
Shared decision pipeline for the bikeped collision-warning system.
This module is imported by both mqtt_bridge.py (deployed system) and decision_testbench.py (offline analysis). Any change here applies to both.
Designed for the Jetson AGX Orin: no heavy imports, no allocations in the hot path, numpy used only for sqrt.
DecisionPipeline
¶
DecisionPipeline(bike_memory_frames=77, prox_min=0.5, prox_max=20.7, prox_speed_min=0.098, lookback_frames=1, max_range=25.0, speed_adaptive=True, cyclist_reaction_s=0.84, cyclist_decel_ms2=1.96, fps=30, decision_rule='pairwise', ttc_threshold_s=3.0)
Three-stage decision pipeline: pedestrian presence, cyclist memory, closing proximity with speed-adaptive bounds.
This class is stateful: it maintains the cyclist memory buffer and per-object track histories across frames. Call reset() between scenarios in offline simulation.
Source code in decision_pipeline.py
update_track
¶
Record a position for a tracked object. Call once per detection.
Source code in decision_pipeline.py
evaluate
¶
Run the three-stage decision pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
persons
|
list of dicts with keys: track_id, x, y. |
required | |
bikes
|
list of dicts with keys: track_id, x, y. |
required | |
bike_in_scene
|
bool, whether any cyclist class is in the current frame. |
required | |
sim_time
|
current time in seconds (for memory expiry). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
state |
one of 'idle', 'safe', 'warning', 'alert'. |
|
alert_pair |
tuple (bike_track_id, ped_track_id) or None. |
Source code in decision_pipeline.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
stopping_distance
¶
Cyclist stopping distance (m).
Default values: 85th-percentile field measurements from Martin & Bigazzi (2025) for conventional bicycles responding to unexpected hazards (n=302).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
speed_ms
|
cyclist ground speed in m/s. |
required | |
reaction_s
|
cyclist perception-reaction time (s). |
0.84
|
|
decel_ms2
|
comfortable braking deceleration (m/s^2). |
1.96
|