Python API#
Authoring (USD prim)
Authoring wrapper for an Isaac contact sensor USD prim. |
|
Authoring wrapper for an Isaac IMU sensor USD prim. |
|
Authoring wrapper for an Isaac raycast sensor USD prim. |
Sensors (runtime)
Runtime wrapper for an Isaac contact sensor with frame-based data access. |
|
Effort sensor reading data. |
|
Sensor for measuring joint effort (torque/force). |
|
Runtime wrapper for an Isaac IMU sensor with frame-based data access. |
|
Joint state sensor reading data for all DOFs of an articulation. |
|
Sensor for reading all DOF joint states from an articulation. |
|
Runtime wrapper for an Isaac raycast sensor with frame-based data access. |
Sensors#
- class ContactSensor(
- path: str | Contact,
Bases:
_PhysicsSensorRuntimeRuntime wrapper for an Isaac contact sensor with frame-based data access.
Wraps a
Contactauthoring object and owns the C++IContactSensorCarbonite interface. Exposesget_data()for a structured per-step dictionary,get_sensor_reading()for the cachedContactSensorReading, andget_raw_data()for raw contact records.- Parameters:
path – Either a string USD path to an existing IsaacContactSensor prim, or a pre-built
Contactauthoring object. To create a new prim, useContact.create().
Example:
from isaacsim.sensors.experimental.physics import Contact, ContactSensor sensor = ContactSensor( Contact.create( "/World/Robot/foot/contact_sensor", min_threshold=1.0, max_threshold=1000.0, radius=0.05, ) ) frame = sensor.get_data() if frame["in_contact"]: print(f"Contact force: {frame['force']}")
- add_raw_contact_data_to_frame() None#
Enable raw contact data in frame output.
After calling this,
get_data()will include a"contacts"list with detailed per-contact information.
- get_data() dict#
Get the current contact sensor data as a structured frame.
- Returns:
"in_contact": Whether contact is detected."force": Contact force magnitude."time": Simulation time of reading."physics_step": Physics step number."number_of_contacts": Number of contact points."contacts": Raw contact data if enabled viaadd_raw_contact_data_to_frame.
- Return type:
Newly allocated frame data, independent of any other call, containing
Note
The frame is refreshed only on a valid reading; otherwise the previous values are returned. Use
get_sensor_reading()and checkis_validto tell them apart."contacts"is rebuilt only on a valid reading, so a returned frame shares that list with the sensor until the next one. Treat it as read-only.
- get_raw_data() list[dict[str, object]]#
Get raw contact data for the sensor’s parent body.
- Returns:
Raw contact dictionaries containing body0, body1, position, normal, impulse, time, and dt fields. Empty when the sensor is invalid.
- get_sensor_reading() ContactSensorReading#
Get the latest cached contact sensor reading.
- Returns:
Reading with contact state and force value. Returns an invalid reading if the sensor is disabled or the prim is invalid.
- on_physics_step(step_dt: float) None#
Called by
_SensorStepManagerafter each physics step.Reads the latest C++ sensor reading and caches it locally.
- Parameters:
step_dt – Duration of the physics step in seconds.
- remove_raw_contact_data_from_frame() None#
Disable raw contact data in frame output.
Removes the
"contacts"key from frame output to reduce overhead.
- property authoring_object: _PhysicsSensorAuthoring#
Authoring object encapsulated by this sensor.
- class EffortSensorReading(
- is_valid: bool = False,
- time: float = 0,
- value: float = 0,
Bases:
objectEffort sensor reading data.
- Parameters:
is_valid – Whether this reading contains valid data.
time – Simulation time when the reading was taken.
value – Effort (torque/force) value at the joint.
- class EffortSensor(path: str, enabled: bool = True)#
Bases:
_PhysicsSensorRuntimeBaseSensor for measuring joint effort (torque/force).
Owns the C++
IEffortSensorCarbonite interface directly and maintains a Python-side circular buffer of readings for historical access. Newton does not currently expose projected joint forces, so readings are invalid while Newton is active.- Parameters:
path – USD path to the joint, formatted as articulation_path/joint_name.
enabled – Whether the sensor is initially enabled.
Example
from isaacsim.sensors.experimental.physics import EffortSensor # Create sensor for a robot joint sensor = EffortSensor("/World/Robot/joint_1") # Read joint effort reading = sensor.get_sensor_reading() if reading.is_valid: print(f"Joint torque: {reading.value}")
- change_buffer_size(new_buffer_size: int) None#
Change the size of the sensor reading buffer.
Deprecated since version 3.3.0: The reading history buffer is not consumed within Isaac Sim. This method will be removed in Isaac Sim 7.0.
- Parameters:
new_buffer_size – New buffer size (number of readings to store). Must be a positive integer. Booleans are rejected, even though
boolis an integer subclass.- Raises:
TypeError – If
new_buffer_sizeis a boolean or is not an integer.ValueError – If
new_buffer_sizeis less than 1.
- get_data() dict#
Get the current effort sensor data as a structured frame.
- Returns:
"value": Effort (torque/force) value at the joint."is_valid": Whether the reading contains valid data."time": Simulation time of the reading."physics_step": Physics step number.
- Return type:
Frame data containing
- get_sensor_reading() EffortSensorReading#
Get the current effort sensor reading.
- Returns:
Reading with effort value and validity state. The reading is invalid when the active backend does not expose projected joint forces.
- on_physics_step(step_dt: float) None#
Called after each physics step. Override for custom per-step logic.
- Parameters:
step_dt – Physics step duration in seconds.
- update_dof_name(dof_name: str) None#
Update the DOF (degree of freedom) name being measured.
Resets the C++ sensor and rebinds the runtime to the new joint path.
Deprecated since version 3.3.0: Construct a new
EffortSensorwith the target joint path instead. This method will be removed in Isaac Sim 7.0.- Parameters:
dof_name – Name of the joint DOF to monitor.
- class IMUSensor(
- path: str | IMU,
Bases:
_PhysicsSensorRuntimeRuntime wrapper for an Isaac IMU sensor with frame-based data access.
Wraps an
IMUauthoring object and owns the C++IImuSensorCarbonite interface. Exposesget_data()for a structured per-step dictionary andget_sensor_reading()for the raw C++ struct.- Parameters:
path – Either a string USD path to an existing IsaacImuSensor prim, or a pre-built
IMUauthoring object. To create a new prim, useIMU.create().
Example:
from isaacsim.sensors.experimental.physics import IMU, IMUSensor # Wrap an existing IsaacImuSensor prim sensor = IMUSensor("/World/Robot/body/imu") # Create a new sensor with custom parameters sensor = IMUSensor( IMU.create( "/World/Robot/body/imu", linear_acceleration_filter_size=5, ) ) frame = sensor.get_data() print(f"Linear acceleration: {frame['linear_acceleration']}")
- get_data(read_gravity: bool = True) dict#
Get the current IMU sensor data as a structured frame.
read_gravity=Truereports specific force, what an accelerometer measures:+gat rest and0in free fall.read_gravity=Falsereports coordinate acceleration:0at rest and-gin free fall.gis in stage linear units per second squared (981on a centimetre stage), on the sensor axis opposing gravity.Deprecated since version 3.2.0:
read_gravityis deprecated and still honored.IsaacComputeOdometry’sglobalLinearAccelerationis gravity-free, but reports world-frame acceleration of the body rather than sensor-frame acceleration at this prim.- Parameters:
read_gravity – Whether the accelerometer channel includes the gravity reaction term.
- Returns:
"linear_acceleration": Linear acceleration[x, y, z]."angular_velocity": Angular velocity[x, y, z]."orientation": Orientation as[w, x, y, z]quaternion."time": Simulation time of reading."physics_step": Physics step number.
- Return type:
Newly allocated frame data, independent of any other call, containing
Note
The frame is refreshed only on a valid reading; otherwise the previous values are returned. Use
get_sensor_reading()and checkis_validto tell them apart, or on a hot path to read the values without allocating a frame.
- get_sensor_reading(read_gravity: bool = True) object#
Get the current IMU sensor reading as the raw C++ struct.
See
get_data()for whatread_gravityselects.Deprecated since version 3.2.0:
read_gravityis deprecated and still honored.IsaacComputeOdometry’sglobalLinearAccelerationis gravity-free, but reports world-frame acceleration of the body rather than sensor-frame acceleration at this prim.- Parameters:
read_gravity – Whether the accelerometer channel includes the gravity reaction term.
- Returns:
The C++
ImuSensorReadingstruct, with scalarlinear_acceleration_x/_y/_z,angular_velocity_x/_y/_z, andorientation_w/_x/_y/_zfields; useget_data()for numpy arrays. A valid reading is a fresh struct, an invalid one (is_validisFalse) a shared placeholder, so checkis_validbefore retaining it.
- on_physics_step(step_dt: float) None#
Called after each physics step. Override for custom per-step logic.
- Parameters:
step_dt – Physics step duration in seconds.
- property authoring_object: _PhysicsSensorAuthoring#
Authoring object encapsulated by this sensor.
- class JointStateSensorReading(
- is_valid: bool = False,
- time: float = 0.0,
- dof_names: list[str] | None = None,
- positions: ndarray | None = None,
- velocities: ndarray | None = None,
- efforts: ndarray | None = None,
- dof_types: ndarray | None = None,
- stage_meters_per_unit: float = 0.0,
Bases:
objectJoint state sensor reading data for all DOFs of an articulation.
Every attribute is read-only, matching the native snapshot: a reading describes one capture, so its values do not change afterwards. The arrays and the name list are owned by the reading and their contents stay mutable.
- Parameters:
is_valid – Whether this reading contains valid data.
time – Simulation time when the reading was taken.
dof_names – List of DOF name strings in articulation order.
positions – DOF positions array (rad for revolute, m for prismatic).
velocities – DOF velocities array (rad/s or m/s).
efforts – DOF efforts array (Nm or N).
dof_types – Per-DOF type: 0 = rotation (revolute), 1 = translation (prismatic).
stage_meters_per_unit – Stage meters per USD unit for SI conversion.
- property dof_names: list[str]#
Mutable list of degree-of-freedom names owned by the reading.
- property dof_types: ndarray#
Mutable degree-of-freedom type array owned by the reading.
- property efforts: ndarray#
Mutable effort array (Nm or N) owned by the reading.
- property is_valid: bool#
Whether the reading was valid when captured.
- property positions: ndarray#
Mutable position array (rad or m) owned by the reading.
- property stage_meters_per_unit: float#
Stage scale in meters per unit at capture time.
- property time: float#
Capture time in seconds.
- property velocities: ndarray#
Mutable velocity array (rad/s or m/s) owned by the reading.
- class JointStateSensor(path: str, enabled: bool = True)#
Bases:
_PhysicsSensorRuntimeBaseSensor for reading all DOF joint states from an articulation.
Reads positions, velocities, and efforts for every DOF in the articulation via the C++
IJointStateSensorCarbonite interface. Analogous to a ROS2 JointState message.- Parameters:
path – USD path to the articulation root prim.
enabled – Whether the sensor is initially enabled.
Example
from isaacsim.sensors.experimental.physics import JointStateSensor sensor = JointStateSensor("/World/Robot") # After playing the simulation: reading = sensor.get_sensor_reading() if reading.is_valid: for name, pos in zip(reading.dof_names, reading.positions): print(f"{name}: {pos:.4f} rad")
- get_data() dict#
Get the current joint state as a structured frame.
- Returns:
"dof_names": List of DOF names in articulation order."positions": Per-DOF positions (rad or m)."velocities": Per-DOF velocities (rad/s or m/s)."efforts": Per-DOF efforts (Nm or N)."dof_types": Per-DOF type (0 = revolute, 1 = prismatic)."stage_meters_per_unit": Stage meters per USD unit."is_valid": Whether the reading contains valid data."time": Simulation time of the reading."physics_step": Physics step number.
- Return type:
Frame data containing
- get_sensor_reading() JointStateSensorReading#
Get a mutable owned snapshot of the joint state for all DOFs.
The snapshot and its NumPy arrays remain valid after later physics steps, sensor reset, or removal. Its values and
is_validflag do not change after capture.- Returns:
Reading with DOF names, positions, velocities, efforts, and validity.
- get_sensor_reading_view() object#
Get a read-only zero-copy view of the live joint-state buffers.
Numeric arrays returned from the view retain its native backing frame even if the view variable is released. Their values and
view.timeupdate on each physics step.view.is_validbecomesFalseafter reset, removal, or timeline stop; retained arrays then remain readable with their last values. A numeric property lookup creates a NumPy array header without copying data; cache the returned array in a tight loop.The view performs no synchronization with the physics step that writes its buffers, so reading it while a step is in flight yields torn values that mix the current and the previous reading. Read it only from the thread that drives physics and only between steps; use
get_sensor_reading()when a reader cannot be ordered against the step.- Returns:
A
JointStateSensorReadingViewwith read-only NumPy arrays.
Example:
view = sensor.get_sensor_reading_view() if view.is_valid: positions = view.positions # read-only and owner-backed
- class RaycastSensor(
- path: str | _PhysicsSensorAuthoring,
Bases:
_PhysicsSensorRuntimeRuntime wrapper for an Isaac raycast sensor with frame-based data access.
Wraps a
Raycastauthoring object and owns the C++IRaycastSensorCarbonite interface. Exposesget_data()for a structured per-step dictionary,get_sensor_reading()for an owned snapshot, andget_sensor_reading_view()for a read-only view of live buffers.- Parameters:
path – Either a string USD path to an existing IsaacRaycastSensor prim, or a pre-built
Raycastauthoring object. To create a new prim, useRaycast.create().
Example:
from isaacsim.sensors.experimental.physics import Raycast, RaycastSensor sensor = RaycastSensor( Raycast.create( "/World/Robot/body/raycast", ray_origins=[[0, 0, 0]], ray_directions=[[1, 0, 0]], ) ) frame = sensor.get_data() print(f"Depths: {frame['depths']}")
- get_data() dict#
Get the current raycast sensor data as a structured frame.
- Returns:
"depths": Per-ray depth values."hit_positions": Per-ray hit positions as Nx3 array."hit_normals": Per-ray surface normals as Nx3 array."hit_prim_paths": Per-ray hit prim USD paths."time": Simulation time of reading."physics_step": Physics step number.
- Return type:
Frame data containing
- get_sensor_reading() object#
Get a mutable owned snapshot of the current raycast reading.
The snapshot and its NumPy arrays remain valid after later physics steps, sensor reset, or removal. Its values and
is_validflag do not change after capture.- Returns:
An owned
RaycastSensorReadingsnapshot. Access fields viareading.depths,reading.hit_positions, and related properties.
- get_sensor_reading_view() object#
Get a read-only zero-copy view of the live raycast buffers.
Numeric arrays returned from the view retain its native backing frame even if the view variable is released. Their values and
view.timeupdate on each physics step.view.is_validbecomesFalseafter reset, removal, or timeline stop; retained arrays then remain readable with their last values. A numeric property lookup creates a NumPy array header without copying data; cache the returned array in a tight loop.The view performs no synchronization with the physics step that writes its buffers, so reading it while a step is in flight yields torn values that mix the current and the previous reading. Read it only from the thread that drives physics and only between steps; use
get_sensor_reading()when a reader cannot be ordered against the step.- Returns:
A
RaycastSensorReadingViewwith read-only NumPy arrays.
Example:
view = sensor.get_sensor_reading_view() if view.is_valid: depths = view.depths # read-only and owner-backed
- on_physics_step(step_dt: float) None#
Called after each physics step. Override for custom per-step logic.
- Parameters:
step_dt – Physics step duration in seconds.
- property authoring_object: _PhysicsSensorAuthoring#
Authoring object encapsulated by this sensor.