Skip to main content

Module init

Module init 

Source
Expand description

Phase 212.L.5 — top-level init API.

Re-exported flat at the crate root: nros::init(), nros::init_with_launch_auto(), nros::init_with_launch(path), nros::init_with_args(args), nros::Context, nros::InitError. Phase 212.L.5 — top-level init API.

Three patterns are supported (per the Phase 212.L canonical pkg shape):

  1. Node pkg — register via the nros::node! macro (Phase 172 W.3); the generated runtime owns the spin loop.
  2. Application pkg + launch-aware — call init_with_launch_auto (or init_with_launch for an explicit path). The returned Context carries launch-resolved fields (domain id, locator, RMW choice). User code drives its own spin via Executor::open + Executor::spin_blocking.
  3. Application pkg + custom spin — call init() (or init_with_args for argv-style overrides). Launch file is ignored; env vars + ExecutorConfig::from_env() semantics still apply.

The Context struct is a thin holder of the resolved init knobs. To actually open a session, materialise an crate::ExecutorConfig via Context::config and pass it to Executor::open.

§Launch overlay (current limitation)

init_with_launch_auto / init_with_launch currently consume the launch-resolved knobs the parent nros launch process exports via env vars (ROS_DOMAIN_ID, NROS_LOCATOR, NROS_SESSION_MODE, RMW_IMPLEMENTATION, plus the placeholder NROS_RUNTIME_OVERLAY for the future structured overlay path). The launch XML is NOT parsed in-process; the runtime trusts the launcher to project the relevant params / remaps / env into the child environment. A follow-up wave wires the structured overlay (Option A — nros launch --emit-runtime-overlay → JSON sidecar consumed here). See Phase 212.L.5 notes.

Structs§

Context
Phase 212.L.5 — resolved init context.

Enums§

ContextSource
Where the Context came from. Diagnostics only.
InitError
Errors returned by the init API.

Functions§

init
Pattern 3 — raw init, launch file ignored.
init_with_args
Pattern 3 — like init but accepts a [--arg=value, ...]-style argv iterator. Currently a thin wrapper over init that ignores the args; the structured argv parse (--ros-args -p foo:=42, etc.) lands with the runtime-overlay wave.
init_with_launch
Pattern 2 — explicit-path variant of init_with_launch_auto.
init_with_launch_auto
Pattern 2 — launch-aware init.