You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Question] IMU Sensor Requires RigidBodyAPI on Target Prim #3088
raiseRuntimeError(f"Failed to find a RigidBodyAPI for the prim paths: {self.cfg.prim_path}")
Question
Is it required that the target prim for an IMU sensor has RigidBodyAPI?
I was expecting it to be possible to attach IMUs to arbitrary (static or articulated) frames, not just rigid bodies.
I tried to dig a bit into the problem and I realized that the IMU class calls create_rigid_body_view() and then, every frame, uses that view’s get_transforms(), get_velocities(), and get_coms() methods. All three calls rely on the prim owning a UsdPhysics.RigidBodyAPI handle. Indeed, the key point is that PhysX only tracks pose, velocity, and COM buffers for rigid bodies. If the prim pointed is just an Xform (as in my case) it has no rigid-body data it is not possible to call that function.
TLDR: the sensor grabs its data straight from PhysX’s rigid-body buffers, so it can only attach to prims that are rigid bodies. Anything else fails because the required physics data isn’t there.
I'm currently modifing the imu sensor to give the user the possibility to set a prim that is just an Xform.
Obtaining this data from an Xform by using an XformPrimView is typically expensive since that goes through USD APIs. The best way to do this is to always get a rigid body prim and specify an offset to the prim to the location on the body that you want to measure.
Obtaining this data from an Xform by using an XformPrimView is typically expensive since that goes through USD APIs. The best way to do this is to always get a rigid body prim and specify an offset to the prim to the location on the body that you want to measure.
Yes, I agree on that, but what do you think about computing this transformation once only in the __init__ of the class? That way we can still rely on the RigidBodyView during simulation for performance, but support attaching the IMU to non-rigid prims (like Xforms) by resolving the fixed transform once and applying it to the configured offset.
On the other hand, are there any programmatic ways to calculate the offset in IsaacLab, or should I write a separate script that does it? I could traverse the USD hierarchy manually using UsdGeom.XformCache to get the relative transform from the rigid body to the IMU frame, but if there’s already a utility for that in the IsaacLab codebase, I’d rather reuse it.
@GiulioRomualdi that's a reasonable solution. In the past, we did not support it because the URDF importer was not saving the "Xform" prims in the USD for collapsed links. Now that it does that, we can think of a way to automate this process to compute the offset automatically on initialization.
There are two possible organizations of Xform that we would have to deal with:
Xform is under a rigid body:
Robot
-- Link_A
-- Link_B
-- Xform
Xform is outside any rigid body
Robot
-- Link_A
-- Link_B
-- Xform
If a user specifies the path to the "Xform" it becomes unclear w.r.t. which rigid body prim this must be computed (for the second case). One possible solution is that we add another attribute to SensorCfg.OffsetCfg that can be used to specify the prim path to the Xform and automate the calculation of the offset for it w.r.t. rigid body path specified in the SensorCfg.prim_path. Though this ends up requiring to specify two prim paths.
Are there any programmatic ways to calculate the offset in IsaacLab, or should I write a separate script that does it?
I don't think there's a function for this. Only snippet I found was in the environment implementation for one of the direct envs
I've iterated further on the problem and found that it also affects other sensors, such as FrameTransform. So, I tried to implement a more general solution.
In the end, I believe what a final user really needs is a function that can easily find the rigid body ancestor of a given prim and compute the corresponding offset. This way, we can use the same function (for IMU sensors, FrameTransform, etc.) to programmatically specify the offset.
To achieve this, I implemented a simple Python function that takes a USD file and returns both the offset and the ancestor to the user. I think this solution is more self-contained and provides a reasonable workaround for the issue.
fromtypingimportTuplefrompxrimportUsd, UsdGeom, UsdPhysics, Sdf, Gfdef_as_wxyz(q: Gf.Quatd) ->Tuple[float, float, float, float]:
im=q.GetImaginary()
return (float(q.GetReal()), float(im[0]), float(im[1]), float(im[2]))
def_robot_root_from_prim_path(prim_path: str) ->str:
""" Deduce a robot root from a concrete path. - '/Foo/...' -> '/Foo' - '/World/Foo/...' -> '/World/Foo' """parts= [pforpinprim_path.strip("/").split("/") ifp]
ifnotparts:
raiseValueError(f"Invalid prim_path: {prim_path!r}")
ifparts[0] =="World":
iflen(parts) <2:
raiseValueError(f"Path under /World must have at least two segments: {prim_path!r}")
returnf"/{parts[0]}/{parts[1]}"returnf"/{parts[0]}"defresolve_rigid_ancestor_and_offset_from_usd(
usd_path: str,
prim_path: str,
ENV_REGEX_PARENT: str="{ENV_REGEX_NS}/Robot"time_code: Usd.TimeCode=Usd.TimeCode.Default(),
) ->Tuple[str, Tuple[float, float, float], Tuple[float, float, float, float]]:
""" Open `usd_path`, find `prim_path`, walk up to the nearest ancestor with UsdPhysics.RigidBodyAPI, and return: parent_path: "ENV_REGEX_PARENT[/<relative path from robot root to rigid ancestor>]" pos (x, y, z): offset from that rigid ancestor to the child prim rot (w, x, y, z): offset quaternion (ancestor to child) """stage=Usd.Stage.Open(usd_path)
ifstageisNone:
raiseRuntimeError(f"Could not open USD: '{usd_path}'")
child=stage.GetPrimAtPath(prim_path)
ifnotchildornotchild.IsValid():
raiseRuntimeError(f"Prim '{prim_path}' not found or invalid in '{usd_path}'")
# Find nearest rigid-body ancestorrigid=childwhilerigidandrigid.IsValid():
ifrigid.HasAPI(UsdPhysics.RigidBodyAPI):
breakrigid=rigid.GetParent()
ifnotrigidornotrigid.IsValid() ornotrigid.HasAPI(UsdPhysics.RigidBodyAPI):
raiseRuntimeError(
f"No rigid-body ancestor found for '{prim_path}' in '{usd_path}'. ""Ensure a parent Xform has UsdPhysics.RigidBodyAPI applied."
)
# Compute relative transform (ancestor -> child)xfc=UsdGeom.XformCache(time_code)
rel=xfc.GetLocalToWorldTransform(rigid).GetInverse() *xfc.GetLocalToWorldTransform(child)
rel.Orthonormalize()
pos=rel.ExtractTranslation()
quat=rel.ExtractRotationQuat()
# Tokenize the returned parent pathrobot_root_path=_robot_root_from_prim_path(prim_path)
rigid_path=rigid.GetPath().pathStringifnotrigid_path.startswith(robot_root_path):
# Fallback: if robot root can't be deduced, use token roottoken_parent=ENV_REGEX_PARENTelse:
rel_path=rigid_path[len(robot_root_path):] # e.g. "/root_link" or ""token_parent=ENV_REGEX_PARENT+rel_path# preserves leading '/'pos_tuple= (float(pos[0]), float(pos[1]), float(pos[2]))
rot_tuple=_as_wxyz(quat)
returntoken_parent, pos_tuple, rot_tuple
Thanks for the detailed trace and for opening #3094, @GiulioRomualdi. The capability ships now: the IMU resolves the closest rigid-body ancestor of the target prim, computes the fixed ancestor→target transform once at initialization, and composes it with the configured sensor offset — so pointing the sensor at a plain Xform like waist_imu_0 just works. It landed in #3864 (see source/isaaclab/isaaclab/sensors/imu/base_imu.py and source/isaaclab_physx/isaaclab_physx/sensors/imu/imu.py).
Closing as resolved — please reopen if it doesn't behave as expected on a current release.
🤖 This issue was reviewed as part of an AI-assisted triage of the Isaac Lab backlog, with automated verification against the current codebase. If we got this wrong, please reopen — we'd rather hear about it!
Activity
GiulioRomualdi commentedon Aug 5, 2025
I tried to dig a bit into the problem and I realized that the IMU class calls
create_rigid_body_view()and then, every frame, uses that view’sget_transforms(),get_velocities(), andget_coms()methods. All three calls rely on the prim owning aUsdPhysics.RigidBodyAPIhandle. Indeed, the key point is thatPhysXonly tracks pose, velocity, and COM buffers for rigid bodies. If the prim pointed is just anXform(as in my case) it has no rigid-body data it is not possible to call that function.TLDR: the sensor grabs its data straight from PhysX’s rigid-body buffers, so it can only attach to prims that are rigid bodies. Anything else fails because the required physics data isn’t there.
I'm currently modifing the imu sensor to give the user the possibility to set a prim that is just an
Xform.Mayankm96 commentedon Aug 5, 2025
Obtaining this data from an
Xformby using anXformPrimViewis typically expensive since that goes through USD APIs. The best way to do this is to always get a rigid body prim and specify an offset to the prim to the location on the body that you want to measure.The offset is specified through the
ImuCfg.OffsetCfg.GiulioRomualdi commentedon Aug 5, 2025
Yes, I agree on that, but what do you think about computing this transformation once only in the
__init__of the class? That way we can still rely on the RigidBodyView during simulation for performance, but support attaching the IMU to non-rigid prims (likeXforms) by resolving the fixed transform once and applying it to the configured offset.On the other hand, are there any programmatic ways to calculate the offset in
IsaacLab, or should I write a separate script that does it? I could traverse the USD hierarchy manually usingUsdGeom.XformCacheto get the relative transform from the rigid body to the IMU frame, but if there’s already a utility for that in theIsaacLabcodebase, I’d rather reuse it.Mayankm96 commentedon Aug 5, 2025
@GiulioRomualdi that's a reasonable solution. In the past, we did not support it because the URDF importer was not saving the "Xform" prims in the USD for collapsed links. Now that it does that, we can think of a way to automate this process to compute the offset automatically on initialization.
There are two possible organizations of Xform that we would have to deal with:
Xform is under a rigid body:
Xform is outside any rigid body
If a user specifies the path to the "Xform" it becomes unclear w.r.t. which rigid body prim this must be computed (for the second case). One possible solution is that we add another attribute to
SensorCfg.OffsetCfgthat can be used to specify the prim path to the Xform and automate the calculation of the offset for it w.r.t. rigid body path specified in theSensorCfg.prim_path. Though this ends up requiring to specify two prim paths.I don't think there's a function for this. Only snippet I found was in the environment implementation for one of the direct envs
Looping @pascal-roth for this discussion as well.
GiulioRomualdi commentedon Aug 5, 2025
Thank you for replying. Since I think it’s easier to discuss in front of the code, I’ve opened a PR that we can iterate on #3094
GiulioRomualdi commentedon Aug 6, 2025
I've iterated further on the problem and found that it also affects other sensors, such as
FrameTransform. So, I tried to implement a more general solution.In the end, I believe what a final user really needs is a function that can easily find the rigid body ancestor of a given prim and compute the corresponding offset. This way, we can use the same function (for IMU sensors,
FrameTransform, etc.) to programmatically specify the offset.To achieve this, I implemented a simple Python function that takes a USD file and returns both the offset and the ancestor to the user. I think this solution is more self-contained and provides a reasonable workaround for the issue.
The function can be called as
Mayankm96 commentedon Aug 10, 2025
Yes, we likely need to make a more generic structure to have in all the sensors.
Adding @jtigue-bdai and @ooctipus to follow-up on this.
Adds automatic transform discovery for imu sensors to a viable parent…
Adds automatic transform discovery for imu sensors to a viable parent…
Adds automatic transform discovery for imu sensors to a viable parent…
Adds automatic transform discovery for imu sensors to a viable parent…
Adds automatic transform discovery for imu sensors to a viable parent…
AntoineRichard commentedon Aug 27, 2026
Thanks for the detailed trace and for opening #3094, @GiulioRomualdi. The capability ships now: the IMU resolves the closest rigid-body ancestor of the target prim, computes the fixed ancestor→target transform once at initialization, and composes it with the configured sensor offset — so pointing the sensor at a plain
Xformlikewaist_imu_0just works. It landed in #3864 (seesource/isaaclab/isaaclab/sensors/imu/base_imu.pyandsource/isaaclab_physx/isaaclab_physx/sensors/imu/imu.py).Closing as resolved — please reopen if it doesn't behave as expected on a current release.
🤖 This issue was reviewed as part of an AI-assisted triage of the Isaac Lab backlog, with automated verification against the current codebase. If we got this wrong, please reopen — we'd rather hear about it!