Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Advanced Configuration

Generating Config Files

ros-z can generate JSON5 config files matching rmw_zenoh_cpp defaults. This is opt-in via the generate-configs feature flag.

Basic Generation

cargo build --features generate-configs

Output location:

target/debug/build/ros-z-*/out/ros_z_config/
  ├── DEFAULT_ROSZ_ROUTER_CONFIG.json5
  └── DEFAULT_ROSZ_SESSION_CONFIG.json5

Custom Output Directory

Specify a custom directory using the ROS_Z_CONFIG_OUTPUT_DIR environment variable:

Absolute path:

ROS_Z_CONFIG_OUTPUT_DIR=/etc/zenoh cargo build --features generate-configs

Relative path (from package root):

ROS_Z_CONFIG_OUTPUT_DIR=./config cargo build --features generate-configs

From workspace root:

ROS_Z_CONFIG_OUTPUT_DIR=$PWD/config cargo build -p ros-z --features generate-configs

Tip

Generated files include inline comments explaining each setting, making them perfect documentation references.

Using Generated Files

let ctx = ZContextBuilder::default()
    .with_config_file("./config/DEFAULT_ROSZ_SESSION_CONFIG.json5")
    .build()?;

Configuration Reference

Key Settings Explained

SettingRouterSessionPurpose
ModerouterpeerRouter relays messages, peers connect directly
Listen Endpointtcp/[::]:7447-Router accepts connections
Connect Endpoint-tcp/localhost:7447Session connects to router
MulticastDisabledDisabledUses TCP gossip for discovery
Unicast Timeout60s60sHandles slow networks/large deployments
Query Timeout10min10minLong-running service calls
Max Sessions10,000-Supports concurrent node startup
Keep-Alive2s2sOptimized for loopback

Note

These defaults are tuned for ROS 2 deployments and match rmw_zenoh_cpp exactly. Only modify them if you have specific performance requirements.