Rigid Object#
The RigidObject class represents non-deformable (rigid) physical objects in EmbodiChain. Rigid objects are characterized by a single pose (position + orientation), collision and visual shapes, and standard rigid-body physical properties.
Configuration#
Configured via the RigidObjectCfg class.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
Geometry configuration for visual and collision shapes. Use |
|
|
|
|
Actor type for the rigid body. See |
|
defaults in code |
Physical attributes (mass, damping, friction, restitution, collision offsets, CCD, etc.). |
|
|
|
|
Initial root position (x, y, z). |
|
|
|
Initial root orientation (Euler angles in degrees) or provide |
|
|
|
If True, use physical properties from USD file; if False, override with config values. Only effective for usd files. |
|
|
|
Optional unique identifier for the object; manager will assign one if omitted. |
Rigid Body Attributes (RigidBodyAttributesCfg)#
The full attribute set lives in {class}~cfg.RigidBodyAttributesCfg`. Common fields shown in code include:
Parameter |
Type |
Default (from code) |
Description |
|---|---|---|---|
|
|
|
Mass of the rigid body in kilograms (set to 0 to use density). |
|
|
|
Density used when mass is negative/zero. |
|
|
|
Linear damping coefficient. |
|
|
|
Angular damping coefficient. |
|
|
|
Dynamic friction coefficient. |
|
|
|
Static friction coefficient. |
|
|
|
Restitution (bounciness). |
|
|
|
Contact offset for collision detection. |
|
|
|
Rest offset for collision detection. |
|
|
|
Enable continuous collision detection. |
Use the .attr() helper to convert to dexsim.PhysicalAttr when interfacing with the engine.
Setup & Initialization#
import torch
from embodichain.lab.sim import SimulationManager, SimulationManagerCfg
from embodichain.lab.sim.objects import RigidObject, RigidObjectCfg
from embodichain.lab.sim.shapes import CubeCfg
from embodichain.lab.sim.cfg import RigidBodyAttributesCfg
# 1. Initialize Simulation
device = "cuda" if torch.cuda.is_available() else "cpu"
sim_cfg = SimulationManagerCfg(sim_device=device)
sim = SimulationManager(sim_cfg)
# 2. Configure a rigid object (cube)
physics_attrs = RigidBodyAttributesCfg(mass=1.0, dynamic_friction=0.5, static_friction=0.5, restitution=0.1)
cfg = RigidObjectCfg(
uid="cube",
shape=CubeCfg(size=[0.1, 0.1, 0.1]),
body_type="dynamic",
attrs=physics_attrs,
init_pos=(0.0, 0.0, 1.0),
)
# 3. Spawn Rigid Object
cube: RigidObject = sim.add_rigid_object(cfg=cfg)
# 4. (Optional) Open window and run
if not sim.sim_config.headless:
sim.open_window()
sim.update()
Note:
scripts/tutorials/sim/create_scene.pyprovides a minimal working example of adding a rigid cube and running the simulation loop.
USD Import#
You can import USD files (.usd, .usda, .usdc) as rigid objects:
from embodichain.data import get_data_path
# Import USD with properties from file
usd_cfg = RigidObjectCfg(
shape=MeshCfg(fpath=get_data_path("path/to/object.usd")),
body_type="dynamic",
use_usd_properties=True # Keep USD properties
)
obj = sim.add_rigid_object(cfg=usd_cfg)
# Or override USD properties with config
usd_cfg_override = RigidObjectCfg(
shape=MeshCfg(fpath=get_data_path("path/to/object.usd")),
body_type="dynamic",
use_usd_properties=False, # Use config instead
attrs=RigidBodyAttributesCfg(mass=2.0)
)
obj2 = sim.add_rigid_object(cfg=usd_cfg_override)
Rigid Object Class — Common Methods & Attributes#
Rigid objects are observed and controlled via single poses and linear/angular velocities. Key APIs include:
Method / Property |
Return / Args |
Description |
|---|---|---|
|
|
Get object local pose as (x, y, z, qw, qx, qy, qz) or 4x4 matrix per environment. |
|
|
Teleport object to given pose (requires calling |
|
|
Access object pose directly (for dynamic/kinematic bodies). |
|
|
Access linear velocity of object root (for dynamic/kinematic bodies). |
|
|
Access angular velocity of object root (for dynamic/kinematic bodies). |
|
|
Get full body state: [x, y, z, qw, qx, qy, qz, lin_x, lin_y, lin_z, ang_x, ang_y, ang_z]. |
|
|
Apply continuous force and/or torque to the object. |
|
- |
Reset velocities and clear all forces/torques. |
|
|
Change visual appearance at runtime. |
|
|
Enable/disable collision for specific instances. |
|
- |
Reset objects to initial configuration. |
Observation Shapes#
Pose:
(N, 7)per-object pose (position + quaternion).Velocities:
(N, 3)for linear and angular velocities respectively.
N denotes the number of parallel environments when using vectorized simulation (SimulationManagerCfg.num_envs).
Notes & Best Practices#
When moving objects programmatically via
set_local_pose, callsim.update()(or step the sim) to ensure transforms and collision state are synchronized.Use
staticbody type for fixed obstacles or environment pieces (they do not consume dynamic simulation resources).Use
kinematicfor objects whose pose is driven by code (teleporting or animation) but still interact with dynamic objects.For complex meshes, enabling convex decomposition (
RigidObjectCfg.max_convex_hull_num) or providing a simplified collision mesh improves stability and performance.To use GPU physics, ensure
SimulationManagerCfg.sim_deviceis set tocudaand callsim.init_gpu_physics()before large-batch simulations.
Example: Applying Force and Torque#
import torch
# Apply force to the cube
force = torch.tensor([[0.0, 0.0, 100.0]], device=sim.device) # (N, 3) upward force
cube.add_force_torque(force=force, torque=None)
sim.update()
# Apply torque to the cube
torque = torch.tensor([[0.0, 0.0, 10.0]], device=sim.device) # (N, 3) torque around z-axis
cube.add_force_torque(force=None, torque=torque)
sim.update()
# Access velocity data
linear_vel = cube.body_data.lin_vel # (N, 3)
angular_vel = cube.body_data.ang_vel # (N, 3)
Integration with Sensors & Scenes#
Rigid objects integrate with sensors (cameras, contact sensors) and gizmos. You can attach sensors referencing object uids or query contacts for collision-based events.