Velocity obstacles¶
cuplan.VelocityObstacleSim — decentralized collision avoidance with
velocity obstacles (Fiorini and Shiller 1998, Motion planning in
dynamic environments using velocity obstacles, IJRR 17(7)), mirroring
pymapf.decentralized.velocity_obstacle.
Semantics¶
Each timestep, each agent:
- computes a desired velocity — full speed toward its goal, zero once
within
radius / 5of it; - builds, for every other agent and moving obstacle, a collision cone
widened to
2.2 x radiusand translated by that obstacle's velocity, expressed as two half-planes; - samples candidate velocities on a polar grid (20 angles x 5 speeds by default, as in pymapf), discards samples inside any cone, and takes the feasible sample closest to the desired velocity — or stops when nothing is feasible.
One deliberate difference from pymapf¶
Updates are synchronous: all agents choose against the same snapshot of the world, then move together. pymapf updates agents in registration order within a timestep — earlier agents do not see later ones at all. The synchronous rule is order-independent, which is what makes it parallel, and is the standard formulation of the decentralized problem. Because the two simulators integrate different dynamics, the benchmark reports cuplan CPU vs CUDA only for this family rather than a misleading cross-library wall-clock number.
Parallelization¶
Every (agent, sample) pair is independent — the step is one embarrassingly parallel evaluation:
- CPU reference — one broadcast expression over
(agents, others, samples). - CUDA — one thread per (agent, sample), looping over the others; the per-agent argmin is a device-side reduction.
CPU and CUDA trajectories agree to floating-point tolerance (tested).
Decentralized collision avoidance with velocity obstacles.
Mirrors pymapf.decentralized.velocity_obstacle (Fiorini and Shiller
1998): each agent samples candidate velocities on a polar grid, discards
those inside any neighbour's collision cone — widened to 2.2 x
radius and translated by the neighbour's velocity, expressed as a pair
of half-planes — and takes the feasible sample closest to its desired
velocity toward the goal.
Every (agent, sample) pair is independent: the whole step is one
embarrassingly parallel evaluation, n_agents x n_samples threads on
the CUDA backend, one broadcast expression on the NumPy one.
One deliberate difference from pymapf: updates are synchronous. All agents choose their velocity against the same snapshot of the world, then move together. pymapf updates agents in registration order inside a timestep, so earlier agents ignore later ones; the synchronous rule is order-independent, which is what makes it parallel — and is also the standard formulation of the decentralized problem.
VOResult
dataclass
¶
Trajectories and summary metrics of a velocity-obstacle run.
Source code in cuplan/velocity_obstacles.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
goals_reached ¶
goals_reached(goals, tolerance)
Number of agents ending within tolerance of their goal.
Source code in cuplan/velocity_obstacles.py
44 45 46 47 48 49 | |
min_separation ¶
min_separation()
Smallest pairwise agent distance over the whole run.
Source code in cuplan/velocity_obstacles.py
51 52 53 54 55 56 57 58 59 60 61 62 | |
VelocityObstacleSim ¶
Multi-agent velocity-obstacle simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestep
|
float
|
integration step in seconds. |
0.1
|
radius
|
float
|
agent radius; the collision cone uses |
0.5
|
vmax
|
float
|
maximum speed; also the desired cruise speed toward the goal. |
2.0
|
n_angles
|
int
|
angular resolution of the velocity sample grid. |
20
|
n_speeds
|
int
|
radial resolution of the velocity sample grid. |
5
|
backend
|
Backend
|
|
'auto'
|
pymapf samples 20 angles x 5 speeds; the defaults match.
Source code in cuplan/velocity_obstacles.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
add_agent ¶
add_agent(start, goal)
Register an agent by start and goal position (2D).
Source code in cuplan/velocity_obstacles.py
110 111 112 113 | |
add_obstacle ¶
add_obstacle(position, velocity)
Register a moving obstacle with constant velocity.
Source code in cuplan/velocity_obstacles.py
115 116 117 118 119 120 121 122 | |
run ¶
run(n_steps)
Simulate n_steps timesteps and return the trajectories.
Source code in cuplan/velocity_obstacles.py
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 | |