rlmesh::adapters::State
A single-part numeric state input expected by a model.
struct StateFields
- roleSemantic role matched against env state features.
- encodingRotation encoding the model expects for this part.
- dimOptional number of leading elements to keep from the source.
- indexOptional single element to select after any conversion.
- optionalZero-fill this part when the env does not declare the role, instead of failing resolution.
- rangeOptional
(low, high)the model expects this part in; when the env declares its own (derived or tagged) range, the value is affinely mapped from the env range to this one (symmetric to action ranges). - pad_toZero-pad the resulting vector to this length.
- dtypeElement dtype name of the resulting value.
- reshapeOptional target shape for the resulting value.
- containerEmit a tensor or a list of values.
- fillValue this part contributes when
optionalis set and the env lacks the role (zeros by default). - post_rotateA fixed
Rotationright-multiplied onto the env's rotation (R_out = R_in @ R(post_rotate)) before it is re-encoded intoencoding. - scaleModel-side multiplier applied after the range map: one float for every axis, or a sequence with one value per axis in this part's own
labelsorder (its resolved width otherwise), serialized asaxis_scale. - offsetModel-side addend applied after
scale(value * scale + offset) -- e.g. a1 - 2ggripper isscale=-2, offset=1, a stand pose uses the negated default joint positions as offsets. - frameCoordinate frame the checkpoint was trained to read this part in, when the role is an absolute pose (
proprio/eef_*). - provenanceWhere the checkpoint expects this part's numbers to come from:
"sensed","estimated"or"privileged", or a sequence of the ones it accepts. - partThe body part this part reads, when the role repeats across a body (
LEFT_ARM,RIGHT_ARM, or any identifier both sides agree on): an identity key the resolver matches on. - labelsThe axis names this part reads, in the order the checkpoint was trained on.
- sourceWhere the value comes from:
"observation"(the default, an env state feature matched by role) or"action"(the model's own output actuator of the sameroleandpart, read back as the raw action executed at the previous step, in model order, before the actuator's scale/offset;fillbefore the episode's first action). - clipClamp the assembled vector to
(low, high)after every part's own transforms and beforepad_to(legged_gym'sclip_obs).
Associated functions
role
field[source]role: StringSemantic role matched against env state features.
encoding
field[source]encoding: Option<StateEncoding>Rotation encoding the model expects for this part. A single encoding, or a sequence of them
in preference order (most-preferred first) — the resolver picks the env’s native encoding
when it appears here (no conversion), else converts into the first entry. A CustomEncoding
is a single host-side packing (not a set). "gravity_xyz" reads any env rotation as the
gravity direction in the body frame (projected gravity, 3 wide); an env that publishes
gravity_xyz itself binds only a part that wants it.
dim
field[source]dim: Option<u32>Optional number of leading elements to keep from the source.
index
field[source]index: Option<u32>Optional single element to select after any conversion.
optional
field[source]optional: boolZero-fill this part when the env does not declare the role, instead of failing resolution.
The fill width comes from index (one), dim, or encoding; one of them must be set so
the width is known without an env feature.
range
field[source]range: Option<(f64, f64)>Optional (low, high) the model expects this part in; when the env declares its own
(derived or tagged) range, the value is affinely mapped from the env range to this one
(symmetric to action ranges). With no env source range there is nothing to map from, so it
is a no-op – it does not clamp or rescale on its own.
pad_to
field[source]pad_to: Option<u32>Zero-pad the resulting vector to this length. Padding is the last step: every part is converted, ranged and scaled, the parts are concatenated in order, and only then is the result padded.
dtype
field[source]dtype: Tolerant<DType>Element dtype name of the resulting value.
reshape
field[source]reshape: Option<Vec<i64>>Optional target shape for the resulting value.
container
field[source]container: StateContainerEmit a tensor or a list of values.
fill
field[source]fill: f64Value this part contributes when optional is set and the env lacks the role (zeros by
default). A non-zero fill requires optional, matching Actuator.fill.
post_rotate
field[source]post_rotate: Option<Rotation>A fixed Rotation right-multiplied onto the env’s rotation (R_out = R_in @ R(post_rotate)) before it is re-encoded into encoding. Needs a rotation encoding; not
combinable with a CustomEncoding.
scale
field[source]scale: Option<AxisValue>Model-side multiplier applied after the range map: one float for every axis, or a sequence
with one value per axis in this part’s own labels order (its resolved width otherwise),
serialized as axis_scale.
offset
field[source]offset: Option<AxisValue>Model-side addend applied after scale (value * scale + offset) – e.g. a 1 - 2g
gripper is scale=-2, offset=1, a stand pose uses the negated default joint positions as
offsets. A float or a per-axis sequence like scale.
frame
field[source]frame: Option<Tolerant<Frame>>Coordinate frame the checkpoint was trained to read this part in, when the role is an
absolute pose (proprio/eef_*). Omitted from the wire when unset. A frame the env
contradicts fails resolution; a frame the env does not declare draws a caution (the model
states a requirement nothing can confirm).
provenance
field[source]provenance: Option<Vec<Tolerant<Provenance>>>Where the checkpoint expects this part’s numbers to come from: "sensed", "estimated"
or "privileged", or a sequence of the ones it accepts. Against an env that publishes
the role under several provenances the declaration picks the leaf (an env publishing
several and a model naming none is an error); a value the env contradicts fails
resolution, and one the env does not declare draws a caution. Omitted from the wire when
unset.
part
field[source]part: Option<String>The body part this part reads, when the role repeats across a body (LEFT_ARM,
RIGHT_ARM, or any identifier both sides agree on): an identity key the resolver matches
on. Naming one binds only that env leaf (a missing one fills if optional, else fails);
naming none binds the env’s only leaf of the role under any part (with an info) and
fails when there are several, naming them. Omitted from the wire when unset.
labels
field[source]labels: Option<Vec<String>>The axis names this part reads, in the order the checkpoint was trained on. Fixes the
width. The env leaf must label its axes with the same set; the values are gathered by
name, so a differing order is a permutation, and a label either side lacks (or an env
leaf with no labels) is a resolve error. Omitted from the wire when unset; not combinable
with index. On an action-source part the names reorder the actuator’s labels.
source
field[source]source: StateSourceWhere the value comes from: "observation" (the default, an env state feature matched by
role) or "action" (the model’s own output actuator of the same role and part, read
back as the raw action executed at the previous step, in model order, before the
actuator’s scale/offset; fill before the episode’s first action). Previous is the
sugar. An action- source part carries only part, labels, dim and fill. Omitted
from the wire when default.
clip
field[source]clip: Option<(f64, f64)>Clamp the assembled vector to (low, high) after every part’s own transforms and before
pad_to (legged_gym’s clip_obs). Omitted from the wire when unset.
new
associated function[source]fn new(role: impl Into<String>) -> SelfConstruct a required observation input producing float32 tensors.
Trait implementations
- impl Clone for State
- impl Debug for State
- impl StructuralPartialEq for State
- impl PartialEq for State
- impl Serialize for State
- impl<'de> Deserialize<'de> for State
- impl Display for State
- impl From<State> for InputNode
- impl From<State> for ConcatPart
- impl From<State> for ReadItem