Script editor | UnboundLocalError: local variable 'current_physics_prim`

Hello,

I am trying to add an IMU sensor with the following simple script:

from omni.isaac.sensor import IMUSensor

base_path = "/World"

IMUSensor(f"{base_path}/imu", name="imu")

Getting the following error:

Hi @omers

Looking at the IMUSensor constructor, possible solutions could be:

  • Create IMU sensor on an existing prim

    from omni.isaac.sensor import IMUSensor
    from omni.isaac.core.prims import XFormPrim
    
    base_path = "/World"
    
    XFormPrim(prim_path=f"{base_path}/imu")
    IMUSensor(f"{base_path}/imu", name="imu")
    
  • Create a PhysicsScene prim if not exists

    from omni.isaac.sensor import IMUSensor
    from omni.isaac.core.physics_context import PhysicsContext
    
    base_path = "/World"
    
    PhysicsContext()
    IMUSensor(f"{base_path}/imu", name="imu")
    
1 Like

PhysicsContext solved it, thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.