unilab.base.reset_state.ResetStateTransaction¶
- class unilab.base.reset_state.ResetStateTransaction[source]¶
Bases:
objectReusable, fail-closed transaction for reset-mode state mutation.
- Parameters:
backend (
SimBackend)
Methods
__init__(backend, *[, default_qpos])abort()Discard staged rows without touching the backend.
begin(env_ids)Open a transaction for the concrete reset environment IDs.
bind_actuator_gain_write(actuator_ids, *, ...)Resolve gain mutation capability and immutable defaults on the cold path.
bind_body_inertia_write(body_ids, *, ...)Bind body-inertia columns with caller-supplied cold-path defaults.
bind_body_ipos_write(body_ids, *, term_name)Bind body inertial-position columns and immutable backend defaults.
bind_body_mass_write(body_ids, *, term_name)Bind body-mass columns and immutable backend defaults on the cold path.
bind_dof_armature_write(dof_ids, *, term_name)Bind DOF-armature columns and immutable backend defaults.
bind_dof_damping_write(column_ids, *, term_name)Bind immutable dof_damping defaults through the declared backend capability.
bind_dof_frictionloss_write(column_ids, *, ...)Bind immutable dof_frictionloss defaults through the declared backend capability.
bind_geom_friction_write(geom_ids, *, term_name)Bind geom-friction rows and immutable backend defaults.
bind_geom_size_write(column_ids, *, term_name)Bind immutable geom_size defaults through the declared backend capability.
bind_geom_solimp_write(column_ids, *, term_name)Bind immutable geom_solimp defaults through the declared backend capability.
bind_geom_solref_write(column_ids, *, term_name)Bind immutable geom_solref defaults through the declared backend capability.
bind_gravity_write(*, term_name)Bind the immutable backend gravity vector on the cold path.
bind_mocap_pose(body_name)Resolve a mocap body once, without exposing a native backend handle.
commit()Commit all staged rows through one public backend call.
read_mocap_pose(body_name)Read current poses with this transaction's pending rows overlaid.
read_root_pose(env_ids, layout, *, term_name)Read the world position and wxyz orientation staged for one floating root.
reset_to_default(env_ids, *, term_name)Stage backend default qpos/qvel for a subset of the active reset.
scoped(env_ids)Begin a reset transaction and commit it only after all terms succeed.
write_actuator_gains(env_ids, actuator_ids, ...)Stage selected per-environment actuator gains in the reset transaction.
write_body_inertia(env_ids, body_ids, ...)Stage selected body principal-inertia diagonals in the reset payload.
write_body_ipos(env_ids, body_ids, values, ...)Stage selected body inertial positions in the reset payload.
write_body_mass(env_ids, body_ids, values, ...)Stage selected body masses in the exactly-once reset payload.
write_dof_armature(env_ids, dof_ids, values, ...)Stage selected DOF armatures in the reset payload.
write_dof_damping(env_ids, column_ids, ...)Stage selected dof_damping values in the active reset.
write_dof_frictionloss(env_ids, column_ids, ...)Stage selected dof_frictionloss values in the active reset.
write_geom_friction(env_ids, geom_ids, ...)Stage selected three-axis geom friction in the reset payload.
write_geom_size(env_ids, column_ids, values, ...)Stage selected geom_size values in the active reset.
write_geom_solimp(env_ids, column_ids, ...)Stage selected geom_solimp values in the active reset.
write_geom_solref(env_ids, column_ids, ...)Stage selected geom_solref values in the active reset.
write_gravity(env_ids, values, *, term_name)Stage per-environment gravity vectors in the reset payload.
write_joint_state(env_ids, qpos_indices, ...)Stage selected joint position and velocity columns in the reset batch.
write_mocap_pose(body_name, env_ids, poses, ...)Stage poses; upload only after the ordinary reset state has committed.
write_root_pose(env_ids, layout, pose, *, ...)Stage world position and wxyz orientation for one floating root.
write_root_state(env_ids, layout, ...)Stage a community 13-D world-frame root state.
write_root_velocity(env_ids, layout, ...)Stage world-frame root velocity in generalized qvel columns.
Attributes
Whether a reset lifecycle currently owns the transaction.
Whether the most recent scoped commit submitted dirty rows to set_state.
Sub-timings from the most recent commit's set_state call.
- __init__(backend, *, default_qpos=None)[source]¶
- Parameters:
backend (
SimBackend)
- property last_commit_had_writes: bool¶
Whether the most recent scoped commit submitted dirty rows to set_state.
- property last_set_state_timing_ms: dict[str, float]¶
Sub-timings from the most recent commit’s set_state call.
Always includes
dr_reset_set_state_ms(outer wall-clock around the backend call); backend-reportedset_state_*_mssub-keys are merged in when the backend returns them. Empty when the last commit had no dirty rows.
- scoped(env_ids)[source]¶
Begin a reset transaction and commit it only after all terms succeed.
- Parameters:
env_ids (
ndarray)- Return type:
- bind_geom_size_write(column_ids, *, term_name)[source]¶
Bind immutable geom_size defaults through the declared backend capability.
- write_geom_size(env_ids, column_ids, values, *, term_name)[source]¶
Stage selected geom_size values in the active reset.
- bind_geom_solref_write(column_ids, *, term_name)[source]¶
Bind immutable geom_solref defaults through the declared backend capability.
- write_geom_solref(env_ids, column_ids, values, *, term_name)[source]¶
Stage selected geom_solref values in the active reset.
- bind_geom_solimp_write(column_ids, *, term_name)[source]¶
Bind immutable geom_solimp defaults through the declared backend capability.
- write_geom_solimp(env_ids, column_ids, values, *, term_name)[source]¶
Stage selected geom_solimp values in the active reset.
- bind_dof_damping_write(column_ids, *, term_name)[source]¶
Bind immutable dof_damping defaults through the declared backend capability.
- write_dof_damping(env_ids, column_ids, values, *, term_name)[source]¶
Stage selected dof_damping values in the active reset.
- bind_dof_frictionloss_write(column_ids, *, term_name)[source]¶
Bind immutable dof_frictionloss defaults through the declared backend capability.
- write_dof_frictionloss(env_ids, column_ids, values, *, term_name)[source]¶
Stage selected dof_frictionloss values in the active reset.
- bind_body_mass_write(body_ids, *, term_name)[source]¶
Bind body-mass columns and immutable backend defaults on the cold path.
- bind_body_ipos_write(body_ids, *, term_name)[source]¶
Bind body inertial-position columns and immutable backend defaults.
- bind_body_inertia_write(body_ids, *, default, default_mass, term_name)[source]¶
Bind body-inertia columns with caller-supplied cold-path defaults.
SimBackendhas no body-inertia getter, so the caller compiles the scene model on the cold path and supplies the full(nbody, 3)principal-inertia table in backend body-id order.default_massis the full(nbody,)table from the same compile and is cross-validated against the backend’s authoritative body-mass table, which fail-closed pins the body set and row ordering.
- bind_gravity_write(*, term_name)[source]¶
Bind the immutable backend gravity vector on the cold path.
- bind_dof_armature_write(dof_ids, *, term_name)[source]¶
Bind DOF-armature columns and immutable backend defaults.
- bind_geom_friction_write(geom_ids, *, term_name)[source]¶
Bind geom-friction rows and immutable backend defaults.
- write_body_mass(env_ids, body_ids, values, *, term_name)[source]¶
Stage selected body masses in the exactly-once reset payload.
- write_body_ipos(env_ids, body_ids, values, *, term_name)[source]¶
Stage selected body inertial positions in the reset payload.
- write_body_inertia(env_ids, body_ids, values, *, term_name)[source]¶
Stage selected body principal-inertia diagonals in the reset payload.
- write_gravity(env_ids, values, *, term_name)[source]¶
Stage per-environment gravity vectors in the reset payload.
- write_dof_armature(env_ids, dof_ids, values, *, term_name)[source]¶
Stage selected DOF armatures in the reset payload.
- write_geom_friction(env_ids, geom_ids, values, *, term_name)[source]¶
Stage selected three-axis geom friction in the reset payload.
- bind_actuator_gain_write(actuator_ids, *, term_name)[source]¶
Resolve gain mutation capability and immutable defaults on the cold path.
- write_actuator_gains(env_ids, actuator_ids, kp, kd, *, term_name)[source]¶
Stage selected per-environment actuator gains in the reset transaction.
- reset_to_default(env_ids, *, term_name)[source]¶
Stage backend default qpos/qvel for a subset of the active reset.
- write_joint_state(env_ids, qpos_indices, qvel_indices, position, velocity, *, term_name)[source]¶
Stage selected joint position and velocity columns in the reset batch.
- write_root_state(env_ids, layout, root_state, *, term_name)[source]¶
Stage a community 13-D world-frame root state.
- write_root_pose(env_ids, layout, pose, *, term_name)[source]¶
Stage world position and wxyz orientation for one floating root.
- write_root_velocity(env_ids, layout, velocity_w, *, term_name)[source]¶
Stage world-frame root velocity in generalized qvel columns.
The public generalized-state contract stores free-root linear velocity in world coordinates and angular velocity in root-body coordinates. The conversion uses the pose already staged in this transaction.
- read_root_pose(env_ids, layout, *, term_name)[source]¶
Read the world position and wxyz orientation staged for one floating root.
Returns a detached
(len(env_ids), 7)copy of the pose currently staged in this transaction. Rows no term has written yet are first initialized to the backend default pose, so a later reset term can build on an earlier term’s root placement without re-deriving it.
- bind_mocap_pose(body_name)[source]¶
Resolve a mocap body once, without exposing a native backend handle.
- Parameters:
body_name (
str)- Return type:
BackendMocapPoseBinding
- read_mocap_pose(body_name)[source]¶
Read current poses with this transaction’s pending rows overlaid.