-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "spawn" variants for Quick Start guides (#3912)
### What By default, the Quick Start guides show instructions that will send a recording to the current viewer. This is only possible if the viewer accepts TPC connection (which is not the case of Web-based viewers). This PR adds a varient for the guides that will instead spawn a local viewer whenever TCP connections aren't accepted. * Fixes #3871 In a connection-accepting viewer: <img width="1291" alt="image" src="https://github.com/rerun-io/rerun/assets/49431240/f4ffbb87-c01c-412f-b0b5-ac2df5c16bb8"> In a web viewer: <img width="1185" alt="image" src="https://github.com/rerun-io/rerun/assets/49431240/c5106daa-babb-4bbd-9c30-3a2aee9c59c5"> ### 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/3912) (if applicable) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG - [PR Build Summary](https://build.rerun.io/pr/3912) - [Docs preview](https://rerun.io/preview/5d04ce8296947cab55c1373990037f7266a5834c/docs) <!--DOCS-PREVIEW--> - [Examples preview](https://rerun.io/preview/5d04ce8296947cab55c1373990037f7266a5834c/examples) <!--EXAMPLES-PREVIEW--> - [Recent benchmark results](https://ref.rerun.io/dev/bench/) - [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
- Loading branch information
Showing
16 changed files
with
203 additions
and
28 deletions.
There are no files selected for viewing
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
File renamed without changes.
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,3 @@ | ||
## C++ Quick Start | ||
|
||
TODO(ab): https://github.com/rerun-io/rerun/issues/3870 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## Python Quick Start | ||
|
||
${SAFARI_WARNING} | ||
|
||
### Installing the Rerun SDK | ||
|
||
The Rerun SDK is available on [PyPI](https://pypi.org/) under the | ||
[`rerun-sdk`](https://pypi.org/project/rerun-sdk/) name. It can be installed like any other | ||
Python package: | ||
|
||
```sh | ||
pip install rerun-sdk | ||
``` | ||
|
||
### Try out the viewer | ||
|
||
The Rerun SDK comes with a demo that can be used to try the viewer. You can spawn a native viewer and load a demo using the following command: | ||
|
||
```sh | ||
python -m rerun_sdk | ||
``` | ||
|
||
This will open a new recording that looks like this: | ||
|
||
![Demo recording](https://static.rerun.io/quickstart2_simple_cube/632a8f1c79f70a2355fad294fe085291fcf3a8ae/768w.png) | ||
|
||
|
||
### Logging your own data | ||
|
||
Instead of a pre-packaged demo, you can log your own data. Copy and paste the following snippet in a new Python file and execute it to create a recording in a new viewer: | ||
|
||
```python | ||
${EXAMPLE_CODE} | ||
``` | ||
|
||
${HOW_DOES_IT_WORK} |
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 @@ | ||
../../../../docs/code-examples/quick_start_spawn.cpp |
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 @@ | ||
../../../../docs/code-examples/quick_start_spawn.py |
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 @@ | ||
../../../../docs/code-examples/quick_start_spawn.rs |
File renamed without changes.
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,35 @@ | ||
## Rust Quick Start | ||
|
||
${SAFARI_WARNING} | ||
|
||
### Installing Rerun | ||
|
||
To use the Rerun SDK in your project, you need the [rerun crate](https://crates.io/crates/rerun) which you can add with `cargo add rerun`. | ||
|
||
Let's try it out in a brand-new Rust project: | ||
|
||
```sh | ||
cargo init cube && cd cube && cargo add rerun --features native_viewer | ||
``` | ||
|
||
Note that the Rerun SDK requires a working installation of Rust 1.72+. | ||
|
||
### Logging your own data | ||
|
||
Add the following code to your `main.rs` file: | ||
|
||
```rust | ||
${EXAMPLE_CODE} | ||
``` | ||
|
||
You can now run your application: | ||
|
||
```shell | ||
cargo run | ||
``` | ||
|
||
Once everything finishes compiling, a new viewer will start displaying these points: | ||
|
||
![Demo recording](https://static.rerun.io/intro_rust_result/cc780eb9bf014d8b1a68fac174b654931f92e14f/768w.png) | ||
|
||
${HOW_DOES_IT_WORK} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// TODO(ab): https://github.com/rerun-io/rerun/issues/3870 | ||
|
||
int main() { | ||
return 0; | ||
} |
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,24 @@ | ||
"""Spawn a viewer and log some data.""" | ||
|
||
import numpy as np | ||
import rerun as rr | ||
|
||
# Initialize the SDK, give our recording a unique name, and spawn a viewer | ||
rr.init("rerun_example_demo", spawn=True) | ||
|
||
# Create some data | ||
SIZE = 10 | ||
|
||
pos_grid = np.meshgrid(*[np.linspace(-10, 10, SIZE)] * 3) | ||
positions = np.vstack([d.reshape(-1) for d in pos_grid]).T | ||
|
||
col_grid = np.meshgrid(*[np.linspace(0, 255, SIZE)] * 3) | ||
colors = np.vstack([c.reshape(-1) for c in col_grid]).astype(np.uint8).T | ||
|
||
# Log the data | ||
rr.log( | ||
# name under which this entity is logged (known as "entity path") | ||
"my_points", | ||
# log data as a 3D point cloud archetype | ||
rr.Points3D(positions, colors=colors, radii=0.5), | ||
) |
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,26 @@ | ||
//! Spawn a viewer and log some data. | ||
use rerun::{demo_util::grid, external::glam}; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// Create a new `RecordingStream` which stores data in memory. | ||
let (rec, storage) = rerun::RecordingStreamBuilder::new("rerun_example_minimal_rs").memory()?; | ||
|
||
// Create some data using the `grid` utility function. | ||
let points = grid(glam::Vec3::splat(-10.0), glam::Vec3::splat(10.0), 10); | ||
let colors = grid(glam::Vec3::ZERO, glam::Vec3::splat(255.0), 10) | ||
.map(|v| rerun::Color::from_rgb(v.x as u8, v.y as u8, v.z as u8)); | ||
|
||
// Log the "my_points" entity with our data, using the `Points3D` archetype. | ||
rec.log( | ||
"my_points", | ||
&rerun::Points3D::new(points) | ||
.with_colors(colors) | ||
.with_radii([0.5]), | ||
)?; | ||
|
||
// Show the viewer with the recorded data. | ||
rerun::native_viewer::show(storage.take())?; | ||
|
||
Ok(()) | ||
} |
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