|
| 1 | +# Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). |
| 2 | +# All rights reserved. |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: BSD-3-Clause |
| 5 | + |
| 6 | +# Copyright (c) 2022-2025, The Isaac Lab Project Developers. |
| 7 | +# All rights reserved. |
| 8 | +# |
| 9 | +# SPDX-License-Identifier: BSD-3-Clause |
| 10 | + |
| 11 | +from isaaclab.managers import EventTermCfg as EventTerm |
| 12 | +from isaaclab.managers import ObservationGroupCfg as ObsGroup |
| 13 | +from isaaclab.managers import ObservationTermCfg as ObsTerm |
| 14 | +from isaaclab.managers import SceneEntityCfg |
| 15 | +from isaaclab.utils import configclass |
| 16 | +from isaaclab.utils.noise import AdditiveUniformNoiseCfg as Unoise |
| 17 | + |
| 18 | +import isaaclab_tasks.manager_based.manipulation.reach.mdp as mdp |
| 19 | + |
| 20 | +from ...reach_env_cfg import EventCfg |
| 21 | + |
| 22 | + |
| 23 | +# Observation configurations |
| 24 | +@configclass |
| 25 | +class StateNoNoiseObservationsCfg: |
| 26 | + """Observation specifications for the MDP.""" |
| 27 | + |
| 28 | + @configclass |
| 29 | + class PolicyCfg(ObsGroup): |
| 30 | + """Observations for policy group.""" |
| 31 | + |
| 32 | + # observation terms (order preserved) |
| 33 | + joint_pos = ObsTerm(func=mdp.joint_pos_rel) |
| 34 | + joint_vel = ObsTerm(func=mdp.joint_vel_rel) |
| 35 | + pose_command = ObsTerm(func=mdp.generated_commands, params={"command_name": "ee_pose"}) |
| 36 | + actions = ObsTerm(func=mdp.last_action) |
| 37 | + |
| 38 | + def __post_init__(self): |
| 39 | + self.enable_corruption = False |
| 40 | + self.concatenate_terms = True |
| 41 | + |
| 42 | + # observation groups |
| 43 | + policy: PolicyCfg = PolicyCfg() |
| 44 | + |
| 45 | + |
| 46 | +@configclass |
| 47 | +class StateNoisyObservationsCfg: |
| 48 | + """Observation specifications for the MDP.""" |
| 49 | + |
| 50 | + @configclass |
| 51 | + class PolicyCfg(ObsGroup): |
| 52 | + """Observations for policy group.""" |
| 53 | + |
| 54 | + # observation terms (order preserved) |
| 55 | + joint_pos = ObsTerm(func=mdp.joint_pos_rel, noise=Unoise(n_min=-0.1, n_max=0.1)) |
| 56 | + joint_vel = ObsTerm(func=mdp.joint_vel_rel, noise=Unoise(n_min=-0.1, n_max=0.1)) |
| 57 | + pose_command = ObsTerm(func=mdp.generated_commands, params={"command_name": "ee_pose"}) |
| 58 | + actions = ObsTerm(func=mdp.last_action) |
| 59 | + |
| 60 | + def __post_init__(self): |
| 61 | + self.enable_corruption = True |
| 62 | + self.concatenate_terms = True |
| 63 | + |
| 64 | + # observation groups |
| 65 | + policy: PolicyCfg = PolicyCfg() |
| 66 | + |
| 67 | + |
| 68 | +@configclass |
| 69 | +class JointRandPositionFrictionEventCfg(EventCfg): |
| 70 | + |
| 71 | + reset_robot_joint_friction = EventTerm( |
| 72 | + func=mdp.randomize_joint_parameters, |
| 73 | + min_step_count_between_reset=720, |
| 74 | + mode="reset", |
| 75 | + params={ |
| 76 | + "asset_cfg": SceneEntityCfg("robot", joint_names=".*"), |
| 77 | + "friction_distribution_params": (0.9, 1.1), |
| 78 | + "operation": "scale", |
| 79 | + "distribution": "gaussian", |
| 80 | + }, |
| 81 | + ) |
| 82 | + |
| 83 | + |
| 84 | +@configclass |
| 85 | +class JointRandPositionFrictionAmartureEventCfg(JointRandPositionFrictionEventCfg): |
| 86 | + """Configuration for events.""" |
| 87 | + |
| 88 | + reset_robot_joint_amature = EventTerm( |
| 89 | + func=mdp.randomize_joint_parameters, |
| 90 | + min_step_count_between_reset=720, |
| 91 | + mode="reset", |
| 92 | + params={ |
| 93 | + "asset_cfg": SceneEntityCfg("robot", joint_names=".*"), |
| 94 | + "armature_distribution_params": (0.9, 1.1), |
| 95 | + "operation": "scale", |
| 96 | + "distribution": "gaussian", |
| 97 | + }, |
| 98 | + ) |
| 99 | + |
| 100 | + |
| 101 | +@configclass |
| 102 | +class EnvConfigurables: |
| 103 | + env: dict[str, any] = { |
| 104 | + "observations": { |
| 105 | + "state_obs_no_noise": StateNoNoiseObservationsCfg(), |
| 106 | + "state_obs_noisy": StateNoisyObservationsCfg(), |
| 107 | + }, |
| 108 | + "actions.arm_action": { |
| 109 | + "ik_abs_arm_action": mdp.DifferentialInverseKinematicsActionCfg( |
| 110 | + asset_name="robot", |
| 111 | + joint_names=["panda_joint.*"], |
| 112 | + body_name="panda_hand", |
| 113 | + controller=mdp.DifferentialIKControllerCfg( |
| 114 | + command_type="pose", use_relative_mode=False, ik_method="dls" |
| 115 | + ), |
| 116 | + body_offset=mdp.DifferentialInverseKinematicsActionCfg.OffsetCfg(pos=[0.0, 0.0, 0.107]), |
| 117 | + ), |
| 118 | + "ik_rel_arm_action": mdp.DifferentialInverseKinematicsActionCfg( |
| 119 | + asset_name="robot", |
| 120 | + joint_names=["panda_joint.*"], |
| 121 | + body_name="panda_hand", |
| 122 | + controller=mdp.DifferentialIKControllerCfg( |
| 123 | + command_type="pose", use_relative_mode=True, ik_method="dls" |
| 124 | + ), |
| 125 | + scale=0.5, |
| 126 | + body_offset=mdp.DifferentialInverseKinematicsActionCfg.OffsetCfg(pos=[0.0, 0.0, 0.107]), |
| 127 | + ), |
| 128 | + "joint_pos_arm_action": mdp.JointPositionActionCfg( |
| 129 | + asset_name="robot", joint_names=["panda_joint.*"], scale=0.5, use_default_offset=True |
| 130 | + ), |
| 131 | + "osc_arm_action": mdp.OperationalSpaceControllerActionCfg( |
| 132 | + asset_name="robot", |
| 133 | + joint_names=["panda_joint.*"], |
| 134 | + body_name="panda_hand", |
| 135 | + controller_cfg=mdp.OperationalSpaceControllerCfg( |
| 136 | + target_types=["pose_abs"], |
| 137 | + impedance_mode="variable_kp", |
| 138 | + inertial_dynamics_decoupling=True, |
| 139 | + partial_inertial_dynamics_decoupling=False, |
| 140 | + gravity_compensation=False, |
| 141 | + motion_stiffness_task=100.0, |
| 142 | + motion_damping_ratio_task=1.0, |
| 143 | + motion_stiffness_limits_task=(50.0, 200.0), |
| 144 | + nullspace_control="position", |
| 145 | + ), |
| 146 | + nullspace_joint_pos_target="center", |
| 147 | + position_scale=1.0, |
| 148 | + orientation_scale=1.0, |
| 149 | + stiffness_scale=100.0, |
| 150 | + ), |
| 151 | + }, |
| 152 | + "events": { |
| 153 | + "rand_joint_pos_friction": JointRandPositionFrictionEventCfg(), |
| 154 | + "rand_joint_pos_friction_amarture": JointRandPositionFrictionAmartureEventCfg(), |
| 155 | + }, |
| 156 | + "events.reset_robot_joints": { |
| 157 | + "aggressive": EventTerm( |
| 158 | + func=mdp.reset_joints_by_scale, |
| 159 | + mode="reset", |
| 160 | + params={ |
| 161 | + "position_range": (0.0, 2.0), |
| 162 | + "velocity_range": (0.0, 1.0), |
| 163 | + }, |
| 164 | + ), |
| 165 | + "easy": EventTerm( |
| 166 | + func=mdp.reset_joints_by_scale, |
| 167 | + mode="reset", |
| 168 | + params={ |
| 169 | + "position_range": (0.0, 0.5), |
| 170 | + "velocity_range": (0.0, 0.0), |
| 171 | + }, |
| 172 | + ), |
| 173 | + }, |
| 174 | + } |
0 commit comments