Skip to main content

nros/guide/
configuration.rs

1//! # Configuration
2//!
3//! ## Runtime environment variables
4//!
5//! [`ExecutorConfig::from_env()`](crate::ExecutorConfig::from_env) reads these at startup:
6//!
7//! | Variable | Description | Default |
8//! |----------|-------------|---------|
9//! | `ROS_DOMAIN_ID` | ROS 2 domain ID | `0` |
10//! | `ZENOH_LOCATOR` | Router address (`tcp/…`, `udp/…`, or `tls/…`) | `tcp/127.0.0.1:7447` |
11//! | `ZENOH_MODE` | Session mode: `client` or `peer` | `client` |
12//! | `ZENOH_TLS_ROOT_CA_CERTIFICATE` | Path to CA certificate (PEM) | — |
13//! | `ZENOH_TLS_ROOT_CA_CERTIFICATE_BASE64` | Base64-encoded CA cert (bare-metal) | — |
14//!
15//! ## Buffer tuning (build-time)
16//!
17//! Set these environment variables **before** `cargo build`.  After
18//! changing a value, run `cargo clean -p zpico-sys` (or `xrce-sys`) to
19//! force a rebuild.
20//!
21//! **Zenoh backend (`ZPICO_*`):**
22//!
23//! | Variable | Description | Posix | Embedded |
24//! |----------|-------------|-------|----------|
25//! | `ZPICO_FRAG_MAX_SIZE` | Max reassembled message size | 65536 | 2048 |
26//! | `ZPICO_BATCH_UNICAST_SIZE` | Max unicast batch before fragmentation | 65536 | 1024 |
27//! | `ZPICO_BATCH_MULTICAST_SIZE` | Max multicast batch size | 8192 | 1024 |
28//! | `ZPICO_SUBSCRIBER_BUFFER_SIZE` | Per-subscriber buffer in zenoh shim | 1024 | 1024 |
29//! | `ZPICO_SERVICE_BUFFER_SIZE` | Per-service-server buffer in zenoh shim | 1024 | 1024 |
30//!
31//! **XRCE-DDS backend (`XRCE_*`):**
32//!
33//! | Variable | Description | Posix | Embedded |
34//! |----------|-------------|-------|----------|
35//! | `XRCE_TRANSPORT_MTU` | Transport MTU (also sizes stream buffers) | 4096 | 512 |
36//! | `XRCE_BUFFER_SIZE` | Per-entity static buffer size | 1024 | 1024 |
37//! | `XRCE_STREAM_HISTORY` | Reliable stream history depth (>= 2) | 4 | 4 |
38//!
39//! **Core (`NROS_*`, C API only):**
40//!
41//! | Variable | Description | Default |
42//! |----------|-------------|---------|
43//! | `NROS_EXECUTOR_MAX_HANDLES` | Max handles in C API executor | 16 |
44//! | `NROS_MAX_SUBSCRIPTIONS` | Max subscriptions | 8 |
45//! | `NROS_MAX_TIMERS` | Max timers | 8 |
46//! | `NROS_MAX_SERVICES` | Max services | 4 |
47//! | `NROS_MESSAGE_BUFFER_SIZE` | Max buffer for subscription/service data | 4096 |
48//! | `NROS_MAX_PARAMETERS` | Max parameters in parameter server | 32 |
49//!
50//! Example — increase zenoh defrag to 128 KB for large point clouds:
51//!
52//! ```bash
53//! ZPICO_FRAG_MAX_SIZE=131072 cargo build --features rmw-zenoh,platform-posix
54//! ```