Skip to main content

Module contract

Module contract 

Source
Expand description

Contract monitors on target, and the /diagnostics reporter they publish through — ONE implementation for every language.

A contracted image bakes monitor tables (min_rate_hz / max_latency_ms per publisher, max_age_ms per subscriber), the executor checks them every spin and logs each violation at detection (the floor every image keeps). A C or C++ image can also PUBLISH each one as a DiagnosticArray on /diagnostics, through a reporter nros-cpp armed when the tables were installed. The Rust entry (nros::main!) installed no table at all, so it neither monitored nor reported.

This module is that reporter, moved up to the umbrella so the three languages share it: DiagSink (one /diagnostics publisher and its two counters) and its violation sink, used by nros-cpp‘s nros_cpp_install_monitors and by install_contract_monitors, which the nros::main! expansion calls before the first node is created. The mapping from a violation to a report is nros-diagnostics’ (DiagnosticReporter::report_violation, streamed by write_violation_reports so the report never sits on the spin thread’s stack as a value), so a violation reads the same from every road. The executor hands the reporter its queued verdicts off the judged dispatch, and one report carries as many as fit one message.

Structs§

ContractReporter
Static storage for one executor’s DiagSink — what a Rust entry owns in place of the C++ context’s diag field.
DiagSink
One executor’s /diagnostics reporter: the publisher and two counters.

Constants§

DIAG_TOPIC
The topic ROS 2’s diagnostics tooling reads.

Functions§

arm_reporter⚠
Arm one executor’s /diagnostics reporter in slot, and point the executor’s violation sink at it — THE arming step, shared by install_contract_monitors (Rust) and nros-cpp’s nros_cpp_install_monitors (C and C++).
install_contract_hazards⚠
Install a contracted Rust image’s hazard table on one executor, after install_contract_monitors (each hazard’s guards index the two tables that call installs). nros::main! emits this only for an executor whose tables observe a hazard; the observer then reports hazard-detected, hazard-reaction and hazard-recovered through the reporter that call armed.
install_contract_modes⚠
Install a contracted Rust image’s MODE variants of the two monitor tables on one executor, after install_contract_monitors (entry 0 of modes is that call’s base tables). nros::main! emits this only for a model that declares modes; nros::monitor::request_mode then switches every executor at its next spin.
install_contract_monitors⚠
Install a contracted Rust image’s monitor tables on one executor, and arm its /diagnostics reporter.