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_text
¶
Anti-aliased text via PIL TrueType (with cv2 Hershey fallback).
pos is the top-left corner of the text bounding box; color is BGR.
Falls back to cv2.putText with Duplex when PIL is unavailable.
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=300, bev_h=300, 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
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
draw_sensor_boundary_lines
¶
Draw the horizontal sensor-boundary lines.
Pixels above the top line and below the bottom line fall outside the 3840x2160 sensor and would not be captured. The lines are drawn early so agent labels can sit on top of them.
Source code in sim_visualizer.py
dim_sensor_outside
¶
Dim the regions outside the physical sensor footprint.
Applied after agents so anything drawn outside the captured field of view is visually attenuated.
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
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 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | |