Skip to content

Commit efef0a9

Browse files
authored
Adds freeze option in NavigationSE2Action, improves observation MDPs (#7)
# Description **Added** - Added ``freeze_low_level_policy`` option to :`NavigationSE2ActionCfg` to allow to not freeze the low level policy. - Added ``nan_fill_value`` option to `camera_image` to allow to fill NaNs with a specific value. **Changed** - Updated `height_scan_clipped` to make clipping optional. ## Type of change - New feature (non-breaking change which adds functionality) ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./formatter.sh` - [ ] I have made corresponding changes to the documentation (will come shortly) - [x] My changes generate no new warnings - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there
1 parent 8b899bd commit efef0a9

File tree

6 files changed

+40
-12
lines changed

6 files changed

+40
-12
lines changed

exts/nav_tasks/config/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
# Note: Semantic Versioning is used: https://semver.org/
4-
version = "0.3.10"
4+
version = "0.3.11"
55

66
# Description
77
title = "IsaacLab Navigation RL Tasks"

exts/nav_tasks/docs/CHANGELOG.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
Changelog
22
---------
33

4+
5+
0.3.11 (2025-08-13)
6+
~~~~~~~~~~~~~~~~~~
7+
8+
Added
9+
^^^^^
10+
11+
- Added ``freeze_low_level_policy`` option to :class:`nav_tasks.mdp.actions.NavigationSE2ActionCfg` to allow to not freeze the low level policy.
12+
- Added ``nan_fill_value`` option to :func:`nav_tasks.mdp.observations.camera_observations:camera_image` to allow to fill NaNs with a specific value.
13+
14+
Changed
15+
^^^^^^^
16+
17+
- Updated :func:`nav_tasks.mdp.observations.height_scan_observations:height_scan_clipped` to make clipping optional.
18+
19+
420
0.3.10 (2025-08-08)
521
~~~~~~~~~~~~~~~~~~
622

exts/nav_tasks/nav_tasks/mdp/actions/navigation_actions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def __init__(self, cfg: NavigationSE2ActionCfg, env: ManagerBasedRLEnv):
3030
# load policies
3131
file_bytes = read_file(self.cfg.low_level_policy_file)
3232
self.low_level_policy = torch.jit.load(file_bytes, map_location=self.device)
33-
self.low_level_policy = torch.jit.freeze(self.low_level_policy.eval())
33+
self.low_level_policy.eval()
34+
if self.cfg.freeze_low_level_policy:
35+
self.low_level_policy = torch.jit.freeze(self.low_level_policy)
3436

3537
# prepare joint position actions
3638
if not isinstance(self.cfg.low_level_action, list):

exts/nav_tasks/nav_tasks/mdp/actions/navigation_actions_cfg.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class NavigationSE2ActionCfg(ActionTermCfg):
2828
low_level_policy_file: str = MISSING
2929
"""Path to the low level policy file."""
3030

31+
freeze_low_level_policy: bool = True
32+
"""Whether to freeze the low level policy.
33+
34+
Can improve performance but will also eliminate possible functions such as `reset`."""
35+
3136
low_level_obs_group: str = "low_level_policy"
3237
"""Observation group of the low level policy."""
3338

exts/nav_tasks/nav_tasks/mdp/observations/camera_observations.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222

2323

2424
def camera_image(
25-
env: ManagerBasedEnv, sensor_cfg: SceneEntityCfg, data_type: str = "distance_to_image_plane", flatten: bool = False
25+
env: ManagerBasedEnv,
26+
sensor_cfg: SceneEntityCfg,
27+
data_type: str = "distance_to_image_plane",
28+
flatten: bool = False,
29+
nan_fill_value: float | None = None,
2630
) -> torch.Tensor:
2731
"""Camera image Observations.
2832
@@ -34,6 +38,7 @@ def camera_image(
3438
sensor_cfg: The name of the sensor.
3539
data_type: The type of data to extract from the sensor. Default is "distance_to_image_plane".
3640
flatten: If True, the image will be flattened to 1D. Default is False.
41+
nan_fill_value: The value to fill nan/inf values with. If None, the maximum distance of the sensor will be used.
3742
3843
Returns:
3944
The image data."""
@@ -43,8 +48,9 @@ def camera_image(
4348
img = sensor.data.output[data_type].clone()
4449

4550
if data_type == "distance_to_image_plane":
46-
img[torch.isnan(img)] = sensor.cfg.max_distance
47-
img[torch.isinf(img)] = sensor.cfg.max_distance
51+
if nan_fill_value is None:
52+
nan_fill_value = sensor.cfg.max_distance
53+
img = torch.nan_to_num(img, nan=nan_fill_value, posinf=nan_fill_value, neginf=0.0)
4854

4955
# if type torch.uint8, convert to float and scale between 0 and 1
5056
if img.dtype == torch.uint8:

exts/nav_tasks/nav_tasks/mdp/observations/height_scan_observations.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,15 @@ def height_scan_clipped(
4949
env: ManagerBasedRLEnv,
5050
sensor_cfg: SceneEntityCfg,
5151
offset: float = 0.5,
52-
clip_height: tuple[float, float] = (-1.0, 0.5),
52+
clip_height: tuple[float, float] | None = (-1.0, 0.5),
5353
) -> torch.Tensor:
54-
"""Height scan from the given sensor w.r.t. the sensor's frame.
55-
56-
The provided offset (Defaults to 0.5) is subtracted from the returned values.
57-
"""
54+
"""Height scan from the given sensor w.r.t. the sensor's frame."""
5855
# get the bounded height scan
5956
height = height_scan_bounded(env, sensor_cfg, offset)
60-
# clip to max observable height
61-
return torch.clip(height, clip_height[0], clip_height[1])
57+
if clip_height is not None:
58+
# clip to max observable height
59+
height = torch.clip(height, clip_height[0], clip_height[1])
60+
return height
6261

6362

6463
def height_scan_square(

0 commit comments

Comments
 (0)