-
Notifications
You must be signed in to change notification settings - Fork 538
Add simple test script for testing out widely branched transform hierarchies #11437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
846f15f
Add simple test script for testing out widely branched transform hier…
Wumpf 93311fa
add missing profiling scope
Wumpf b972e64
py lint, better arg name
Wumpf 93d22f3
Update tests/python/many_entity_transforms/main.py
Wumpf 98fedda
Update tests/python/many_entity_transforms/main.py
Wumpf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
from __future__ import annotations | ||
|
||
import argparse | ||
|
||
import rerun as rr | ||
import rerun.blueprint as rrb | ||
|
||
|
||
def main() -> None: | ||
parser = argparse.ArgumentParser(description="Simple benchmark for many transforms over time & space.") | ||
rr.script_add_args(parser) | ||
|
||
parser.add_argument("--branching-factor", type=int, default=2, help="How many children each node has") | ||
parser.add_argument("--hierarchy-depth", type=int, default=10, help="How many levels of hierarchy we want") | ||
parser.add_argument( | ||
"--transforms-every-n-levels", type=int, default=2, help="At which level in the hierarchies we add transforms" | ||
) | ||
parser.add_argument( | ||
"--num-timestamps", | ||
type=int, | ||
default=100, | ||
help="Number of timestamps to log. Stamps shift for each entity a bit.", | ||
) | ||
parser.add_argument("--transforms-only", action="store_true", help="If set, don't log a point at each leaf") | ||
parser.add_argument( | ||
"--num-views", type=int, default=6, help="Number of 3D views to create (each will use a different origin)" | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
rr.script_setup(args, "rerun_example_benchmark_many_transforms") | ||
rr.set_time("sim_time", duration=0) | ||
|
||
entity_paths = [] | ||
call_id = 0 | ||
|
||
def log_hierarchy(entity_path: str, level: int) -> None: | ||
nonlocal call_id | ||
call_id += 1 | ||
entity_paths.append(entity_path) | ||
|
||
# Add a transform at every 'transforms_every_n_levels' level except root | ||
if level > 0 and level % args.transforms_every_n_levels == 0: | ||
# Add a static transform that has to be combined in to stress the per-timestamp transform resolve. | ||
rr.log( | ||
entity_path, | ||
# Have to be careful to not override all other transforms, therefore, use `from_fields`. | ||
rr.Transform3D.from_fields( # | ||
mat3x3=[ | ||
[1.0 + level * 0.1, 0.0, 0.0], # | ||
[0.0, 1.0 + level * 0.1, 0.0], | ||
[0.0, 0.0, 1.0 + level * 0.1], | ||
] | ||
), | ||
static=True, | ||
) | ||
|
||
# Add a transforms that changes for each timestamp. | ||
for i in range(args.num_timestamps): | ||
call_id_factor = call_id * 0.02 | ||
rr.set_time("sim_time", duration=i + call_id_factor) | ||
rr.log( | ||
entity_path, | ||
rr.Transform3D( | ||
translation=[i * 0.1 * level + call_id_factor, call_id_factor * level, 0.0], | ||
rotation_axis_angle=rr.RotationAxisAngle(axis=(0.0, 1.0, 0.0), degrees=i * 0.1), | ||
), | ||
) | ||
|
||
if level == args.hierarchy_depth: | ||
if not args.transforms_only: | ||
# Log a single point at the leaf | ||
rr.set_time("sim_time", duration=0) | ||
rr.log(entity_path, rr.Points3D([[0.0, 0.0, 0.0]])) | ||
return | ||
|
||
for i in range(args.branching_factor): | ||
child_path = f"{entity_path}/{i}_at_{level}" | ||
log_hierarchy(child_path, level + 1) | ||
|
||
log_hierarchy("root", 0) | ||
|
||
# All views display all entities. | ||
rr.send_blueprint( | ||
rrb.Blueprint( | ||
rrb.Grid( | ||
contents=[rrb.Spatial3DView(origin=path, contents="/**") for path in entity_paths[: args.num_views]] | ||
), | ||
collapse_panels=True, # Collapse panels, so we perf is mostly about the data & the views. | ||
Wumpf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
) | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.