Skip to content

Commit 96d7c9c

Browse files
committed
Initial ZED workspace
0 parents  commit 96d7c9c

35 files changed

Lines changed: 7136 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: "17 6 * * *"
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
jobs:
17+
check:
18+
name: Check against copper-rs master
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
submodules: recursive
25+
26+
- name: Install Rust
27+
uses: dtolnay/rust-toolchain@stable
28+
29+
- name: Check
30+
run: cargo check -p cu-zed --all-targets --features zed-rerun-demo

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target/
2+
/Cargo.lock

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "components/libs/zed_sdk_sys/vendor/zed-c-api"]
2+
path = components/libs/zed_sdk_sys/vendor/zed-c-api
3+
url = https://github.com/stereolabs/zed-c-api.git

Cargo.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[workspace]
2+
members = [
3+
"components/libs/zed_sdk",
4+
"components/libs/zed_sdk_sys",
5+
"components/sources/cu_zed",
6+
]
7+
default-members = ["components/sources/cu_zed"]
8+
resolver = "2"
9+
10+
[workspace.package]
11+
version = "0.15.0"
12+
authors = ["Guillaume Binet <gbin@gootz.net>"]
13+
edition = "2024"
14+
rust-version = "1.95"
15+
license = "Apache-2.0"
16+
keywords = ["robotics", "middleware", "copper", "real-time"]
17+
categories = ["science::robotics"]
18+
homepage = "https://github.com/copper-project"
19+
repository = "https://github.com/copper-project/zed"
20+
21+
[workspace.dependencies]
22+
cu29 = { git = "https://github.com/copper-project/copper-rs.git", branch = "master" }
23+
cu29-logviz = { git = "https://github.com/copper-project/copper-rs.git", branch = "master" }
24+
cu-sensor-payloads = { git = "https://github.com/copper-project/copper-rs.git", branch = "master" }
25+
cu-transform = { git = "https://github.com/copper-project/copper-rs.git", branch = "master" }
26+
27+
bincode = { package = "cu-bincode", version = "2.0", default-features = false, features = [
28+
"derive",
29+
"alloc",
30+
] }
31+
serde = { version = "1.0", default-features = false, features = [
32+
"derive",
33+
"alloc",
34+
] }
35+
36+
bytemuck = "1.23.0"
37+
cc = "1.2"
38+
eframe = "0.33"
39+
rerun = { version = "0.31", default-features = false, features = [
40+
"sdk",
41+
"server",
42+
"log",
43+
] }

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# zed
2+
3+
Small Copper workspace for Stereolabs ZED stereo camera integration.
4+
5+
This repository contains:
6+
7+
- `components/sources/cu_zed`: the Copper source task and depth-to-pointcloud task
8+
- `components/libs/zed_sdk`: safe Rust wrapper for the Stereolabs ZED C API
9+
- `components/libs/zed_sdk_sys`: raw FFI crate and optional vendored `zed-c-api` wrapper
10+
11+
The Copper dependencies intentionally track the `master` branch of
12+
`copper-project/copper-rs`.
13+
14+
## Checks
15+
16+
```bash
17+
just check
18+
```
19+
20+
The check target initializes the `zed-c-api` submodule when needed and runs the
21+
same `cargo check` command used by CI. A machine without the proprietary ZED SDK
22+
can still type-check the Rust crates; final binaries that link the native ZED
23+
libraries need the SDK installed under `/usr/local/zed` or `/opt/zed-sdk`.
24+
25+
The full crate docs live in `components/sources/cu_zed/README.md`.

components/libs/zed_sdk/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

components/libs/zed_sdk/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "zed-sdk"
3+
version.workspace = true
4+
authors.workspace = true
5+
edition.workspace = true
6+
rust-version.workspace = true
7+
license.workspace = true
8+
description = "Safe Rust wrapper for the Stereolabs ZED C API"
9+
readme = "README.md"
10+
repository.workspace = true
11+
12+
[lib]
13+
path = "src/lib.rs"
14+
15+
[[bin]]
16+
name = "zed_viz_demo"
17+
path = "src/bin/zed_viz_demo.rs"
18+
19+
[dependencies]
20+
eframe = { workspace = true }
21+
zed-sdk-sys = { path = "../zed_sdk_sys" }
22+
23+
[package.metadata.cargo-shear]
24+
ignored = []

components/libs/zed_sdk/README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# zed-sdk
2+
3+
Safe Rust bindings for the Stereolabs ZED C API.
4+
5+
This crate wraps the low-level `sl_zed_c` interface in a typed Rust API for:
6+
7+
- opening a camera, SVO file, stream, or GMSL source
8+
- grabbing image and depth frames into typed matrices
9+
- reading calibration, camera, and sensor metadata
10+
- keeping an escape hatch to the raw FFI through `zed_sdk::sys`
11+
12+
## Requirements
13+
14+
- Linux
15+
- the proprietary ZED SDK installed under `/usr/local/zed` or `/opt/zed-sdk`
16+
- a working CUDA/ZED runtime suitable for your camera and chosen depth mode
17+
18+
The sibling `zed-sdk-sys` crate links against an installed `libsl_zed_c` if it is already present.
19+
If that wrapper is not installed yet, the build script can compile the vendored `zed-c-api` wrapper with CMake instead.
20+
21+
If you need the vendored wrapper path, initialize the submodule from the repository root:
22+
23+
```bash
24+
git submodule update --init --recursive components/libs/zed_sdk_sys/vendor/zed-c-api
25+
```
26+
27+
## Basic Use
28+
29+
```rust,ignore
30+
use zed_sdk::{Camera, Mat, OpenOptions, ResolutionPreset, Rgba8, RuntimeParameters};
31+
32+
let options = OpenOptions::default()
33+
.camera_device_id(0)
34+
.resolution(ResolutionPreset::Hd720)
35+
.fps(30);
36+
37+
let mut camera = Camera::open(options)?;
38+
let resolution = camera.resolution()?;
39+
let runtime = RuntimeParameters::default();
40+
let mut left = Mat::<Rgba8>::new_cpu(resolution)?;
41+
42+
camera.grab(&runtime)?;
43+
camera.retrieve_left(&mut left)?;
44+
45+
let view = left.view()?;
46+
println!("captured {}x{}", view.width(), view.height());
47+
# Ok::<(), zed_sdk::Error>(())
48+
```
49+
50+
`Mat<T>` keeps the element type explicit, so color, depth, and point-cloud buffers stay aligned with the SDK view or measure you request.
51+
52+
## Running The Demo
53+
54+
The crate includes `zed_viz_demo`, an `egui` viewer that overlays clipped depth on the left image feed.
55+
56+
From this directory:
57+
58+
```bash
59+
cargo run --release --bin zed_viz_demo -- PERFORMANCE
60+
```
61+
62+
Supported depth mode arguments are:
63+
64+
- `NONE`
65+
- `PERFORMANCE`
66+
- `QUALITY`
67+
- `ULTRA`
68+
- `NEURAL_LIGHT`
69+
- `NEURAL`
70+
- `NEURAL_PLUS`
71+
72+
Convenience targets are also available:
73+
74+
```bash
75+
just performance
76+
just neural-light
77+
just neural
78+
```
79+
80+
`just` defaults to `neural-light`.
81+
82+
## Raw FFI Access
83+
84+
If you need an SDK entry point that is not wrapped yet, use `zed_sdk::sys` directly and keep the safe layer for everything else.

components/libs/zed_sdk/justfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
default:
2+
just neural-light
3+
4+
performance:
5+
cargo run --release -- PERFORMANCE
6+
7+
neural-light:
8+
cargo run --release -- NEURAL_LIGHT
9+
10+
neural:
11+
cargo run --release -- NEURAL

0 commit comments

Comments
 (0)