unilab.base.entity¶
Base-owned NumPy scene/entity facade for manager terms.
The facade deliberately describes partitions of an already materialized UniLab scene.
It is not a second scene composer: all name resolution and state reads go through the
public SimBackend contract.
Classes
Logical entity with cached local-to-backend mappings. |
|
Declare one logical entity inside an existing backend scene. |
|
Hot-path NumPy state surface backed by cached backend IDs. |
|
Read-only name-addressable collection of backend-bound entities. |
- class unilab.base.entity.Entity[source]¶
Bases:
objectLogical entity with cached local-to-backend mappings.
- Parameters:
name (
str)cfg (
EntityCfg)backend (
SimBackend)reset_state (
ResetStateTransaction|None)state_read_cache (
_EntityStateReadCache|None)
- __init__(name, cfg, backend, control_buffer=None, reset_state=None, *, default_qpos=None, state_read_cache=None)[source]¶
- Parameters:
name (
str)cfg (
EntityCfg)backend (
SimBackend)reset_state (
ResetStateTransaction|None)state_read_cache (
_EntityStateReadCache|None)
- find_joints_by_actuator_names(keys)[source]¶
Resolve actuator-target joint patterns in natural entity joint order.
- set_joint_position_target(target, joint_ids=None, env_ids=None)[source]¶
Map entity-local joint targets to the env-owned actuator control buffer.
- set_joint_velocity_target(target, joint_ids=None, env_ids=None)[source]¶
Map joint velocity targets to the entity actuator control buffer.
- set_joint_effort_target(target, joint_ids=None, env_ids=None)[source]¶
Map joint effort (torque) targets to the actuator control buffer.
- bind_body_state_copy(body_ids=None)[source]¶
Bind entity-local body columns to the backend copy contract on the cold path.
- write_root_state_to_sim(root_state, env_ids=None)[source]¶
Stage a 13-D world-frame root state in the active reset transaction.
- bind_actuator_gain_write(actuator_ids=None, *, term_name)[source]¶
Bind selected actuator columns and immutable gain defaults on the cold path.
- write_actuator_gains_to_sim(kp, kd, actuator_ids=None, env_ids=None, *, term_name='pd_gains')[source]¶
Stage entity-local actuator gains in the active reset transaction.
- bind_geom_size_write(geom_ids=None, *, term_name)[source]¶
Bind entity-local geom_size columns and immutable defaults.
- write_geom_size_to_sim(values, geom_ids=None, env_ids=None, *, term_name='geom_size')[source]¶
Stage geom_size values through the reset transaction.
- bind_geom_solref_write(geom_ids=None, *, term_name)[source]¶
Bind entity-local geom_solref columns and immutable defaults.
- write_geom_solref_to_sim(values, geom_ids=None, env_ids=None, *, term_name='geom_solref')[source]¶
Stage geom_solref values through the reset transaction.
- bind_geom_solimp_write(geom_ids=None, *, term_name)[source]¶
Bind entity-local geom_solimp columns and immutable defaults.
- write_geom_solimp_to_sim(values, geom_ids=None, env_ids=None, *, term_name='geom_solimp')[source]¶
Stage geom_solimp values through the reset transaction.
- bind_joint_damping_write(joint_ids=None, *, term_name)[source]¶
Bind entity-local joint_damping columns and immutable defaults.
- write_joint_damping_to_sim(values, joint_ids=None, env_ids=None, *, term_name='joint_damping')[source]¶
Stage joint_damping values through the reset transaction.
- bind_joint_frictionloss_write(joint_ids=None, *, term_name)[source]¶
Bind entity-local joint_frictionloss columns and immutable defaults.
- write_joint_frictionloss_to_sim(values, joint_ids=None, env_ids=None, *, term_name='joint_frictionloss')[source]¶
Stage joint_frictionloss values through the reset transaction.
- bind_mocap_pose_write(body_name, *, term_name)[source]¶
Bind an explicitly named mocap body, independently of the floating root.
- read_mocap_pose()[source]¶
Read full-batch mocap poses, including pending reset writes.
- Return type:
- write_mocap_pose_to_sim(poses, env_ids=None, *, term_name='mocap_pose')[source]¶
Stage poses to commit after the ordinary reset state upload.
- bind_joint_armature_write(joint_ids=None, *, term_name)[source]¶
Bind entity-local joints and immutable default DOF armatures.
- write_joint_armature_to_sim(values, joint_ids=None, env_ids=None, *, term_name='joint_armature')[source]¶
Stage selected entity joint armatures in the active reset transaction.
- bind_geom_friction_write(geom_ids=None, *, term_name)[source]¶
Bind entity-local geoms and immutable default friction vectors.
- write_geom_friction_to_sim(values, geom_ids=None, env_ids=None, *, term_name='geom_friction')[source]¶
Stage selected entity geom friction in the active reset transaction.
- bind_body_mass_write(body_ids=None, *, term_name)[source]¶
Bind entity-local body columns and immutable default masses.
- write_body_mass_to_sim(values, body_ids=None, env_ids=None, *, term_name='randomize_rigid_body_mass')[source]¶
Stage selected entity body masses in the active reset transaction.
- bind_body_ipos_write(body_ids=None, *, term_name)[source]¶
Bind entity-local body columns and immutable inertial positions.
- write_body_ipos_to_sim(values, body_ids=None, env_ids=None, *, term_name='randomize_rigid_body_com')[source]¶
Stage selected entity body inertial positions in the reset transaction.
- bind_body_inertia_write(body_ids=None, *, default, default_mass, term_name)[source]¶
Bind entity-local body columns and caller-compiled default inertias.
default/default_massare the full backend-width inertial tables compiled from the scene model on the cold path; the transaction cross-validatesdefault_massagainst the backend’s authoritative body-mass table before trusting the inertia rows.
- write_body_inertia_to_sim(values, body_ids=None, env_ids=None, *, term_name='randomize_body_mass_inertia')[source]¶
Stage selected entity body principal inertias in the reset transaction.
- bind_root_linear_velocity_delta(*, term_name)[source]¶
Validate the interval root-velocity capability on the cold path.
- bind_root_angular_velocity_delta(*, term_name)[source]¶
Validate the interval root angular-velocity capability on the cold path.
- apply_root_linear_velocity_delta_to_sim(values, env_ids=None, *, term_name='push_by_setting_velocity')[source]¶
Dispatch a cached root linear-velocity delta through the formal interval plan.
- apply_root_velocity_delta_to_sim(linear_delta, angular_delta, env_ids=None, *, term_name='push_by_setting_velocity')[source]¶
Dispatch world-frame root linear/angular velocity deltas in one interval plan.
- bind_body_wrench(body_ids=None, *, torque, term_name)[source]¶
Resolve entity-local and backend body columns for interval wrench writes.
Returns readonly
(local_ids, backend_ids);local_idsindex the entity’s body-state views (e.g.data.body_link_quat_w) andbackend_idsare the columns accepted byapply_body_wrench_to_sim().
- apply_body_wrench_to_sim(forces, torques, body_ids, env_ids=None, *, term_name)[source]¶
Dispatch world-frame body forces/torques through the formal interval plan.
body_idsare the immutable backend columns returned bybind_body_wrench();forces/torquesare world-frame rows forenv_idsstaged for the upcoming step.
- write_root_link_pose_to_sim(root_pose, env_ids=None)[source]¶
Stage world position and wxyz root orientation during reset.
- write_root_link_velocity_to_sim(root_velocity, env_ids=None)[source]¶
Stage world linear/angular root velocity during reset.
- read_reset_root_pose(env_ids=None)[source]¶
Read the world position and wxyz root orientation staged in the reset.
Returns a detached
(len(env_ids), 7)copy of the pose currently staged in the active reset transaction (backend default for rows no term has written yet), so a later reset term can build on an earlier term’s root placement.
- write_joint_state_to_sim(position, velocity, joint_ids=None, env_ids=None)[source]¶
Stage community-style joint state writes in the active reset transaction.
- class unilab.base.entity.EntityCfg[source]¶
Bases:
objectDeclare one logical entity inside an existing backend scene.
Names are explicit because UniLab keeps scene composition in task-owned XML and backend adapters.
Nonemeans that the namespace is not exposed by this entity; an empty sequence means that it is exposed but contains no elements.- Parameters:
- __init__(root_body_name=None, joint_names=None, body_names=None, geom_names=None, site_names=None, actuator_names=None)¶
- class unilab.base.entity.EntityData[source]¶
Bases:
objectHot-path NumPy state surface backed by cached backend IDs.
- Parameters:
backend (
SimBackend)entity_name (
str)backend_type (
str)state_read_cache (
_EntityStateReadCache)
- __init__(backend, *, root_body_ids, joint_pos_ids, joint_vel_ids, default_root_state, default_root_state_error, default_joint_pos, default_joint_vel, soft_joint_pos_limits, gravity_vec_w, body_ids, actuator_ids, actuator_ctrl_range, control_buffer, entity_name, backend_type, state_read_cache)[source]¶
- Parameters:
backend (
SimBackend)entity_name (
str)backend_type (
str)state_read_cache (
_EntityStateReadCache)
- property default_joint_vel: ndarray¶
Read-only zero default velocities from the UniLab reset contract.
- property soft_joint_pos_limits: ndarray¶
Read-only joint position limits in the declared entity joint order.
- property encoder_bias: ndarray¶
Mutable per-environment joint encoder bias used by position actions.
- body_link_pos_w_rows(env_ids)[source]¶
Row-scoped variant of body_link_pos_w for partial-reset rebuilds.
- body_link_quat_w_rows(env_ids)[source]¶
Row-scoped variant of body_link_quat_w for partial-reset rebuilds.
- body_link_lin_vel_w_rows(env_ids)[source]¶
Row-scoped variant of body_link_lin_vel_w for partial-reset rebuilds.
- body_link_ang_vel_w_rows(env_ids)[source]¶
Row-scoped variant of body_link_ang_vel_w for partial-reset rebuilds.
- write_ctrl(values, env_ids=None, *, actuator_ids=None)[source]¶
Write entity-local actuator controls into the env-owned control buffer.
This is an in-memory scene write, analogous to the pinned manager runtime’s entity target buffers. Physics remains owned by
NpEnv/SimBackend; this method never steps or calls a backend-private API.
- class unilab.base.entity.EntityScene[source]¶
-
Read-only name-addressable collection of backend-bound entities.
- Parameters:
backend (
SimBackend)reset_state (
ResetStateTransaction|None)
- __init__(entities, backend, control_buffer=None, *, reset_state=None, default_qpos=None)[source]¶
- Parameters:
backend (
SimBackend)reset_state (
ResetStateTransaction|None)
- classmethod from_scene_cfg(cfg, backend, control_buffer=None, *, reset_state=None, default_qpos=None)[source]¶
- Parameters:
cfg (
SceneCfg)backend (
SimBackend)reset_state (
ResetStateTransaction|None)
- Return type:
- property env_origins: ndarray¶
Read-only per-environment origins; flat UniLab scenes default to zero.
- reset_to_default(env_ids, *, term_name)[source]¶
Stage a full-scene default state in the active reset transaction.
- bind_gravity_write(*, term_name)[source]¶
Bind immutable backend gravity for a reset event on the cold path.
- write_gravity_to_sim(values, env_ids, *, term_name)[source]¶
Stage gravity values in the exactly-once reset transaction.
- bind_sensor_data(names)[source]¶
Bind existing backend sensors for a manager term on the cold path.
The returned view owns the backend-specific reader. Terms retain that view and only call
BackendSensorView.read()while stepping, so the scene facade never exposes a backend model, data object, or native handle.