Skip to content

Commit eceaa0b

Browse files
Apply suggestions from code review
Co-authored-by: jtigue-bdai <166445701+jtigue-bdai@users.noreply.github.com> Signed-off-by: Pascal Roth <57946385+pascal-roth@users.noreply.github.com>
1 parent 1e45495 commit eceaa0b

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

source/extensions/omni.isaac.lab/omni/isaac/lab/sensors/imu/imu.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,16 @@ def _update_buffers_impl(self, env_ids: Sequence[int]):
146146
raise RuntimeError(
147147
"The update function must be called before the data buffers are accessed the first time."
148148
)
149+
# default to all sensors
150+
if len(env_ids) == self._num_envs:
151+
env_ids = slice(None)
149152
# obtain the poses of the sensors
150153
pos_w, quat_w = self._view.get_transforms()[env_ids].split([3, 4], dim=-1)
151154
quat_w = math_utils.convert_quat(quat_w, to="wxyz")
152155

153156
# store the poses
154-
self._data.pos_w[env_ids] = pos_w + math_utils.quat_rotate(quat_w, self._offset_pos_b)
155-
self._data.quat_w[env_ids] = math_utils.quat_mul(quat_w, self._offset_quat_b)
157+
self._data.pos_w[env_ids] = pos_w + math_utils.quat_rotate(quat_w, self._offset_pos_b[env_ids])
158+
self._data.quat_w[env_ids] = math_utils.quat_mul(quat_w, self._offset_quat_b[env_ids])
156159

157160
# get the offset from COM to link origin
158161
com_pos_b = self._view.get_coms().to(self.device).split([3, 4], dim=-1)[0]
@@ -162,21 +165,21 @@ def _update_buffers_impl(self, env_ids: Sequence[int]):
162165
# if an offset is present or the COM does not agree with the link origin, the linear velocity has to be
163166
# transformed taking the angular velocity into account
164167
lin_vel_w += torch.linalg.cross(
165-
ang_vel_w, math_utils.quat_rotate(quat_w, self._offset_pos_b - com_pos_b[env_ids]), dim=-1
168+
ang_vel_w, math_utils.quat_rotate(quat_w, self._offset_pos_b[env_ids] - com_pos_b[env_ids]), dim=-1
166169
)
167170

168171
# numerical derivative
169-
lin_acc_w = (lin_vel_w - self._prev_lin_vel_w) / self._dt + self._gravity_bias_w
170-
ang_acc_w = (ang_vel_w - self._prev_ang_vel_w) / self._dt
172+
lin_acc_w = (lin_vel_w - self._prev_lin_vel_w[env_ids]) / self._dt + self._gravity_bias_w[env_ids]
173+
ang_acc_w = (ang_vel_w - self._prev_ang_vel_w[env_ids) / self._dt
171174
# store the velocities
172175
self._data.lin_vel_b[env_ids] = math_utils.quat_rotate_inverse(self._data.quat_w[env_ids], lin_vel_w)
173176
self._data.ang_vel_b[env_ids] = math_utils.quat_rotate_inverse(self._data.quat_w[env_ids], ang_vel_w)
174177
# store the accelerations
175178
self._data.lin_acc_b[env_ids] = math_utils.quat_rotate_inverse(self._data.quat_w[env_ids], lin_acc_w)
176179
self._data.ang_acc_b[env_ids] = math_utils.quat_rotate_inverse(self._data.quat_w[env_ids], ang_acc_w)
177180

178-
self._prev_lin_vel_w[:] = lin_vel_w
179-
self._prev_ang_vel_w[:] = ang_vel_w
181+
self._prev_lin_vel_w[env_ids] = lin_vel_w
182+
self._prev_ang_vel_w[env_ids] = ang_vel_w
180183

181184
def _initialize_buffers_impl(self):
182185
"""Create buffers for storing data."""

source/extensions/omni.isaac.lab/omni/isaac/lab/sensors/imu/imu_data.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@ class ImuData:
2626
"""
2727

2828
lin_vel_b: torch.Tensor = None
29-
"""Root angular velocity in base frame.
29+
"""IMU frame angular velocity relative to the world expressed in IMU frame.
3030
3131
Shape is (N, 3), where ``N`` is the number of environments.
3232
"""
3333

3434
ang_vel_b: torch.Tensor = None
35-
"""Root angular velocity in base frame.
35+
"""IMU frame angular velocity relative to the world expressed in IMU frame.
3636
3737
Shape is (N, 3), where ``N`` is the number of environments.
3838
"""
3939

4040
lin_acc_b: torch.Tensor = None
41-
"""Root linear acceleration in base frame.
41+
"""IMU frame linear acceleration relative to the world expressed in IMU frame.
4242
4343
Shape is (N, 3), where ``N`` is the number of environments.
4444
"""
4545

4646
ang_acc_b: torch.Tensor = None
47-
"""Root angular acceleration in base frame.
47+
"""IMU frame angular acceleration relative to the world expressed in IMU frame.
4848
4949
Shape is (N, 3), where ``N`` is the number of environments.
5050
"""

0 commit comments

Comments
 (0)