pub fn init_with_args<I, S>(args: I) -> Result<Context, InitError>Expand description
Pattern 3 — like init() but takes the process arguments, the way
rclcpp::init(argc, argv) / rclrs’s Context::new(args, ..) do. The
free-function twin of Context::new with default options.
§What it does with the arguments
It parses --ros-args with rcl’s grammar (Humble rcl/arguments.h): ROS
arguments live between --ros-args and -- (or the end), several scopes
may appear, and everything outside them is the program’s own and is left
alone.
-r/--remap [node:]from:=to— honoured. The rules ride on the returnedContextand are installed in every executor it creates (Context::create_executor/Context::create_executor_in) as the FALLBACK remap tier: a launch-projected rule for the same name wins (RFC-0046), exactly as rcl checks a node’s local arguments before the process’s global ones. They reach entities on every road — the handleExecutor::create_nodereturns,nros::node!components, and the C and C++ APIs.-p/--param [node:]name:=valueand--params-file <path>— honoured whennroshasparam-services(phase-482 W5, RFC-0015 §9’s POSIX row). They ride on theContextin argv order and are applied when a node DECLARES the parameter: the last matching override wins, its text typed by the declared default, and anode:override reaches only the node of that name. The envelope, stated here because it is the API: a parameter file is read withstd::fsand holds scalars only (arrays, anchors and block scalars are refused, with their line), a node key matches by NAME not namespace, and an override that does not parse as the declared type is logged and the default kept.- Everything else inside a scope — refused, loudly: node-identity
remaps, enclaves, log flags, unknown tokens, and
-p/--params-filein an image with no parameter store. Logged throughnros_log, then a panic carryingREFUSE_INIT_ARGSand the argument. rclcpp refuses unknown ROS arguments too (UnknownROSArgsError).
§Where the rules do NOT reach
Context::config refuses a context that carries rules, because an
ExecutorConfig cannot carry them. Entities created through the
executor’s own add_* registration methods or a node_mut context are
not remapped either: those are also where the C ABI and the component
sink hand their ALREADY-RESOLVED names, so remapping there would apply a
rule twice.