Unverified Commit b1781712 authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

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
parent 2c59cbc5
...@@ -34,7 +34,7 @@ RIDGEBACK_FRANKA_PANDA_CFG = ArticulationCfg( ...@@ -34,7 +34,7 @@ RIDGEBACK_FRANKA_PANDA_CFG = ArticulationCfg(
"panda_joint3": 0.0, "panda_joint3": 0.0,
"panda_joint4": -2.810, "panda_joint4": -2.810,
"panda_joint5": 0.0, "panda_joint5": 0.0,
"panda_joint6": 3.037, "panda_joint6": 2.0,
"panda_joint7": 0.741, "panda_joint7": 0.741,
# tool # tool
"panda_finger_joint.*": 0.035, "panda_finger_joint.*": 0.035,
...@@ -76,8 +76,8 @@ RIDGEBACK_FRANKA_PANDA_CFG = ArticulationCfg( ...@@ -76,8 +76,8 @@ RIDGEBACK_FRANKA_PANDA_CFG = ArticulationCfg(
The following control configuration is used: The following control configuration is used:
* Base: velocity control with damping * Base: velocity control
* Arm: position control with damping (contains default position offsets) * Arm: position control with damping
* Hand: mimic control * Hand: position control with damping
""" """
# Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
# ignore private usage of variables warning
# pyright: reportPrivateUsage=none
"""Launch Isaac Sim Simulator first."""
from omni.isaac.orbit.app import AppLauncher, run_tests
# launch the simulator
app_launcher = AppLauncher(headless=True)
simulation_app = app_launcher.app
"""Rest everything follows."""
import unittest
import omni.isaac.orbit_assets as orbit_assets # noqa: F401
from omni.isaac.orbit.assets import AssetBase, AssetBaseCfg
from omni.isaac.orbit.sensors import SensorBase, SensorBaseCfg
from omni.isaac.orbit.sim import build_simulation_context
class TestValidEntitiesConfigs(unittest.TestCase):
"""Test cases for all registered entities configurations."""
@classmethod
def setUpClass(cls):
# load all registered entities configurations from the module
cls.registered_entities: dict[str, AssetBaseCfg | SensorBaseCfg] = {}
# inspect all classes from the module
for obj_name in dir(orbit_assets):
obj = getattr(orbit_assets, obj_name)
# store all registered entities configurations
if isinstance(obj, (AssetBaseCfg, SensorBaseCfg)):
cls.registered_entities[obj_name] = obj
# print all existing entities names
print(">>> All registered entities:", list(cls.registered_entities.keys()))
"""
Test fixtures.
"""
def test_asset_configs(self):
"""Check all registered asset configurations."""
# iterate over all registered assets
for asset_name, entity_cfg in self.registered_entities.items():
for device in ("cuda:0", "cpu"):
with self.subTest(asset_name=asset_name, device=device):
with build_simulation_context(device=device, auto_add_lighting=True) as sim:
# print the asset name
print(">>> Testing entities:", asset_name)
# name the prim path
entity_cfg.prim_path = "/World/asset"
# create the asset / sensors
entity: AssetBase | SensorBase = entity_cfg.class_type(entity_cfg) # type: ignore
# play the sim
sim.reset()
# check asset is initialized successfully
self.assertTrue(entity._is_initialized)
if __name__ == "__main__":
run_tests()
...@@ -65,7 +65,13 @@ class MySceneCfg(InteractiveSceneCfg): ...@@ -65,7 +65,13 @@ class MySceneCfg(InteractiveSceneCfg):
), ),
init_state=ArticulationCfg.InitialStateCfg( init_state=ArticulationCfg.InitialStateCfg(
pos=(0.0, 0.0, 0.5), pos=(0.0, 0.0, 0.5),
joint_pos={".*": 0.0}, joint_pos={
".*_leg": 0.0,
"front_left_foot": 0.785398, # 45 degrees
"front_right_foot": -0.785398,
"left_back_foot": -0.785398,
"right_back_foot": 0.785398,
},
), ),
actuators={ actuators={
"body": ImplicitActuatorCfg( "body": ImplicitActuatorCfg(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment