Implementation:Isaac sim IsaacGymEnvs FactoryBase Init
| Knowledge Sources | |
|---|---|
| Domains | Simulation, Manipulation |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Core initialization classes for Factory and IndustReal assembly environments, covering simulation creation, Franka robot import, environment population, and GPU tensor acquisition.
Description
Three classes collaborate to initialize the simulation scene. FactoryBase handles simulation creation, Franka asset import, and GPU tensor acquisition. FactoryEnvNutBolt (and other FactoryEnv* subclasses) handles object loading and environment population. IndustRealBase extends FactoryBase with additional tensor management for IndustReal-specific requirements (SDF meshes, controller signals).
Usage
These classes are instantiated by the task registration system when a Factory or IndustReal task is selected. The __init__ call cascades through the class hierarchy, with each level performing its initialization responsibilities.
Code Reference
Source Location
- Repository: IsaacGymEnvs
- File: isaacgymenvs/tasks/factory/factory_base.py, Lines 53-249
- File: isaacgymenvs/tasks/factory/factory_env_nut_bolt.py, Lines 48-357
- File: isaacgymenvs/tasks/industreal/industreal_base.py, Lines 51-504
Signature
FactoryBase
class FactoryBase(VecTask, FactoryABCBase):
def __init__(self, cfg, rl_device, sim_device, graphics_device_id,
headless, virtual_screen_capture, force_render):
"""Initialize base Factory environment.
Creates simulation, imports Franka asset, acquires GPU tensor handles.
"""
def create_sim(self): # L83-95
"""Create Isaac Gym simulation with configured physics parameters."""
def import_franka_assets(self): # L108-163
"""Load Franka Panda URDF with DOF properties and shape properties."""
def acquire_base_tensors(self): # L164-249
"""Acquire GPU tensor handles for DOF, rigid body, and contact states."""
FactoryEnvNutBolt
class FactoryEnvNutBolt(FactoryBase, FactoryABCEnv):
def __init__(self, cfg, rl_device, sim_device, graphics_device_id,
headless, virtual_screen_capture, force_render):
"""Initialize nut-bolt assembly environment."""
def create_envs(self):
"""Create parallel environments with Franka, nuts, bolts, and table."""
def _create_actors(self, lower, upper, num_per_row, franka_asset,
nut_assets, bolt_assets, table_asset):
"""Instantiate actors in a single environment."""
IndustRealBase
class IndustRealBase(FactoryBase, FactoryABCBase):
def __init__(self, cfg, rl_device, sim_device, graphics_device_id,
headless, virtual_screen_capture, force_render):
"""Initialize IndustReal base with extended tensor management."""
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| cfg | DictConfig | Yes | Hydra config object composed from YAML hierarchy |
| rl_device | str | Yes | Device for RL tensors (e.g., 'cuda:0')
|
| sim_device | str | Yes | Device for physics simulation (e.g., 'cuda:0')
|
| graphics_device_id | int | Yes | GPU ID for rendering (-1 for headless) |
| headless | bool | Yes | Whether to run without display |
| Franka URDF | file | Yes | Robot description at assets/factory/urdf/franka.urdf
|
| Object URDFs | file(s) | Yes | Task-specific assembly object descriptions |
| YAML asset info | file | Yes | Object dimensions and properties (e.g., factory_asset_info_nut_bolt.yaml)
|
Outputs
| Name | Type | Description |
|---|---|---|
| self.sim | GymSim | Isaac Gym simulation handle |
| self.envs | list[GymEnv] | List of environment handles (one per parallel env) |
| self.dof_pos | torch.Tensor | Joint positions, shape [num_envs, num_dofs]
|
| self.dof_vel | torch.Tensor | Joint velocities, shape [num_envs, num_dofs]
|
| self.rigid_body_states | torch.Tensor | Rigid body poses and velocities, shape [num_envs, num_bodies, 13]
|
| self.contact_forces | torch.Tensor | Contact forces on all bodies, shape [num_envs, num_bodies, 3]
|
| self.jacobian | torch.Tensor | Franka Jacobian, shape [num_envs, num_bodies, 6, num_dofs]
|
| self.mass_matrix | torch.Tensor | Franka mass matrix, shape [num_envs, num_dofs, num_dofs]
|
Usage Examples
Initialization Call Chain
# Task registration triggers the __init__ cascade:
# FactoryTaskNutBoltPick.__init__()
# -> FactoryEnvNutBolt.__init__()
# -> FactoryBase.__init__()
# -> VecTask.__init__() (calls create_sim)
# -> FactoryBase.import_franka_assets()
# -> FactoryEnvNutBolt.create_envs()
# -> FactoryEnvNutBolt._create_actors() (per env)
# -> FactoryBase.acquire_base_tensors()
# After initialization, GPU tensors are ready:
# task.dof_pos -> [num_envs, num_dofs]
# task.rigid_body_states -> [num_envs, num_bodies, 13]
# task.contact_forces -> [num_envs, num_bodies, 3]
Creating a New Factory Environment
class FactoryEnvCustom(FactoryBase, FactoryABCEnv):
"""Custom assembly environment following the Factory pattern."""
def __init__(self, cfg, rl_device, sim_device, graphics_device_id,
headless, virtual_screen_capture, force_render):
super().__init__(cfg, rl_device, sim_device, graphics_device_id,
headless, virtual_screen_capture, force_render)
# Import Franka (from FactoryBase)
self.import_franka_assets()
# Create environments with custom objects
self.create_envs()
# Acquire GPU tensor handles (from FactoryBase)
self.acquire_base_tensors()
def create_envs(self):
"""Populate environments with Franka + custom objects."""
# Load custom object URDFs
# Arrange in grid layout
# Create actors per environment
pass