Skip to content

Commit 0cbff3d

Browse files
Should be good
1 parent 22c8750 commit 0cbff3d

File tree

5 files changed

+34
-15
lines changed

5 files changed

+34
-15
lines changed

scripts/environments/export_IODescriptors.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ def main():
4949
env.reset()
5050

5151
outs = env.unwrapped.get_IO_descriptors
52-
out = outs["observations"]
52+
out_observations = outs["observations"]
5353
out_actions = outs["actions"]
54+
out_articulations = outs["articulations"]
5455
# Make a yaml file with the output
5556
import yaml
5657

@@ -60,15 +61,25 @@ def main():
6061
with open(f"{name}_IO_descriptors.yaml", "w") as f:
6162
yaml.safe_dump(outs, f)
6263

63-
for k, v in out_actions.items():
64-
print(f"--- Action term: {k} ---")
65-
for k1, v1 in v.items():
64+
for k in out_actions:
65+
print(f"--- Action term: {k['name']} ---")
66+
k.pop("name")
67+
for k1, v1 in k.items():
6668
print(f"{k1}: {v1}")
6769

68-
for k, v in out.items():
69-
print(f"--- Obs term: {k} ---")
70-
for k1, v1 in v.items():
70+
for obs_group_name, obs_group in out_observations.items():
71+
print(f"--- Obs group: {obs_group_name} ---")
72+
for k in obs_group:
73+
print(f"--- Obs term: {k['name']} ---")
74+
k.pop("name")
75+
for k1, v1 in k.items():
76+
print(f"{k1}: {v1}")
77+
78+
for articulation_name, articulation_data in out_articulations.items():
79+
print(f"--- Articulation: {articulation_name} ---")
80+
for k1, v1 in articulation_data.items():
7181
print(f"{k1}: {v1}")
82+
7283
env.step(torch.zeros(env.action_space.shape, device=env.unwrapped.device))
7384
env.close()
7485

source/isaaclab/isaaclab/envs/manager_based_env.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from .common import VecEnvObs
2222
from .manager_based_env_cfg import ManagerBasedEnvCfg
2323
from .ui import ViewportCameraController
24-
24+
from .utils.io_descriptors import export_articulations_data
2525

2626
class ManagerBasedEnv:
2727
"""The base environment encapsulates the simulation scene and the environment managers for the manager-based workflow.
@@ -220,6 +220,7 @@ def get_IO_descriptors(self):
220220
return {
221221
"observations": self.observation_manager.get_IO_descriptors,
222222
"actions": self.action_manager.get_IO_descriptors,
223+
"articulations": export_articulations_data(self),
223224
}
224225

225226
"""

source/isaaclab/isaaclab/envs/mdp/actions/joint_actions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,11 @@ def IO_descriptor(self) -> GenericActionIODescriptor:
138138
else:
139139
self._IO_descriptor.offset = self._offset
140140
#FIXME: This is not correct. Add list support.
141-
if isinstance(self._clip, torch.Tensor):
142-
self._IO_descriptor.clip = self._clip[0].detach().cpu().numpy().tolist()
141+
if self.cfg.clip is not None:
142+
if isinstance(self._clip, torch.Tensor):
143+
self._IO_descriptor.clip = self._clip[0].detach().cpu().numpy().tolist()
144+
else:
145+
self._IO_descriptor.clip = self._clip
143146
else:
144147
self._IO_descriptor.clip = None
145148
return self._IO_descriptor

source/isaaclab/isaaclab/managers/action_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def has_debug_vis_implementation(self) -> bool:
271271
return has_debug_vis
272272

273273
@property
274-
def get_IO_descriptors(self) -> dict[str, dict[str, Any]]:
274+
def get_IO_descriptors(self) -> list[dict[str, Any]]:
275275
"""Get the IO descriptors for the action manager.
276276
277277
Returns:
@@ -286,10 +286,10 @@ def get_IO_descriptors(self) -> dict[str, dict[str, Any]]:
286286
except Exception as e:
287287
print(f"Error getting IO descriptor for term '{term_name}': {e}")
288288

289-
formatted_data = {}
289+
formatted_data = []
290290
for item in data:
291291
name = item.pop("name")
292-
formatted_item = {"extras": item.pop("extras")}
292+
formatted_item = {"name": name, "extras": item.pop("extras")}
293293
for k, v in item.items():
294294
# Check if v is a tuple and convert to list
295295
if isinstance(v, tuple):
@@ -298,7 +298,7 @@ def get_IO_descriptors(self) -> dict[str, dict[str, Any]]:
298298
formatted_item["extras"][k] = v
299299
else:
300300
formatted_item[k] = v
301-
formatted_data[name] = formatted_item
301+
formatted_data.append(formatted_item)
302302

303303
return formatted_data
304304

source/isaaclab/isaaclab/managers/observation_manager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def group_obs_concatenate(self) -> dict[str, bool]:
226226
return self._group_obs_concatenate
227227

228228
@property
229-
def get_IO_descriptors(self):
229+
def get_IO_descriptors(self, group_names_to_export: list[str] = ["policy"]):
230230
"""Get the IO descriptors for the observation manager.
231231
232232
Returns:
@@ -276,13 +276,17 @@ def get_IO_descriptors(self):
276276
# Check if v is a tuple and convert to list
277277
if isinstance(v, tuple):
278278
v = list(v)
279+
# Check if v is a tensor and convert to list
280+
if isinstance(v, torch.Tensor):
281+
v = v.detach().cpu().numpy().tolist()
279282
if k in ["scale", "clip", "history_length", "flatten_history_dim"]:
280283
formatted_item["overloads"][k] = v
281284
elif k in ["modifiers", "description", "units"]:
282285
formatted_item["extras"][k] = v
283286
else:
284287
formatted_item[k] = v
285288
formatted_data[group_name].append(formatted_item)
289+
formatted_data = {k: v for k, v in formatted_data.items() if k in group_names_to_export}
286290
return formatted_data
287291

288292
"""

0 commit comments

Comments
 (0)