Implementation:Haosulab ManiSkill Drive
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Simulation, Physics Constraints |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
Concrete tool for managing batched PhysX drive constraints between rigid bodies across parallel simulation environments.
Description
The Drive dataclass wraps physx.PhysxDriveComponent objects, providing a batched interface for creating and configuring 6-DOF drive constraints between pairs of rigid bodies. Drives can apply spring-damper forces/torques along or around each axis.
Key creation methods:
create_from_entities()-- Creates drives from raw SAPIEN entities or rigid body components. Requiresbodies1(child bodies);bodies0(parent bodies) may be None for world-anchored drives.create_from_actors_or_links()-- Convenience method that creates drives between Actor/Link struct pairs, automatically extracting underlying objects.
Drive property methods (all decorated with @before_gpu_init):
set_drive_property_x/y/z(stiffness, damping, force_limit, mode)-- Configure linear drive properties for each axis with stiffness, damping, force limit, and mode ("force" or "acceleration").set_limit_x/y/z(low, high, stiffness, damping)-- Set positional limits for each linear axis.
Additional commented-out methods indicate planned support for: slerp/swing/twist drives, drive targets, velocity targets, cone/pyramid/twist limits.
Usage
Drives are used to create spring constraints, position servos, or velocity controllers between objects. Common in environments that need soft constraints (e.g., tethered objects, spring-loaded mechanisms).
Code Reference
Source Location
- Repository: Haosulab_ManiSkill
- File: mani_skill/utils/structs/drive.py
Signature
@dataclass
class Drive(PhysxJointComponentStruct[physx.PhysxDriveComponent]):
@classmethod
def create_from_entities(
cls, scene, bodies0=None, pose0=None, bodies1=None, pose1=None, scene_idxs=None
) -> "Drive": ...
@staticmethod
def create_from_actors_or_links(
scene, entities0=None, pose0=None, entities1=None, pose1=None, scene_idxs=None
) -> "Drive": ...
def set_drive_property_x(self, stiffness, damping, force_limit=..., mode="force") -> None: ...
def set_drive_property_y(self, stiffness, damping, force_limit=..., mode="force") -> None: ...
def set_drive_property_z(self, stiffness, damping, force_limit=..., mode="force") -> None: ...
def set_limit_x(self, low, high, stiffness=0.0, damping=0.0) -> None: ...
def set_limit_y(self, low, high, stiffness=0.0, damping=0.0) -> None: ...
def set_limit_z(self, low, high, stiffness=0.0, damping=0.0) -> None: ...
Import
from mani_skill.utils.structs.drive import Drive
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| scene | ManiSkillScene | Yes | The scene containing the sub-scenes |
| bodies0 | Sequence[Entity] | No | Parent bodies (None for world-anchored) |
| bodies1 | Sequence[Entity] | Yes | Child bodies |
| pose0/pose1 | Pose | No | Drive frame poses |
| stiffness | float | Yes | Spring stiffness for drive |
| damping | float | Yes | Damping coefficient for drive |
Outputs
| Name | Type | Description |
|---|---|---|
| Drive | Drive | Batched drive constraint object |
Usage Examples
Basic Usage
from mani_skill.utils.structs.drive import Drive
from mani_skill.utils.structs.pose import Pose
import sapien
# Create a spring drive between two actors
drive = Drive.create_from_actors_or_links(
scene=env.scene,
entities0=actor_a,
pose0=Pose.create(sapien.Pose()),
entities1=actor_b,
pose1=Pose.create(sapien.Pose()),
)
drive.set_drive_property_x(stiffness=1000, damping=100)
drive.set_drive_property_y(stiffness=1000, damping=100)
drive.set_drive_property_z(stiffness=1000, damping=100)