-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose batch APIs for linestrips (#2822)
### What Although batch linestrips have been supported by our data-model, we didn't have an API for logging them as such. This adds two new APIs: - `log_line_strips_2d` and `log_line_strips_3d` While being explicit about 2d vs 3d is not consistent with our existing python API surface, it drastically simplifies the error handling around type-inference in cases of empty lists, and iterables. Given our future-looking APIs will also be explicit about APIs, this departure seems like a reasonable compromise. Tested with: ``` rr.log_line_strips_3d( "simple", [ [ [0, 0, 2], [1, 0, 2], [1, 1, 2], [0, 1, 2], ], [ [0, 0, 0], [0, 0, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1], [0, 1, 0], [0, 1, 1], ], ], identifiers=[17, 42], colors=[[255, 0, 0], [0, 255, 0]], stroke_widths=[0.05, 0.2], ) ``` ![image](https://github.com/rerun-io/rerun/assets/3312232/aa6a2ac5-97cd-4fca-816e-6ceb7b97da07) ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2822) (if applicable) - [PR Build Summary](https://build.rerun.io/pr/2822) - [Docs preview](https://rerun.io/preview/pr%3Ajleibs%2Fbatch_lines/docs) - [Examples preview](https://rerun.io/preview/pr%3Ajleibs%2Fbatch_lines/examples)
- Loading branch information
Showing
8 changed files
with
306 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,17 @@ | ||
"""Log a batch of 2d line strips.""" | ||
import rerun as rr | ||
|
||
rr.init("linestrip2d", spawn=True) | ||
|
||
rr.log_line_strips_2d( | ||
"batch", | ||
[ | ||
[[0, 0], [2, 1], [4, -1], [6, 0]], | ||
[[0, 3], [1, 4], [2, 2], [3, 4], [4, 2], [5, 4], [6, 3]], | ||
], | ||
colors=[[255, 0, 0], [0, 255, 0]], | ||
stroke_widths=[0.05, 0.01], | ||
) | ||
|
||
# Log an extra rect to set the view bounds | ||
rr.log_rect("bounds", [3, 1.5, 8, 9], rect_format=rr.RectFormat.XCYCWH) |
This file contains 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,28 @@ | ||
"""Log a batch of 3d line strips.""" | ||
import rerun as rr | ||
|
||
rr.init("linestrip3d", spawn=True) | ||
|
||
rr.log_line_strips_3d( | ||
"batch", | ||
[ | ||
[ | ||
[0, 0, 2], | ||
[1, 0, 2], | ||
[1, 1, 2], | ||
[0, 1, 2], | ||
], | ||
[ | ||
[0, 0, 0], | ||
[0, 0, 1], | ||
[1, 0, 0], | ||
[1, 0, 1], | ||
[1, 1, 0], | ||
[1, 1, 1], | ||
[0, 1, 0], | ||
[0, 1, 1], | ||
], | ||
], | ||
colors=[[255, 0, 0], [0, 255, 0]], | ||
stroke_widths=[0.05, 0.01], | ||
) |
This file contains 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 contains 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 contains 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 contains 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 contains 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