Skip to main content

isaac_sim_bridge/
sensor.rs

1// SPDX-License-Identifier: MPL-2.0
2/// Type-level identifier for a sensor domain.
3///
4/// `NAME` simultaneously plays four roles:
5///
6/// 1. **Registry key** — the consumer-registry insert/lookup key so the
7///    bridge can fan out callbacks per sensor without a runtime string map.
8/// 2. **Env-var prefix** — adapters derive `ISAAC_SIM_RS_DORA_<NAME>_*` and
9///    `ISAAC_SIM_RS_RERUN_<NAME>_*` variable names from it.
10/// 3. **Log label** — structured log lines use `S::NAME` so every sensor's
11///    messages are grep-able by name.
12/// 4. **Default dora id** — `register_publisher` defaults both OUTPUT and
13///    the dora node id to `S::NAME` when the env var is unset.
14///
15/// If a fifth use case arises that needs a value that differs from NAME
16/// for any existing sensor, introduce a separate associated const or a
17/// distinct trait rather than adding another load to this one. The existing
18/// exception is `CmdVelChannel`: its publisher output defaults to
19/// `"cmd_vel_observed"` (not `S::NAME`) via `register_publisher_with_default`
20/// because role 4 conflicts with role 2 when the subscriber's INPUT also
21/// defaults to `"cmd_vel"`.
22///
23/// Implemented by ZST markers in each sensor module (e.g. `LidarFlatScan`,
24/// `LidarPointCloud`). Adapters layer their own per-sensor trait on top
25/// (`RerunRender`, `DoraPublish`) keyed on these markers.
26pub trait Sensor: 'static {
27    /// Unique lowercase sensor identifier; see trait-level doc for all four roles and routing constraints.
28    const NAME: &'static str;
29}