sim_visualizer¶
sim_visualizer
¶
Scenario visualizer for the bikeped decision testbench.
Renders simulated fisheye camera views of test scenarios showing what the camera would actually see: agents projected through the fisheye model onto a ground-plane wireframe, with decision state overlay.
Camera placement matches index.html presets: - Single pole: (x=5, y=-13, h=5.5), heading 90 deg (facing +y across road) - Cross-cam: add second camera at (x=5, y=+13, h=5.5), heading 270 deg
Usage
python sim_visualizer.py # key scenarios, single cam python sim_visualizer.py --scenarios 1 5 7 # specific scenarios python sim_visualizer.py --two-cam # two-camera split view python sim_visualizer.py --no-save # display only
FisheyeRenderer
¶
FisheyeRenderer(cam_x, cam_y, cam_h, heading_deg, fov_deg=197.9, img_w=640, img_h=480, pitch_deg=None, cx_offset=0.0, cy_offset=0.0)
Thin wrapper around FisheyeCamera for rendering at arbitrary resolution.
Delegates all projection math to FisheyeCamera (decision_testbench.py) so that the simulation visualiser uses the exact same model as the decision testbench and error analysis.
The calibrated 3500x3500 camera is scaled to the render resolution (default 640x480) by adjusting radius_px and optical center proportionally.
Source code in sim_visualizer.py
draw_ground_grid
¶
Draw a ground-plane grid through the fisheye projection.
Source code in sim_visualizer.py
draw_crosswalk
¶
Draw crosswalk stripes at x=5, spanning y=-12 to y=12.
Source code in sim_visualizer.py
draw_agent_3d
¶
Draw an agent as a 3D wireframe box projected through fisheye, oriented along the agent's heading direction.
Source code in sim_visualizer.py
draw_proximity_line
¶
Draw a ground-level line between bike and pedestrian.
Source code in sim_visualizer.py
draw_hud
¶
Draw heads-up display overlay.
Source code in sim_visualizer.py
draw_bev_radar
¶
draw_bev_radar(agents, trail_history, cam_x, cam_y, heading_deg, state, bev_w=200, bev_h=200, max_range=25.0)
Draw a bird's-eye-view radar showing agent positions relative to camera.
The camera's forward direction (heading) points up in the BEV. This matches mqtt_bridge's BEV where the camera is at the origin and forward = +x (displayed as up).
Source code in sim_visualizer.py
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 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
draw_sensor_boundary
¶
Draw horizontal lines showing the physical sensor boundary.
Pixels above the top line and below the bottom line fall outside the 3840x2160 sensor and would not be captured.
Source code in sim_visualizer.py
draw_error_vector
¶
Draw an error vector from true to observed position on the ground plane.
Source code in sim_visualizer.py
render_camera_frame
¶
render_camera_frame(renderer, agents, trail_history, prox_max, scenario_name, t, duration, state, danger, cam_label='', cam_x=0.0, cam_y=0.0, heading_deg=90.0, error_data=None)
Render one frame from a single camera's perspective with BEV radar.
If error_data is provided (list of dicts with true_x/y, obs_x/y, err_m), draws error vectors from true to observed positions.
Source code in sim_visualizer.py
render_scenario
¶
render_scenario(scenario, scenario_idx, params_name='optimized', fps=30, save=True, display=True, two_cam=False, cam_height=None, cam_pitch=None, show_errors=False)
Render a scenario from the fisheye camera perspective.
If show_errors is True, computes and visualizes fisheye bbox localization error for each agent, runs the pipeline on the observed (error-perturbed) positions, and saves all per-frame observation data to a JSON sidecar file.
Source code in sim_visualizer.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | |