IsaacLab: [Bug Report] `base_height_l2` for rough terrain is wrong!

Describe the bug

The code added in #1525 is wrong!

Also marked in #1546

https://github.com/isaac-sim/IsaacLab/blob/b5078debe1896c449d5b3a940cebe21bf1560bd0/source/extensions/omni.isaac.lab/omni/isaac/lab/envs/mdp/rewards.py#L100-L122

sensor.data.pos_w[:, 2] is the position of sensor origin in world frame, and it is equal to asset.data.root_link_pos_w[:, 2].

In rough terrain, the func return

torch.square(asset.data.root_link_pos_w[:, 2] - adjusted_target_height) = torch.square(asset.data.root_link_pos_w[:, 2] - target_height - sensor.data.pos_w[:, 2]) = torch.square(- target_height)

This is meaningless.

I think we should take the height of the center point as the reference height, but this cannot be achieved with the current API.

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have checked that the issue is not in running Isaac Sim itself and is related to the repo

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 19 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I am also not super sure what sensor cfg should be there, i do a agree a more clear example or comment is needed to understand the useage of it. how I currently get around with this issue is exactly how you described, querying the center point of the height scanner(assume your height scanner is center around robot base), then by subtracting hit z from base z

May I ask how you get the center index?

Yes! This is the code

sensor: RayCaster = env.scene[sensor_cfg.name]
ray_hits_w = sensor.data.ray_hits_w
hit_center_z = ray_hits_w[:, ray_hits_w.shape[1] // 2, 2]

and hit center z can be treated as the z of the floor

But I think this only satisfies an odd number of points. If it is an even number, it will definitely be indexed to the edge instead of the average of the center points

Image