simulo.ContactSensor
Contact force sensor using PhysX contact reporting.
Measures contact forces between bodies and the environment. Commonly used for foot contact detection in locomotion tasks.
Attributes:
history_length— Number of past contact states to storetrack_air_time— Whether to track time since last contactfilter_prim_paths— Optional list of prims to filter contacts with
Example:
import simulo
# Create contact sensor for robot feetcontact = simulo.ContactSensor( history_length=6, track_air_time=True, debug_vis=True,)
# Add to scene (supports regex patterns)scene.add(contact, at="/World/Robot/.*_FOOT")
# Read dataforces = contact.read_net_forces() # (num_envs, num_bodies, 3)air_time = contact.read_air_time() # (num_envs, num_bodies)Note: The path can include regex patterns (e.g., “.*_FOOT”) to match multiple bodies. Contact reporting must be enabled on the rigid bodies (done automatically for articulation feet).
simulo.ContactSensor( path: Optional[str] = None, update_period: float = 0.0, history_length: int = 1, track_air_time: bool = False, filter_prim_paths: Optional[List[str]] = None, enabled: bool = True, debug_vis: bool = False,)read_net_forces()
Section titled “read_net_forces()”ContactSensor.read_net_forces() -> torch.TensorGet net contact forces in world frame.
Returns:
Force tensor of shape (num_envs, num_bodies, 3). Each row is (fx, fy, fz) force vector in Newtons.
Raises:
RuntimeError— If sensor not initialized
read_force_matrix()
Section titled “read_force_matrix()”ContactSensor.read_force_matrix() -> torch.TensorGet contact force matrix (forces with history).
Returns:
Force matrix of shape (num_envs, num_bodies, history_length, 3).
Raises:
RuntimeError— If sensor not initialized
read_air_time()
Section titled “read_air_time()”ContactSensor.read_air_time() -> torch.TensorGet time bodies have been in air (not in contact).
Returns:
Air time tensor of shape (num_envs, num_bodies). Values are float32 in seconds.
Raises:
RuntimeError— If sensor not initialized or track_air_time is False
is_in_contact()
Section titled “is_in_contact()”ContactSensor.is_in_contact(threshold: float = 1.0) -> torch.TensorCheck if bodies are in contact.
Args:
threshold— Force threshold for contact detection (Newtons)
Returns:
Boolean tensor of shape (num_envs, num_bodies). True if contact force magnitude exceeds threshold.