From a734692b6090e7fab2ab096cee2c5cd589a9ff5a Mon Sep 17 00:00:00 2001 From: cesar Date: Tue, 8 Sep 2026 09:10:53 -0300 Subject: [PATCH] update the build to dora 1.0 and a shell-free build command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dora 1.0 runs a node's build command directly rather than through a shell, so the mkdir/cd/&& sequence in dataflow.yml could not work. Move it to scripts/build.sh and invoke that instead. Default CMAKE_BUILD_TYPE to Release so DoraTargets.cmake picks the release cargo profile and the binary does not link debug dora bindings. Pin the dataflow source with tag: — 1.0 replaced git_checkout with the mutually exclusive tag/rev/branch. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Y7g2cBJ5e3r15ZbJ9WZn8c --- AGENTS.md | 11 +++++++---- CMakeLists.txt | 6 ++++++ Dockerfile | 2 +- README.md | 15 ++++++++++++--- dataflow.yml | 4 ++-- scripts/build.sh | 14 ++++++++++++++ 6 files changed, 42 insertions(+), 10 deletions(-) create mode 100755 scripts/build.sh diff --git a/AGENTS.md b/AGENTS.md index 310a548..b5c9da8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,12 +9,14 @@ A dora-rs C++ node that interfaces with ZED stereo cameras. On each tick it grab ## Build ```bash -mkdir -p build && cd build && cmake .. && make install +scripts/build.sh ``` -The binary is installed to `bin/dora_zed` relative to the repo root. +The binary is installed to `bin/dora_zed` relative to the repo root. The script is also +the dataflow's `build:` command: dora 1.0 executes build commands directly rather than +through a shell, so `cd`, `&&` and command substitution do not work there. -**Requirements:** CMake 3.21+, ZED SDK 5.x (at `/usr/local/zed`), CUDA Toolkit, ONNX Runtime 1.20+ (system install), Rust stable toolchain (for dora-rs C++ bindings). +**Requirements:** dora 1.0+ (verified with `dora-cli 1.0.1`), CMake 3.21+, ZED SDK 5.x (at `/usr/local/zed`), CUDA Toolkit, ONNX Runtime 1.20+ (system install), Rust stable toolchain (for dora-rs C++ bindings). The first build clones dora-rs from GitHub and compiles `dora-node-api-cxx` via Cargo. This takes a while. Subsequent builds are incremental. If `DORA_ROOT_DIR` is set to a local dora checkout, it builds against that instead. @@ -40,7 +42,8 @@ Camera and detection behavior is configured entirely through environment variabl - **`src/engines/yolo_onnx.h/cc`** — `engines::YoloOnnx` / `YoloOnnxConfig`: closed-vocabulary detection for any single-input YOLO ONNX model (YOLOv8, YOLOv11, YOLOv5, etc.). Auto-detects output layout (`NC_FIRST` / `NC_LAST` / `NC_LAST_OBJ`) from tensor shape; override with `ZED_ONNX_OUTPUT_FORMAT`. Labels loaded from `ZED_ONNX_LABELS` or `ZED_ONNX_LABELS_FILE`. - **`src/main.cc`** — Dora event loop. Selects engine via `ZED_ENGINE` env var (`yolo_onnx`/`onnx` or `native`), holds a `std::unique_ptr`. Parses `ZED_PC_MODE` (`FULL`/`HALF`/`ROI`) once before the loop. On any input event (intended to be driven by a tick timer; the id is not inspected): calls `camera.grab()` and `detector->detect()`, then sends `image_bgr`, `point_cloud`, `camera_info`, and `objects` outputs. Point cloud output varies by mode: `FULL` sends the raw `sl::Mat` pointer (no copy); `HALF` downsamples by 2 in each dimension; `ROI` emits only valid points within detected bounding boxes as a flat `[N, 4]` array. Handles reconnection on grab failure. - **`DoraTargets.cmake`** — Handles building or fetching dora-rs and generating the CXX bridge files. Two paths: local (`DORA_ROOT_DIR`) or git clone. Produces `dora_node_api_cxx` library and the `node_bridge.cc` glue. -- **`dataflow.yml`** — Example dora dataflow definition using the `git:` source format. +- **`scripts/build.sh`** — Configure/compile/install in one shell-free-callable step. Referenced by `dataflow.yml`, the `Dockerfile` and the README. +- **`dataflow.yml`** — Example dora dataflow definition using the `git:` source format, pinned with `tag:` — dora 1.0 pins a source with the mutually exclusive `tag:`, `rev:` or `branch:`. - **`Dockerfile`** — Ubuntu 24.04 x86-64 build environment (CUDA 12.8, ZED SDK 5.2, ONNX Runtime, Rust). No ARM64/Jetson image; build natively there. No camera needed; run the compile with `--gpus all`. Sets `NVIDIA_DRIVER_CAPABILITIES=compute,utility,video` — the `video` capability is what makes the container runtime mount NVDEC/NVENC, which `libsl_zed.so` links against. ONNX Runtime's CMake package files are relocated to `/usr/local/lib/cmake` because Ubuntu's multiarch CMake does not search `lib64`. Rust lives at `/usr/local/{rustup,cargo}` rather than `/root` so the build can run as the invoking user. `docker build -t dora-zed-build . && docker run --rm --gpus all --user "$(id -u):$(id -g)" -v "$PWD:/src" -v dora-zed-cargo:/usr/local/cargo/registry dora-zed-build`. - **`scripts/export_yolo.py`** — PEP 723 uv script. Exports a standard YOLOv11 model to ONNX for closed-vocabulary detection. Run: `uv run scripts/export_yolo.py --model n --output-dir models/`. - **`src/test_yolo_onnx.cc`** — Standalone C++ test binary (`bin/test_yolo_onnx`). Exercises `YoloOnnx` with an image (default `test/assets/yolo.png`). No dora and no live camera required. Uses the same env vars as the main binary. Saves an annotated result image alongside the input. diff --git a/CMakeLists.txt b/CMakeLists.txt index 71f3cd6..3baf07b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,12 @@ project(dora_zed VERSION 0.1.0 LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS "-fPIC") +# DoraTargets.cmake picks the cargo profile from this, so an unset build type +# would link debug dora bindings into an otherwise unoptimized binary. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) +endif() + include(DoraTargets.cmake) set(ZED_DIR "/usr/local/zed" CACHE PATH "Path to the ZED SDK") diff --git a/Dockerfile b/Dockerfile index 2e30c15..b7c0016 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,4 +72,4 @@ RUN curl -fSL -o /tmp/ort.tgz \ ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility,video WORKDIR /src -CMD ["bash", "-lc", "mkdir -p build && cd build && cmake .. && make -j$(nproc) install"] +CMD ["scripts/build.sh"] diff --git a/README.md b/README.md index 2bfe4cf..8a5c825 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ Add to your dataflow: nodes: - id: zed-camera git: ssh://git@gitea.liria.cl:5001/liria/dora-zed.git - git_checkout: v0.1.0 - build: mkdir -p build && cd build && cmake .. && make install + tag: v0.2.0 + build: scripts/build.sh path: bin/dora_zed inputs: tick: dora/timer/millis/100 @@ -28,6 +28,7 @@ See [`dataflow.yml`](dataflow.yml) for a complete runnable example with a camera | Dependency | Version | Notes | |---|---|---| +| [dora-rs](https://github.com/dora-rs/dora) | 1.0+ | Verified against `dora-cli 1.0.1`; the C++ bindings are built from source at configure time | | [CMake](https://cmake.org/download/) | 3.21+ | | | [ZED SDK](https://www.stereolabs.com/developers/release) | 5.x | Bundles OpenCV; default path `/usr/local/zed` | | [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads) | — | Required by ZED SDK | @@ -51,11 +52,17 @@ See [`dataflow.yml`](dataflow.yml) for a complete runnable example with a camera ```bash git clone ssh://git@gitea.liria.cl:5001/liria/dora-zed.git cd dora-zed -mkdir -p build && cd build && cmake .. && make install +scripts/build.sh ``` Binary installed to `bin/dora_zed`. +`scripts/build.sh` is also the `build:` command in the dataflow. dora 1.0 runs build +commands directly rather than through a shell, so `cd`, `&&` and command substitution are +not available there; keeping the sequence in one script is what makes the dataflow build +work. It configures a `Release` build, which is also what links the optimized dora +bindings. + ### Containerized build [`Dockerfile`](Dockerfile) provides the full toolchain — CUDA, ZED SDK, ONNX Runtime and Rust — on Ubuntu 24.04, the newest release Stereolabs ships a ZED SDK for. No camera is needed. @@ -66,6 +73,8 @@ docker run --rm --gpus all --user "$(id -u):$(id -g)" \ -v "$PWD:/src" -v dora-zed-cargo:/usr/local/cargo/registry dora-zed-build ``` +The container runs the same `scripts/build.sh`. + The first run clones dora-rs and compiles it with Cargo; the named volume keeps that cache across runs. `--user` keeps `build/` and `bin/` owned by you rather than root. diff --git a/dataflow.yml b/dataflow.yml index 80dcf14..5d7d4c4 100644 --- a/dataflow.yml +++ b/dataflow.yml @@ -1,8 +1,8 @@ nodes: - id: zed-camera git: ssh://git@gitea.liria.cl:5001/liria/dora-zed.git - git_checkout: v0.1.0 - build: mkdir -p build && cd build && cmake .. && make install + tag: v0.2.0 + build: scripts/build.sh path: bin/dora_zed inputs: tick: dora/timer/millis/100 diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..8eb753a --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Configure, compile and install the node into bin/. +# +# dora 1.0 runs a node's `build:` command directly rather than through a shell, +# so `cd`, `&&` and command substitution are not available there. The whole +# sequence lives here instead, and the dataflow only invokes this script. +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_DIR="$(dirname "$SCRIPT_DIR")" +BUILD_DIR="${REPO_DIR}/build" + +cmake -S "$REPO_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release +cmake --build "$BUILD_DIR" --target install --parallel "$(nproc)"