API
Recording
Class representing a continuous traffic observation. Usually corresponds to one omega-prime file.
Internally, the Recording uses a Polars DataFrame to store moving object data. Each row in the DataFrame represents the state of a moving object at a specific timestamp.
Attributes:
| Name | Type | Description |
|---|---|---|
df |
DataFrame
|
Polars DataFrame containing the moving object data. |
map |
MapOsi | MapOsiCenterline | MapOdr | None
|
Map associated with the recording. |
projections |
dict
|
Projection metadata with structure
|
traffic_light_states |
dict
|
Dictionary mapping timestamps to traffic light states. |
host_vehicle_idx |
int | None
|
Index of the host vehicle, if applicable. |
Source code in omega_prime/recording.py
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 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 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 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 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 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 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 | |
__init__(df, map=None, projections=None, host_vehicle_idx=None, validate=False, traffic_light_states=None)
Initialize a Recording instance.
Source code in omega_prime/recording.py
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 | |
apply_projections()
Apply projection transformations to the recording's moving object data based on the provided projection metadata
and the map's projection. This method updates the x, y, and z columns of the recording's DataFrame
according to the specified projections and transforms the coordinates to the target CRS if necessary.
The original coordinates before applying projections are stored in x_original, y_original, and z_original
columns to preserve the original pose information for export or reference.
Source code in omega_prime/recording.py
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 753 754 755 756 757 758 759 760 761 762 763 764 | |
from_file(filepath, map_path=None, validate=False, parse_map=False, step_size=0.01, apply_proj=True, **kwargs)
classmethod
Load a Recording from a file. Supports .parquet, .osi and .mcap files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Path to the input file. |
required |
map_path
|
str | None
|
Optional path to a map file. If None, the map will be loaded from the recording if available. |
None
|
validate
|
bool
|
Whether to validate the data against the schema. |
False
|
parse_map
|
bool
|
Whether to create python objects from the map data or just load it. |
False
|
step_size
|
float
|
Step size for map parsing, if applicable (Used for ASAM OpenDRIVE). |
0.01
|
apply_proj
|
bool
|
Whether to apply projection transformations to the recording's moving object data. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Recording |
Recording
|
The loaded Recording object. |
Source code in omega_prime/recording.py
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 | |
interpolate(new_nanos=None, hz=None)
Interpolate the recording to new timestamps or a given frequency.
Source code in omega_prime/recording.py
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 | |
plot(ax=None, legend=False, mvs_plt_type='scatter')
Generate a static plot of the recording using Matplotlib. Plots the map (if available), moving objects, and traffic light states.
Source code in omega_prime/recording.py
853 854 855 856 857 858 859 860 861 862 863 864 | |
plot_altair(start_frame=0, end_frame=-1, plot_map=True, plot_map_polys=True, metric_column=None, plot_wedges=True, idx=None, height=None, width=None)
Generate an interactive plot of the recording using Altair.
Source code in omega_prime/recording.py
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 | |
plot_frame(frame, ax=None)
Generate a static plot of a specific frame in the recording using Matplotlib.
Source code in omega_prime/recording.py
916 917 918 919 920 | |
plot_mvs(ax=None, legend=False, mvs_plt_type='scatter')
Generate a static plot of the moving objects in the recording using Matplotlib.
Source code in omega_prime/recording.py
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 | |
plot_tl(ax=None)
Generate a static plot of the traffic lights in the recording using Matplotlib.
Source code in omega_prime/recording.py
887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 | |
to_file(filepath)
Store Recording to a file based on its suffix (.parquet, .mcap).
Source code in omega_prime/recording.py
637 638 639 640 641 642 643 644 645 646 | |
to_mcap(filepath)
Store Recording as an MCAP file.
Source code in omega_prime/recording.py
498 499 500 501 502 503 504 505 506 507 508 509 510 | |
to_parquet(filename)
Store Recording as a Parquet file.
Source code in omega_prime/recording.py
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 | |
Map
dataclass
Base class for Map representations
Source code in omega_prime/map.py
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 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 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 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 | |
align_predecessor_and_successor_relations()
Ensure that predecessor and successor relationships between lanes are consistent. If lane A lists lane B as a successor, then lane B should list lane A as a predecessor, and vice versa.
Source code in omega_prime/map.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | |
from_file(filepath, parse_map=True, **kwargs)
classmethod
Create a Map instance from a file.
Source code in omega_prime/map.py
284 285 286 287 288 | |
map_to_centerline_mcap(output_mcap_path=None)
Convert an Map to a MapOsiCenterline and save it as an MCAP file if the output path is provided. It returns the generated GroundTruth object from the generated MapOsiCenterline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_mcap_path
|
Path
|
Path where the MCAP file will be saved |
None
|
Returns: betterosi.GroundTruth: The generated GroundTruth object
Source code in omega_prime/map.py
355 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 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 | |
MapOsi
dataclass
Bases: Map
Map representation based on ASAM OSI GroundTruth
Source code in omega_prime/map.py
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 | |
MapOsiCenterline
dataclass
Bases: Map
Map representation based on ASAM OSI GroundTruth defining only the centerlines of lanes and nothing else. Does not conform to the omega-prime specification for Map.
Source code in omega_prime/map.py
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 | |
split_linestring(line, max_length)
Split a LineString into segments of maximum length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
shapely LineString to split |
required | |
max_length
|
Maximum length of each segment |
required |
Returns:
| Type | Description |
|---|---|
|
List of LineString segments |
Source code in omega_prime/map.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
MapOdr
dataclass
Bases: Map
Source code in omega_prime/map_odr.py
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 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 | |
to_file(filename)
Export the current MapOdr to a .xodr file.
Source code in omega_prime/map_odr.py
302 303 304 305 306 307 308 309 310 311 312 313 314 | |
Locator
dataclass
Source code in omega_prime/locator.py
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 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 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 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 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
get_single_lane_association(traveler_lane_intersections, overlaps=None)
filter traveling path of traveler, so that traveler is not assigned to lanes that are only reachable through a merging or crossing relation return format: road, lane
Source code in omega_prime/locator.py
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 434 435 436 437 438 439 440 441 442 443 444 445 | |
query_centerlines(point, range_percentage=0.1)
Query the nearest centerline and all centerlines within a range percentage.
:param point: A shapely Point object representing the query location. :param range_percentage: The range as a percentage of the total length of the nearest centerline. Default is 0.1 (10%). :return: A NDArray with all the Lane Idx in the Range.
Source code in omega_prime/locator.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | |
get_lane_centerline(right_border, left_border)
middle line between (interpolated) boundaries, oriented in direction of lane
Source code in omega_prime/locator.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
DatasetConverter
Bases: ABC
Source code in omega_prime/converters/converter.py
52 53 54 55 56 57 58 59 60 61 62 63 64 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 | |
get_recording_name(recording)
abstractmethod
Abstract method to get the name for a given recording. The method should be implemented in subclasses to handle specific dataset formats. Args: recording: Recording of any type as returned by get_recordings. Returns: str: unique name of recording.
Source code in omega_prime/converters/converter.py
93 94 95 96 97 98 99 100 101 102 103 | |
get_recordings(source_recording)
abstractmethod
Abstract method to get all recordings in a source-recording-instance of the specific dataset. The method should be implemented in subclasses to handle specific dataset formats. Args: source_recordings: List of the source recordings. Could be of any type as returned by get_source_recordings. Yields: recording: Each recording in the source-recording-instance, one at a time. Could be of any type as further processed in to_omega_prime_recording and get_recording_id.
Source code in omega_prime/converters/converter.py
69 70 71 72 73 74 75 76 77 78 79 | |
get_source_recordings()
abstractmethod
Abstract method to get a list of the source recordings. The method should be implemented in subclasses to handle specific dataset formats. Returns: source_recordings: List of the source recordings. Could be of any type as further processed in get_recordings.
Source code in omega_prime/converters/converter.py
59 60 61 62 63 64 65 66 67 | |
to_omega_prime_recording(recording)
abstractmethod
Abstract method to convert a raw recording into an omega prime recording instance. The method should be implemented in subclasses to handle specific dataset formats. Args: recording: A recording of any type as returned by get_omega_prime_recordings. Returns: Recording: An instance of the Recording class containing the processed data.
Source code in omega_prime/converters/converter.py
81 82 83 84 85 86 87 88 89 90 91 | |
Metric
dataclass
Class to compute metrics based on polars dataframes.
Source code in omega_prime/metrics.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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 | |
compute_func
instance-attribute
The function that actually computes the metric
computes_columns = field(default_factory=list)
class-attribute
instance-attribute
Names of the columns that will be added to the dataframe by this metrics
computes_intermediate_columns = field(default_factory=list)
class-attribute
instance-attribute
Same as computes_columns by these ones will not be returned in the end and are only available to other metrics
computes_intermediate_properties = field(default_factory=list)
class-attribute
instance-attribute
Same as computes_properties but these ones will not be returned in the end and are only available to other metrics.
computes_properties = field(default_factory=list)
class-attribute
instance-attribute
Keys of the tables added to the properties dictionary by this metric
requires_columns = field(default_factory=list)
class-attribute
instance-attribute
Columns that must be present in the dataframe before this metric can be calculated
requires_properties = field(default_factory=list)
class-attribute
instance-attribute
Keys of tables that must be present in the properties dictionary before this metric can be calculated.
MetricManager
dataclass
Source code in omega_prime/metrics.py
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 302 303 304 305 306 307 | |
exclude_columns = field(default_factory=list)
class-attribute
instance-attribute
List of columns computed by the metrics that do not need to be computed
exclude_properties = field(default_factory=list)
class-attribute
instance-attribute
List of tables in the properties dict that do not need to be computed
metrics = field(default_factory=(lambda: metrics))
class-attribute
instance-attribute
List of metrics to compute
distance_traveled(df)
Metric that computes the column distance_traveled
Source code in omega_prime/metrics.py
88 89 90 91 92 93 94 95 96 97 98 | |
metric(computes_columns=None, computes_properties=None, requires_columns=None, requires_properties=None, computes_intermediate_columns=None, computes_intermediate_properties=None)
Decorator to turn a function into a Metric
Source code in omega_prime/metrics.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
p_timegaps_and_min_p_timgaps(df, /, ego_id, crossed, timegaps, time_buffer=2000000000.0)
Metrics that computes a predicted timegap between ego_id and all other objects. time_buffer gives the timespan in which intersection of trajectories is tested. The prediction is based on constant velocity following the same trajectory as observed.
Source code in omega_prime/metrics.py
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 | |
timegaps_and_min_timgaps(df, /, ego_id, time_buffer=2000000000.0)
Metrics that computes timegaps between ego_id and all other objects. time_buffer gives the timespan in which intersection of trajectories is tested
Source code in omega_prime/metrics.py
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 | |
vel(df)
Metric that computes the column length of the speed vecotr vel
Source code in omega_prime/metrics.py
101 102 103 104 105 106 | |
MapSegmentType
Bases: Enum
Classification of MapSegments.
Source code in omega_prime/mapsegment.py
9 10 11 12 13 14 15 16 17 | |
MapSegmentation
Bases: ABC
Abstract base class for map segmentation that handles multiple segments on a single map. Concrete implementations must define how to extract lane-specific information.
Source code in omega_prime/mapsegment.py
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 | |
check_if_all_lanes_are_on_segment()
Checks if all lanes are on a segment. Returns: bool: True if all lanes are on a segment, False otherwise.
Source code in omega_prime/mapsegment.py
216 217 218 219 220 221 222 223 224 225 226 | |
create_lane_dict()
Returns a dictionary mapping each lane's lane_id to the lane object.
Source code in omega_prime/mapsegment.py
197 198 199 200 | |
get_lane_successors_and_predecessors()
Returns dictionaries mapping each lane's lane_id to its successor and predecessor lane indices.
Source code in omega_prime/mapsegment.py
202 203 204 205 206 207 208 209 210 211 212 213 214 | |
Segment
Bases: ABC
A class that represents a segment of the map
Source code in omega_prime/mapsegment.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 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 63 64 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 | |
add_lane(lanes, update_polygon=True)
Adds a lane to the segment. If the lane is already in the segment, it will not be added again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lane
|
list
|
A list of lane objects to be added to the segment. |
required |
Source code in omega_prime/mapsegment.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
create_segment_polygon()
Create the Polygon of the Segment
Source code in omega_prime/mapsegment.py
82 83 84 | |
get_center_point()
Returns the center point of the segment
Source code in omega_prime/mapsegment.py
78 79 80 | |
get_timeinterval_on_segment(roaduser)
Gets a roadsegment as input as well as a roaduser trajectory. Returns the time interval of the roaduser on the segment. roaduser should be a np.array with (total_nanos, x, y)
Source code in omega_prime/mapsegment.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
set_trafficlight()
abstractmethod
Set traffic lights for this segment. Map-type specific.
Source code in omega_prime/mapsegment.py
47 48 49 50 | |
update_polygon()
Updates the Polygon of the Segment
Source code in omega_prime/mapsegment.py
86 87 88 89 | |
ConnectionSegment
Bases: SegmentOsiCenterline
Source code in omega_prime/maposicenterlinesegmentation.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 | |
plot(output_plot)
Plots the Connection segment
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_plot
|
Path
|
Path to the output directory. |
required |
Returns: None
Source code in omega_prime/maposicenterlinesegmentation.py
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 | |
MapOsiCenterlineSegmentation
Bases: MapSegmentation
A class that identifies different segments on a OsiCenterline Map. Concrete implementation of MapSegmentation for OSI centerline maps.
Source code in omega_prime/maposicenterlinesegmentation.py
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 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 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 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 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 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 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 | |
add_non_intersecting_lanes_to_intersection()
Add all lanes that are within the intersection polygon to the intersection object. Args: None Returns: None
Source code in omega_prime/maposicenterlinesegmentation.py
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 | |
combine_intersection_on_polygon(intersection1, intersection2)
Combine two intersections into one if they overlap. Args: intersection1 (Intersection): The first intersection object. intersection2 (Intersection): The second intersection object. Returns: Intersection: The combined intersection object if they overlap, None otherwise.
Source code in omega_prime/maposicenterlinesegmentation.py
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
combine_intersections()
A function that revieves a list with idx [[1,2] , [4,5,6] , ...] of intersections that need to be combined. It will combine all those intersections and will then update all intersections in the map_segmentation class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intersection_list
|
list
|
A list of lists, where each inner list contains the indices of intersections to be combined. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in omega_prime/maposicenterlinesegmentation.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 | |
combine_isolated_connections(isolated_connections)
Check if any of the isolated connections are connecting the same intersections. If yes, then combine them into one connection. Args: isolated_connections (list): A list of ConnectionSegment objects representing isolated connections. Returns: isolated_connections (list): A list of ConnectionSegment objects representing the combined isolated connections.
Source code in omega_prime/maposicenterlinesegmentation.py
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 753 | |
create_intersection_dict()
Creats a dictionary where the key is the intersection id and the value is the intersection object. Args: None Returns: None
Source code in omega_prime/maposicenterlinesegmentation.py
546 547 548 549 550 551 552 553 554 555 556 557 | |
create_lane_segment_dict()
Create a dictionary mapping lane IDs to their segment information. Args: None Returns: lane_segment_dict (dict): A dictionary mapping lane IDs to their segment information.
Source code in omega_prime/maposicenterlinesegmentation.py
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 | |
create_non_intersecting_lane_graph()
Create a graph with each lane which is not part of a intersection as a node and the edges are the successors and predecessors of the lanes. Args: None Returns: G (networkx.Graph): A graph with each lane as a node and the edges are the successors and predecessors of the lanes.
Source code in omega_prime/maposicenterlinesegmentation.py
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | |
create_parallel_lane_dict()
Creates a dictionary mapping each lane's lane_id to the lane ids which are parallel to it Args: None Returns: dict: A dictionary mapping each lane's lane_id to the lane ids which are parallel to it.
Source code in omega_prime/maposicenterlinesegmentation.py
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 | |
find_isolated_connections()
Find all isolated strings of connections in the graph. Then Check if any of those lanes would be part of an intersection. Args: None Returns: isolated_connections (list): A list of lists, where each inner list contains the indices of lanes that are part of an isolated connection.
Source code in omega_prime/maposicenterlinesegmentation.py
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 | |
get_intersecting_lanes(buffer=None)
Returns a dictionary mapping each lane's lane_id to an array of lane ids it intersects with.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lanes
|
list
|
Array of lane objects, each with an |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
A dictionary where keys are lane ids and values are arrays of intersecting lane ids. |
Source code in omega_prime/maposicenterlinesegmentation.py
344 345 346 347 348 349 350 351 352 353 354 355 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 | |
graph_intersection_detection()
Detects intersections in a graph of lanes based on their intersections, successors, and predecessors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lane_dict
|
dict
|
A dictionary where keys are lane indices and values are arrays of intersecting lane indices. |
required |
lane_successors
|
dict
|
A dictionary where keys are lane indices and values are arrays of successor lane indices. |
required |
lane_predecessors
|
dict
|
A dictionary where keys are lane indices and values are arrays of predecessor lane indices. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
A list of intersections, where each intersection is a set of lane indices. |
Source code in omega_prime/maposicenterlinesegmentation.py
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 | |
init_intersections()
Initializes the intersections in the map. Args: None Returns: None
Source code in omega_prime/maposicenterlinesegmentation.py
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 | |
intersections_overlap(intersection1, intersection2, buffer=None)
Check if two intersections overlap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intersection1
|
Intersection
|
The first intersection object. |
required |
intersection2
|
Intersection
|
The second intersection object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if the intersections overlap, False otherwise. |
Source code in omega_prime/maposicenterlinesegmentation.py
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | |
plot(output_plot=None, trajectory=None, plot_lane_ids=False, plot_intersection_polygons=False, plot_connection_polygons=False)
Plots the intersections and saves the plot to the specified output path. A Trajectory can be given to plot it on the map. The Trajectory should be a numpy array of shape (n,3) where each row is (frame, x, y) Args: output_plot (Path): Path to a folder where the plot will be saved. If None, the plot will be shown instead. trajectory (numpy.ndarray): The trajectory to be plotted. If None, no trajectory will be plotted. plot_lane_ids (bool): Whether to plot lane IDs on the map. plot_intersection_polygons (bool): Whether to plot intersection polygons. plot_connection_polygons (bool): Whether to plot connection polygons. Returns: None
Source code in omega_prime/maposicenterlinesegmentation.py
806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 | |
plot_intersections(output_plot)
Plots all intersections and saves them to the output path. Args: output_plot (Path): Path to a folder where the plots will be saved. Returns: None
Source code in omega_prime/maposicenterlinesegmentation.py
919 920 921 922 923 924 925 926 927 928 929 930 | |
set_intersection_idx()
Sets the index for each intersection in the list of intersections. Args: None Returns: None
Source code in omega_prime/maposicenterlinesegmentation.py
535 536 537 538 539 540 541 542 543 544 | |
set_lane_intersection_relation()
Sets the attribute lane.is_approaching true if the lane is connecting to an intersection. Sets the attribute lane.on_intersection true if the lane is part of an intersection.
Source code in omega_prime/maposicenterlinesegmentation.py
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | |
set_lane_trafficlights()
Sets the traffic lights for each lane of the map.
Source code in omega_prime/maposicenterlinesegmentation.py
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 | |
trajectory_segment_detection(trajectory)
Splits a trajectory into segments based on the lane it is located on
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trajectory
|
ndarray
|
A NumPy array of shape (n, 3) representing the trajectory, where each row is a (frame, x, y) coordinate. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
A list of tuples, where each tuple contains a segment of the trajectory and the segment it intersects with. |
Source code in omega_prime/maposicenterlinesegmentation.py
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 337 338 339 340 341 342 | |
update_road_ids()
Updates the road_ids of the lane to the segment ID
Source code in omega_prime/maposicenterlinesegmentation.py
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 | |
update_segment_ids()
Updates the segment IDs of the map segmentation
Source code in omega_prime/maposicenterlinesegmentation.py
222 223 224 225 226 227 | |
SegmentOsiCenterline
Bases: Segment
Segment implementation for OSI centerline-based maps.
Source code in omega_prime/maposicenterlinesegmentation.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
add_lanexy_to_graph(G, lanes)
Adds lane coordinates to the graph as node attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
G
|
Graph
|
The graph to which lane coordinates will be added. |
required |
lanes
|
dict
|
A dictionary of lane objects. |
required |
Returns:
| Type | Description |
|---|---|
|
networkx.Graph: The updated graph with lane coordinates as node attributes. |
Source code in omega_prime/maposicenterlinesegmentation.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
plot_graph(G, output)
Plots the graph with lane coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
G
|
Graph
|
The graph to be plotted. |
required |
Path
|
str or Path
|
The file path to save the plot. |
required |
Source code in omega_prime/maposicenterlinesegmentation.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |