Skip to content

Commit b178171

Browse files
authored
Adds unit test to check all pre-included asset configs work as expected (#511)
# Description This MR adds a test to check all the asset configurations in the `omni.isaac.orbit_assets` class work as expected. This is useful since we keep adding new checks and updates. It is good to automatically know that the assets can be initialized successfully. ## 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 `./orbit.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have run all the tests with `./orbit.sh --test` and they pass - [ ] 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 2c59cbc commit b178171

File tree

3 files changed

+82
-5
lines changed

3 files changed

+82
-5
lines changed

source/extensions/omni.isaac.orbit_assets/omni/isaac/orbit_assets/ridgeback_franka.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"panda_joint3": 0.0,
3535
"panda_joint4": -2.810,
3636
"panda_joint5": 0.0,
37-
"panda_joint6": 3.037,
37+
"panda_joint6": 2.0,
3838
"panda_joint7": 0.741,
3939
# tool
4040
"panda_finger_joint.*": 0.035,
@@ -76,8 +76,8 @@
7676
7777
The following control configuration is used:
7878
79-
* Base: velocity control with damping
80-
* Arm: position control with damping (contains default position offsets)
81-
* Hand: mimic control
79+
* Base: velocity control
80+
* Arm: position control with damping
81+
* Hand: position control with damping
8282
8383
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright (c) 2022-2024, The ORBIT Project Developers.
2+
# All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
# ignore private usage of variables warning
7+
# pyright: reportPrivateUsage=none
8+
9+
"""Launch Isaac Sim Simulator first."""
10+
11+
from omni.isaac.orbit.app import AppLauncher, run_tests
12+
13+
# launch the simulator
14+
app_launcher = AppLauncher(headless=True)
15+
simulation_app = app_launcher.app
16+
17+
18+
"""Rest everything follows."""
19+
20+
import unittest
21+
22+
import omni.isaac.orbit_assets as orbit_assets # noqa: F401
23+
24+
from omni.isaac.orbit.assets import AssetBase, AssetBaseCfg
25+
from omni.isaac.orbit.sensors import SensorBase, SensorBaseCfg
26+
from omni.isaac.orbit.sim import build_simulation_context
27+
28+
29+
class TestValidEntitiesConfigs(unittest.TestCase):
30+
"""Test cases for all registered entities configurations."""
31+
32+
@classmethod
33+
def setUpClass(cls):
34+
# load all registered entities configurations from the module
35+
cls.registered_entities: dict[str, AssetBaseCfg | SensorBaseCfg] = {}
36+
# inspect all classes from the module
37+
for obj_name in dir(orbit_assets):
38+
obj = getattr(orbit_assets, obj_name)
39+
# store all registered entities configurations
40+
if isinstance(obj, (AssetBaseCfg, SensorBaseCfg)):
41+
cls.registered_entities[obj_name] = obj
42+
# print all existing entities names
43+
print(">>> All registered entities:", list(cls.registered_entities.keys()))
44+
45+
"""
46+
Test fixtures.
47+
"""
48+
49+
def test_asset_configs(self):
50+
"""Check all registered asset configurations."""
51+
# iterate over all registered assets
52+
for asset_name, entity_cfg in self.registered_entities.items():
53+
for device in ("cuda:0", "cpu"):
54+
with self.subTest(asset_name=asset_name, device=device):
55+
with build_simulation_context(device=device, auto_add_lighting=True) as sim:
56+
# print the asset name
57+
print(">>> Testing entities:", asset_name)
58+
# name the prim path
59+
entity_cfg.prim_path = "/World/asset"
60+
# create the asset / sensors
61+
entity: AssetBase | SensorBase = entity_cfg.class_type(entity_cfg) # type: ignore
62+
63+
# play the sim
64+
sim.reset()
65+
66+
# check asset is initialized successfully
67+
self.assertTrue(entity._is_initialized)
68+
69+
70+
if __name__ == "__main__":
71+
run_tests()

source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/ant/ant_env_cfg.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ class MySceneCfg(InteractiveSceneCfg):
6565
),
6666
init_state=ArticulationCfg.InitialStateCfg(
6767
pos=(0.0, 0.0, 0.5),
68-
joint_pos={".*": 0.0},
68+
joint_pos={
69+
".*_leg": 0.0,
70+
"front_left_foot": 0.785398, # 45 degrees
71+
"front_right_foot": -0.785398,
72+
"left_back_foot": -0.785398,
73+
"right_back_foot": 0.785398,
74+
},
6975
),
7076
actuators={
7177
"body": ImplicitActuatorCfg(

0 commit comments

Comments
 (0)