Running a Conda Environment for IsaacLab for Script Editor

I am currently using a standalone python script with the Isaac Lab conda environment. I find it hard to re-simulate everything from scratch for every change I do with it. It takes so much time to load the app with AppLauncher and importing the libraries, only then you can see the changes you applied. Is it possible to use the conda environment for Isaac Lab in the script editor? I am using the Isaac Lab API for setting up a scene for reinforcement learning task with a custom robot arm. Here’s my code for the current scene:

import omni.isaac.lab.sim as sim_utils
from omni.isaac.lab.assets import RigidObject, RigidObjectCfg
from pxr import UsdGeom, Gf
import omni.usd

def create_table(size):
    """ Creates a table in the scene. """
    
    # add size argument
    if args_cli.size:
        size=args_cli.size

    # configure the table object
    cube_cfg = RigidObjectCfg(
        prim_path="/World/Table",

        # spawn a cube with rigid, mass, collision, and visual properties
        
        spawn=sim_utils.CuboidCfg(
            size=(size,size,size),
            rigid_props=sim_utils.RigidBodyPropertiesCfg(),
            mass_props=sim_utils.MassPropertiesCfg(mass=10.0),
            collision_props=sim_utils.CollisionPropertiesCfg(),
            visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.5, 0.5, 0.5)),
        )
    )

    # create the table object then return scene information
    table = RigidObject(cfg=cube_cfg)
    scene_entities = {"table": table}

    return scene_entities
    
def create_glass():
    """ Creates a glass in the scene. """

    # configure the glass object
    glass_cfg = RigidObjectCfg(
        prim_path="/World/Glass",

        # spawn a cube with rigid, mass, collision, and visual properties
        
        spawn=sim_utils.CuboidCfg(
            size=(0.1, 0.1, 0.1),
            rigid_props=sim_utils.RigidBodyPropertiesCfg(),
            mass_props=sim_utils.MassPropertiesCfg(mass=0.02),
            collision_props=sim_utils.CollisionPropertiesCfg(),
            visual_material=None,
        )
    )

    # create the glass object then return scene information
    glass = RigidObject(cfg=glass_cfg)
    
    scene_entities = {"glass": glass}

    return scene_entities

def load_reference_prim(usd_file_path, prim_path, translation=(0.0, 0.0, 0.0)):
    """Loads a specific prim and its children from a USD file using Isaac Lab."""
    
    stage = omni.usd.get_context().get_stage()
    prim = stage.DefinePrim(prim_path, "Xform")
    prim.GetReferences().AddReference(usd_file_path)

    xformable = UsdGeom.Xformable(prim)
    for name in prim.GetPropertyNames():
        if name == "xformOp:transform":
           xformable.RemoveProperty(name)
    
    if "xformOp:translate" in prim.GetPropertyNames():
        xform_op_tranlsate = UsdGeom.XformOp(prim.GetAttribute("xformOp:translate"))
    else:
        xform_op_tranlsate = xformable.AddXformOp(UsdGeom.XformOp.TypeTranslate, UsdGeom.XformOp.PrecisionDouble, "")
    xformable.SetXformOpOrder([xform_op_tranlsate])

    xform_op_tranlsate.Set(Gf.Vec3d([translation[0], translation[1], translation[2]]))
    

def design_scene():
    """ Initializes the scene. """

    SIZE = 1.0
    # ground plane
    cfg = sim_utils.GroundPlaneCfg()
    cfg.func("/World/defaultGroundPlane", cfg)
    
    # lights
    cfg = sim_utils.DomeLightCfg(intensity=2000.0, color=(0.8, 0.8, 0.8))
    cfg.func("/World/Light", cfg)

    # initialize scene entities
    scene_entities = {}
    
    # create a table in the scene
    table_entity = create_table(size=SIZE)
    glass_entity = create_glass()
    # TODO: You can load other entities in the scenes here.

    # load usd files
    usd_file_path = os.path.join(cwd, "nabi/arctos.usd")
    load_reference_prim(usd_file_path=usd_file_path,
                        prim_path="/World/arctos",
                        translation=(0.0, 0.0, SIZE))

    # adding the table to the scene entities
    scene_entities.update(table_entity)
    scene_entities.update(glass_entity)
    # TODO: You can update the scene entities with other entities here.

    return scene_entities

def run_simulator(sim: sim_utils.SimulationContext, entities: dict[str, RigidObject]):
    """ Runs the simulator. """

    # extract scene entities
    table_object = entities["table"]
    glass_object = entities["glass"]

    # define simulation stepping
    sim_dt = sim.get_physics_dt()
    sim_time = 0.0

    # simulate physics
    while simulation_app.is_running():
        table_object.write_data_to_sim()
        glass_object.write_data_to_sim()
        sim.step()
        sim_time += sim_dt
        table_object.update(sim_dt)

def main():
    """ Main function. """

    # load kit helper
    sim_cfg = sim_utils.SimulationCfg(device=args_cli.device)
    sim = sim_utils.SimulationContext(sim_cfg)

    # set main camera
    sim.set_camera_view(eye=[1.5, 0.0, 1.0], target=[0.0, 0.0, 0.0])

    # design the scene
    scene_entities = design_scene()

    # play the simulator
    sim.reset()
    print("[INFO]: TO THE MOOON!!!")

    # run the simulator
    run_simulator(sim, scene_entities)

if __name__ == "__main__":
    main()
    simulation_app.close()

import omni.isaac.lab.sim as sim_utils
from omni.isaac.lab.assets import RigidObject, RigidObjectCfg
from pxr import UsdGeom, Gf
import omni.usd

def create_table(size):
“”" Creates a table in the scene. “”"

# add size argument
if args_cli.size:
    size=args_cli.size

# configure the table object
cube_cfg = RigidObjectCfg(
    prim_path="/World/Table",

    # spawn a cube with rigid, mass, collision, and visual properties
    
    spawn=sim_utils.CuboidCfg(
        size=(size,size,size),
        rigid_props=sim_utils.RigidBodyPropertiesCfg(),
        mass_props=sim_utils.MassPropertiesCfg(mass=10.0),
        collision_props=sim_utils.CollisionPropertiesCfg(),
        visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.5, 0.5, 0.5)),
    )
)

# create the table object then return scene information
table = RigidObject(cfg=cube_cfg)
scene_entities = {"table": table}

return scene_entities

def create_glass():
“”" Creates a glass in the scene. “”"

# configure the glass object
glass_cfg = RigidObjectCfg(
    prim_path="/World/Glass",

    # spawn a cube with rigid, mass, collision, and visual properties
    
    spawn=sim_utils.CuboidCfg(
        size=(0.1, 0.1, 0.1),
        rigid_props=sim_utils.RigidBodyPropertiesCfg(),
        mass_props=sim_utils.MassPropertiesCfg(mass=0.02),
        collision_props=sim_utils.CollisionPropertiesCfg(),
        visual_material=None,
    )
)

# create the glass object then return scene information
glass = RigidObject(cfg=glass_cfg)

scene_entities = {"glass": glass}

return scene_entities

def load_reference_prim(usd_file_path, prim_path, translation=(0.0, 0.0, 0.0)):
“”“Loads a specific prim and its children from a USD file using Isaac Lab.”“”

stage = omni.usd.get_context().get_stage()
prim = stage.DefinePrim(prim_path, "Xform")
prim.GetReferences().AddReference(usd_file_path)

xformable = UsdGeom.Xformable(prim)
for name in prim.GetPropertyNames():
    if name == "xformOp:transform":
       xformable.RemoveProperty(name)

if "xformOp:translate" in prim.GetPropertyNames():
    xform_op_tranlsate = UsdGeom.XformOp(prim.GetAttribute("xformOp:translate"))
else:
    xform_op_tranlsate = xformable.AddXformOp(UsdGeom.XformOp.TypeTranslate, UsdGeom.XformOp.PrecisionDouble, "")
xformable.SetXformOpOrder([xform_op_tranlsate])

xform_op_tranlsate.Set(Gf.Vec3d([translation[0], translation[1], translation[2]]))

def design_scene():
“”" Initializes the scene. “”"

SIZE = 1.0
# ground plane
cfg = sim_utils.GroundPlaneCfg()
cfg.func("/World/defaultGroundPlane", cfg)

# lights
cfg = sim_utils.DomeLightCfg(intensity=2000.0, color=(0.8, 0.8, 0.8))
cfg.func("/World/Light", cfg)

# initialize scene entities
scene_entities = {}

# create a table in the scene
table_entity = create_table(size=SIZE)
glass_entity = create_glass()
# TODO: You can load other entities in the scenes here.

# load usd files
usd_file_path = os.path.join(cwd, "nabi/arctos.usd")
load_reference_prim(usd_file_path=usd_file_path,
                    prim_path="/World/arctos",
                    translation=(0.0, 0.0, SIZE))

# adding the table to the scene entities
scene_entities.update(table_entity)
scene_entities.update(glass_entity)
# TODO: You can update the scene entities with other entities here.

return scene_entities

def run_simulator(sim: sim_utils.SimulationContext, entities: dict[str, RigidObject]):
“”" Runs the simulator. “”"

# extract scene entities
table_object = entities["table"]
glass_object = entities["glass"]

# define simulation stepping
sim_dt = sim.get_physics_dt()
sim_time = 0.0

# simulate physics
while simulation_app.is_running():
    table_object.write_data_to_sim()
    glass_object.write_data_to_sim()
    sim.step()
    sim_time += sim_dt
    table_object.update(sim_dt)

def main():
“”" Main function. “”"

# load kit helper
sim_cfg = sim_utils.SimulationCfg(device=args_cli.device)
sim = sim_utils.SimulationContext(sim_cfg)

# set main camera
sim.set_camera_view(eye=[1.5, 0.0, 1.0], target=[0.0, 0.0, 0.0])

# design the scene
scene_entities = design_scene()

# play the simulator
sim.reset()
print("[INFO]: TO THE MOOON!!!")

# run the simulator
run_simulator(sim, scene_entities)

if name == “main”:
main()
simulation_app.close()

Thank you for your interest in Isaac Lab. To ensure efficient support and collaboration, please submit your topic to its GitHub repo following the instructions provided on Isaac Lab’s Contributing Guidelines regarding discussions, submitting issues, feature requests, and contributing to the project.

We appreciate your understanding and look forward to assisting you.