Skip to content

Commit

Permalink
Removes duplicated TerminationsCfg code in G1 and H1 RoughEnvCfg (#…
Browse files Browse the repository at this point in the history
…1484)

# Description

`TerminationsCfg` is the same as `LocomotionVelocityRoughEnvCfg`, there
is no need to configure it again, just modify the corresponding name
`self.terminations.base_contact.params["sensor_cfg"].body_names`

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] 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

Co-authored-by: Kelly Guo <[email protected]>
  • Loading branch information
fan-ziqi and kellyguo11 authored Dec 5, 2024
1 parent 6f4663a commit 63bd428
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from omni.isaac.lab.managers import RewardTermCfg as RewTerm
from omni.isaac.lab.managers import SceneEntityCfg
from omni.isaac.lab.managers import TerminationTermCfg as DoneTerm
from omni.isaac.lab.utils import configclass

import omni.isaac.lab_tasks.manager_based.locomotion.velocity.mdp as mdp
Expand Down Expand Up @@ -104,21 +103,9 @@ class G1Rewards(RewardsCfg):
)


@configclass
class TerminationsCfg:
"""Termination terms for the MDP."""

time_out = DoneTerm(func=mdp.time_out, time_out=True)
base_contact = DoneTerm(
func=mdp.illegal_contact,
params={"sensor_cfg": SceneEntityCfg("contact_forces", body_names="torso_link"), "threshold": 1.0},
)


@configclass
class G1RoughEnvCfg(LocomotionVelocityRoughEnvCfg):
rewards: G1Rewards = G1Rewards()
terminations: TerminationsCfg = TerminationsCfg()

def __post_init__(self):
# post init of parent
Expand Down Expand Up @@ -163,6 +150,9 @@ def __post_init__(self):
self.commands.base_velocity.ranges.lin_vel_y = (-0.0, 0.0)
self.commands.base_velocity.ranges.ang_vel_z = (-1.0, 1.0)

# terminations
self.terminations.base_contact.params["sensor_cfg"].body_names = "torso_link"


@configclass
class G1RoughEnvCfg_PLAY(G1RoughEnvCfg):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from omni.isaac.lab.managers import RewardTermCfg as RewTerm
from omni.isaac.lab.managers import SceneEntityCfg
from omni.isaac.lab.managers import TerminationTermCfg as DoneTerm
from omni.isaac.lab.utils import configclass

import omni.isaac.lab_tasks.manager_based.locomotion.velocity.mdp as mdp
Expand Down Expand Up @@ -71,21 +70,9 @@ class H1Rewards(RewardsCfg):
)


@configclass
class TerminationsCfg:
"""Termination terms for the MDP."""

time_out = DoneTerm(func=mdp.time_out, time_out=True)
base_contact = DoneTerm(
func=mdp.illegal_contact,
params={"sensor_cfg": SceneEntityCfg("contact_forces", body_names=".*torso_link"), "threshold": 1.0},
)


@configclass
class H1RoughEnvCfg(LocomotionVelocityRoughEnvCfg):
rewards: H1Rewards = H1Rewards()
terminations: TerminationsCfg = TerminationsCfg()

def __post_init__(self):
# post init of parent
Expand Down Expand Up @@ -127,6 +114,9 @@ def __post_init__(self):
self.commands.base_velocity.ranges.lin_vel_y = (0.0, 0.0)
self.commands.base_velocity.ranges.ang_vel_z = (-1.0, 1.0)

# terminations
self.terminations.base_contact.params["sensor_cfg"].body_names = ".*torso_link"


@configclass
class H1RoughEnvCfg_PLAY(H1RoughEnvCfg):
Expand Down

0 comments on commit 63bd428

Please sign in to comment.