Sensor Graphs
A SensorGraph connects numeric sensor sources and transforms into a
synchronous pipeline. It runs only the outputs you request and their upstream
dependencies, in dependency order, after physics has produced the data to
measure. Policy reads do not trigger another acquisition.
For example, a fingertip's vertex forces can feed a rectangular force map:
link contact forces → vertex-force source → rectangular map → policy observation
These are CPU numeric observations, including image-like tactile tensors.
SENSOR_CAMERA describes a camera's pose and intrinsics for a renderer; it does
not publish camera images through the sensor graph. See
Sensors for the registered source and transform types.
Building a graph
Declaring a pipeline on a bot
A link's sensors list can declare both the source and its transform. For a
hemispherical tactile link aligned with local +Z:
"sensors": [
{
"type": "SENSOR_LINK_VERTEX_FORCE",
"name": "surface",
"params": { "sampleRateHz": 100 }
},
{
"type": "SENSOR_SEED_RECT_MAP",
"name": "map",
"inputs": ["surface"],
"params": { "width": 16, "height": 8 }
}
]
Bot-owned node names become bot/link/sensor in a loaded SuperDex scene. An
unqualified input name resolves on the same link. Missing inputs, duplicate
names and dependency cycles fail graph construction.
params can also reference a .superdex_sensor file. Keep learned weights and
other companion assets with that file; relative companion paths are resolved
from the parameter file rather than the working directory.
Scene-level sensors
A .superdex_scene file's top-level sensors list declares sensors that belong
to the scene rather than to a bot, bound to no link. They use their declared
name and refer to bot-owned inputs by their full canonical name:
"sensors": [
{
"type": "SENSOR_DELAY_LINE",
"name": "hand_encoder_delayed",
"inputs": ["hand/dg5f_link_mount/joint_encoder"],
"params": { "delayMs": 10 }
}
]
The graph-capable sources registered today all read from a link or its bot, so current scene-level graph sensors are transforms like this one.
Combining outputs
SENSOR_CONCAT stacks inputs with identical formats along a new leading axis,
so K inputs of shape [N, 3] become one [K, N, 3] observation. The output's
capture time is the newest input's; each input's capture time stays available
and is recorded.
Building from a scene
The SuperDex scene loader prepares the chosen bots' prefabs and validates their sensor dependencies before constructing any bots. Nodes initially hold their names and inputs; live sensors are bound as the bots load. Scene-level sensors are constructed when their inputs are available. The graph begins with no selected outputs.
Loading normally prepares and loads every declared bot. An explicit nonempty
initialization list chooses which bots to prepare and load. To load them later,
pass bots_to_initialize=[] to the Python scene helper, then call
prepare_bots(names) with the complete selection before initialize_bot(name).
Include every bot referenced by the selected sensors' inputs; unused slot
alternatives are not read.
A valid graph may still have unbound nodes. Independent outputs can run while another selected bot remains unloaded. Selecting an output whose dependencies are unavailable returns an error; select it again after those bots load. See Changing the graph.
Building a graph without BotScene
C++ callers can construct a graph directly: Add the borrowed sensors and
their input names, select outputs with SetOutputEnabled, Build with a
SensorScope, then Reset. Sensor objects must outlive the graph's use of
them. To validate wiring before constructing sensors, use AddNode and Build
with no outputs selected. Then attach sensors with BindNode, select ready
outputs and build again.
Python exposes sensor parameter types and accessors, but not SensorGraph
construction; use BotScene from Python.
Stepping
- With BotScene, the graph steps once at the end of every
scene.step(), after physics, with that physics step's time and duration. Graph steps and physics steps are always in lockstep, and from Python this is the only option. Do not step the same graph manually as well. A source with a positivesampleRateHzcaptures on the graph steps that fall due at its rate, so it can sample more slowly than physics, but not faster and without interpolation. - Without BotScene, C++ calls
Stepitself, after a physics step, with aStepTimeit supplies. It can step the graph on every physics step or less often, provided time never goes backwards. Sources read the physics state as it is whenStepruns. - Serialize graph mutation, physics stepping and borrowed sensor reads on the stepping thread.
Errors during stepping
BotScene steps the sensor graph at the end of each scene.step(), after
physics, so a sensor failure does not interrupt the call. BotScene records the
first error, stops stepping the graph, and leaves the last published samples in
place. check_sensor_graph() raises the recorded error. It stays recorded until
reset_sensors() or rebuild_sensor_graph(), so you can check once before consuming observations rather
than after every step, and decide whether to end the episode or reset the
sensors and continue.
Missing bindings are checked when an output is enabled. That error returns from
add_sensor_outputs() and leaves the running outputs unchanged; it is not a
post-step acquisition error.
Reading the latest sample
For a scene containing bot hand with link tip and the sensors above:
import numpy as np
bot_scene.add_sensor_outputs(["hand/tip/map"])
scene = bot_scene.get_scene()
for _ in range(20):
scene.step(0.005)
bot_scene.check_sensor_graph() # Surfaces native post-step acquisition errors.
for output in bot_scene.get_sensor_outputs():
sensor = output.sensor
sample = sensor.latest()
if sample.capture_step < 0:
continue # No publication yet; allocated storage is not a sample.
values = np.asarray(sensor.copy_latest_values()).reshape(
sensor.get_format().shape
)
# Consume values with sample.capture_time, not the policy's read time.
NoUpdate retains the last sample. A faster policy loop can legitimately read
the same capture several times; neither a read nor a reset creates a new
measurement.
C++ Latest().Floats() is a borrowed Float32 payload. Consume or copy it before
that sensor publishes again, resets, reinitializes or is destroyed. Python
copy_latest_values() provides an owning copy. Use get_format() for the fixed
row-major shape and units; typed C++ metadata supplies vertex or joint-row
identities. Raw metadata object bytes are not a serialization format.
Matching tensor shape alone is not enough: check units, coordinate frames and row identities.
Two timestamps per sample
Native C++ SensorSample.captureStep / captureTime identify acquisition;
publishedStep / publishedTime identify when that node made its result
available. Transforms preserve the input's capture identity while stamping their
own publication time. A delay therefore changes availability, not when the
measurement was taken. Use capture time for physical alignment and publication
time for observation latency.
Positive-rate vertex-force sampling starts at the first positive physics step after reset and then follows its own cadence, sampled on physics steps rather than the policy's read schedule.
The current Python SensorSample binding exposes capture_step and
capture_time, but not the native publication fields. Do not use the policy
read time as a substitute for either timestamp.
Changing the graph
bot_scene.add_sensor_outputs(outputs)selects more outputs. Selecting the map above activates its source dependency without selecting the source as a separate output. Only newly active nodes are initialized; existing acquisition state and selections are preserved.- Removing a loaded bot releases its sensor bindings and downstream bindings, including scene-level sensors that read them. The prepared nodes remain. Loading that selected bot again binds fresh sensors; ready scene sensors can be constructed again without a full rebuild. Select the affected outputs again. Sensors that neither belong to that bot nor depend on its sensors retain their state and clock.
- Changing the selected bots is a configuration boundary: stop stepping, remove
all loaded bots, then
prepare_bots(names)with the new complete selection. This rebuilds and resets the graph; load the chosen bots and select outputs again. Repeating the same selection leaves the graph unchanged. bot_scene.reset_sensors()clears sensor state and restarts the acquisition clock without resetting physics, controllers or task state.rebuild_sensor_graph(outputs)explicitly reconstructs the declared graph, selects outputs and resets acquisition. It reuses the prepared prefab snapshots, including their edits. Later entry-path changes are rejected; load a new scene to pick up changed files or edits. Use rebuilding for a full acquisition restart, not routine reads.
Noise, Delay and History
A graph can model the observation path as well as the physical sensor. Each transform below takes one fixed Float32 input:
SensorGaussianNoiseadds noise once per new input publication, not per policy read.stdis a one-element broadcast or one standard deviation per flattened input element, in that element's units. Values must be finite and nonnegative.SensorUniformNoiseadds independent uniform noise, likewise drawn once per input publication.SensorOutlierInjectionreplaces whole input samples with outliers at a fixed probability, decided once per input publication; other samples pass through unchanged.SensorDelayLinequeues input publications and releases them afterdelayMsmilliseconds, preserving capture identity. Delay begins at the input publication time, so chained delays accumulate. A graph step can release several due samples;Latest()exposes the last released one.SensorTemporalWindowprepends ahistoryLengthaxis: a[N, 3]input becomes[historyLength, N, 3], oldest first. It advances on new input publications, not policy reads. Initial rows are zero-padded with invalid step-1; use its C++ row capture/publication accessors to distinguish padding from measured zeros. The window's sample header describes its newest row.
For example, add a noise node after the map declared above, then select
hand/tip/noisy_map instead of hand/tip/map:
{
"type": "SENSOR_GAUSSIAN_NOISE",
"name": "noisy_map",
"inputs": ["map"],
"params": {
"std": [0.01],
"random": { "episodeSeed": 7, "processKey": "hand/tip/map_noise" }
}
}
Noise is derived from the episode seed, stream key and input publication
step, so repeated reads do not redraw it. The stream key defaults to the
canonical graph name; random.processKey can supply an explicit stable key. Supply the next episode's parameters before resetting the
graph; resetting alone does not choose a new seed. Retain these parameters with
the experiment when comparing observations.
Delay storage is sized at initialization from bufferMs and the input's
publication-frequency estimate. If that estimate is unknown,
bufferAssumedFrequencyHzEstimate is used. Cover the largest delay and actual
input rate: underestimated capacity produces an error, not silent data loss.
Buffer sizing cannot change after initialization; set episode delay parameters
before graph reset. A temporal window's history length is construction-time
configuration.
Creation boundary: Gaussian noise and delay lines are registered
automatically in the public RoboticsContext. The temporal-window
implementation is public, but the default context does not register its
factory. C++ applications can construct it directly or register it before
loading a scene that declares SENSOR_TEMPORAL_WINDOW:
#include <superdex_robotics/core/context.h>
#include <superdex_robotics/sensors/sensor_temporal_window.h>
botsContext->RegisterSensor<superdex::robotics::SensorTemporalWindow>();
Python exposes its parameter type and accessors, but not native constructors or
these C++ registration templates. A class or type_name() being visible in
Python does not make it a default creatable type.
Recording observations
SensorRecordingSink is a backend-neutral C++ destination for constants and
timestamped sensor samples. ConfigureRecording writes the sensor's fixed
metadata; Record writes its latest sample and any sidecar fields. A graph step
alone does not record anything. The application supplies the sink and invokes
these hooks at its chosen recording cadence, preserving capture timestamps
rather than treating every policy read as a new measurement.
See Controllers, Sensors & Actuators for component ownership and registration, and Recording a Control Loop for simulation and controller recording with SuperDex Recorder.