Implementation:Haosulab ManiSkill BaseSensor
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Simulation, Sensors |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
Concrete tool for defining the abstract base class interface for all sensors in ManiSkill.
Description
The base_sensor.py module defines two foundational types:
BaseSensorConfig -- A minimal dataclass holding sensor configuration:
uid: str-- Unique identifier for the sensor.
BaseSensor -- Abstract base class that all ManiSkill sensors must implement:
__init__(config)-- Stores the sensor configuration.setup()-- Called during environment/scene reconfiguration to initialize the sensor for the current scene.capture()-- Captures sensor data. Designed to be non-blocking where possible (e.g., taking a picture after scene render update).get_obs(**kwargs)-- Returns the captured data as an observation dictionary for agent consumption. Must be implemented by subclasses.get_params()-- Returns sensor parameters as a dictionary of torch tensors. Must be implemented by subclasses.get_images()-- Returns sensor data visualized as an image (shape B, H, W, 3). Not for agent observations. Must be implemented by subclasses.uidproperty -- Returns the sensor's unique identifier from its config.
Usage
Subclassed by all sensor implementations (Camera, StereoDepthCamera, etc.). Use when implementing custom sensors for ManiSkill environments.
Code Reference
Source Location
- Repository: Haosulab_ManiSkill
- File: mani_skill/sensors/base_sensor.py
Signature
@dataclass
class BaseSensorConfig:
uid: str
class BaseSensor:
def __init__(self, config: BaseSensorConfig) -> None: ...
def setup(self) -> None: ...
def capture(self) -> None: ...
def get_obs(self, **kwargs): ... # abstract
def get_params(self) -> dict: ... # abstract
def get_images(self) -> torch.Tensor: ... # abstract
@property
def uid(self) -> str: ...
Import
from mani_skill.sensors.base_sensor import BaseSensor, BaseSensorConfig
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config | BaseSensorConfig | Yes | Configuration with at minimum a unique identifier |
Outputs
| Name | Type | Description |
|---|---|---|
| obs | dict | Observation data from get_obs() |
| params | dict | Sensor parameters (torch tensors) from get_params() |
| images | torch.Tensor | Visualization images of shape (B, H, W, 3) |
Usage Examples
Basic Usage
from mani_skill.sensors.base_sensor import BaseSensor, BaseSensorConfig
class CustomSensor(BaseSensor):
def get_obs(self, **kwargs):
return {"custom_data": self.captured_data}
def get_params(self) -> dict:
return {"param1": torch.tensor([1.0])}
def get_images(self):
return self.visualization_image
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment