-
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.
- Loading branch information
Showing
4 changed files
with
86 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
add_subdirectory(clock) | ||
add_subdirectory(custom_collection_adapter) | ||
add_subdirectory(dna) | ||
add_subdirectory(shared_recording) | ||
add_subdirectory(minimal) | ||
add_subdirectory(spawn_viewer) | ||
add_subdirectory(custom_collection_adapter) | ||
|
||
add_custom_target(examples) | ||
|
||
add_dependencies(examples example_clock) | ||
add_dependencies(examples example_custom_collection_adapter) | ||
add_dependencies(examples example_dna) | ||
add_dependencies(examples example_shared_recording) | ||
add_dependencies(examples example_minimal) | ||
add_dependencies(examples example_spawn_viewer) | ||
add_dependencies(examples example_custom_collection_adapter) |
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,32 @@ | ||
cmake_minimum_required(VERSION 3.16...3.27) | ||
|
||
# If you use the example outside of the Rerun SDK you need to specify | ||
# where the rerun_c build is to be found by setting the `RERUN_CPP_URL` variable. | ||
# This can be done by passing `-DRERUN_CPP_URL=<path to rerun_sdk_cpp zip>` to cmake. | ||
if(DEFINED RERUN_REPOSITORY) | ||
add_executable(example_shared_recording main.cpp) | ||
rerun_strict_warning_settings(example_shared_recording) | ||
else() | ||
project(example_shared_recording LANGUAGES CXX) | ||
|
||
add_executable(example_shared_recording main.cpp) | ||
|
||
# Set the path to the rerun_c build. | ||
set(RERUN_CPP_URL "https://github.com/rerun-io/rerun/releases/latest/download/rerun_cpp_sdk.zip" CACHE STRING "URL to the rerun_cpp zip.") | ||
option(RERUN_FIND_PACKAGE "Whether to use find_package to find a preinstalled rerun package (instead of using FetchContent)." OFF) | ||
|
||
if(RERUN_FIND_PACKAGE) | ||
find_package(rerun_sdk REQUIRED) | ||
else() | ||
# Download the rerun_sdk | ||
include(FetchContent) | ||
FetchContent_Declare(rerun_sdk URL ${RERUN_CPP_URL}) | ||
FetchContent_MakeAvailable(rerun_sdk) | ||
endif() | ||
|
||
# Rerun requires at least C++17, but it should be compatible with newer versions. | ||
set_property(TARGET example_shared_recording PROPERTY CXX_STANDARD 17) | ||
endif() | ||
|
||
# Link against rerun_sdk. | ||
target_link_libraries(example_shared_recording PRIVATE rerun_sdk) |
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,27 @@ | ||
--- | ||
title: Shared Recording | ||
python: https://github.com/rerun-io/rerun/tree/latest/examples/python/shared_recording/main.py | ||
rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/shared_recording/src/main.rs | ||
cpp: https://github.com/rerun-io/rerun/tree/latest/examples/cpp/shared_recording/main.cpp | ||
--- | ||
|
||
<picture> | ||
<img src="https://static.rerun.io/shared_recording/c3da85f1d4c158b8c7afb6bd3278db000b58049d/full.png" alt=""> | ||
<source media="(max-width: 480px)" srcset="https://static.rerun.io/shared_recording/c3da85f1d4c158b8c7afb6bd3278db000b58049d/480w.png"> | ||
<source media="(max-width: 768px)" srcset="https://static.rerun.io/shared_recording/c3da85f1d4c158b8c7afb6bd3278db000b58049d/768w.png"> | ||
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/shared_recording/c3da85f1d4c158b8c7afb6bd3278db000b58049d/1024w.png"> | ||
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/shared_recording/c3da85f1d4c158b8c7afb6bd3278db000b58049d/1200w.png"> | ||
</picture> | ||
|
||
This example demonstrates how to use `RecordingId`s to create a single shared recording across multiple processes. | ||
|
||
To build it from a checkout of the repository (requires a Rust toolchain): | ||
```bash | ||
cmake . | ||
cmake --build . --target example_shared_recording | ||
``` | ||
|
||
Run the following multiple times, and you'll see that each invocation adds data to the existing recording rather than creating a new one: | ||
```bash | ||
./examples/cpp/shared_recording/example_shared_recording | ||
``` |
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,22 @@ | ||
#include <unistd.h> | ||
#include <iostream> | ||
#include <sstream> | ||
|
||
#include <rerun.hpp> | ||
#include <rerun/demo_utils.hpp> | ||
|
||
using rerun::demo::grid3d; | ||
|
||
int main() { | ||
const auto rec = | ||
rerun::RecordingStream("rerun_example_shared_recording", "my_shared_recording"); | ||
rec.spawn().exit_on_failure(); | ||
|
||
int pid = getpid(); | ||
std::ostringstream oss; | ||
oss << "Hello from " << pid; | ||
|
||
rec.log("updates", rerun::TextLog(oss.str())); | ||
|
||
std::cout << "Run me again to append more data to the recording!" << std::endl; | ||
} |