-
Notifications
You must be signed in to change notification settings - Fork 2.6k
WIP: RL environment for the surface gripper #3885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
99d6eca
81ea7b1
e4c76c4
fab2d12
9e14cc2
7e7d1f1
234a74f
b139fc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||
| # Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). | ||||||
| # All rights reserved. | ||||||
| # | ||||||
| # SPDX-License-Identifier: BSD-3-Clause | ||||||
| import gymnasium as gym | ||||||
| import os | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style:
Suggested change
|
||||||
|
|
||||||
| from . import agents | ||||||
|
|
||||||
| ## | ||||||
| # Register Gym environments. | ||||||
| ## | ||||||
|
|
||||||
| ## | ||||||
| # Joint Position Control | ||||||
| ## | ||||||
|
|
||||||
| gym.register( | ||||||
| id="Isaac-Lift-Cube-UR10SG-v0", | ||||||
| entry_point="isaaclab.envs:ManagerBasedRLEnv", | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: entry point should be |
||||||
| kwargs={ | ||||||
| "env_cfg_entry_point": f"{__name__}.joint_pos_env_cfg:UR10SGCubeLiftEnvCfg", | ||||||
| "skrl_cfg_entry_point": f"{agents.__name__}:skrl_ppo_cfg.yaml", | ||||||
| }, | ||||||
| disable_env_checker=True, | ||||||
| ) | ||||||
|
Comment on lines
18
to
42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: missing additional RL framework cfg_entry_points ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: missing PLAY environment registrations ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: missing PLAY environment registrations (e.g., |
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: BSD-3-Clause |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| seed: 42 | ||
|
|
||
|
|
||
| # Models are instantiated using skrl's model instantiator utility | ||
| # https://skrl.readthedocs.io/en/latest/api/utils/model_instantiators.html | ||
| models: | ||
| separate: False | ||
| policy: # see gaussian_model parameters | ||
| class: GaussianMixin | ||
| clip_actions: False | ||
| clip_log_std: True | ||
| min_log_std: -20.0 | ||
| max_log_std: 2.0 | ||
| initial_log_std: 0.0 | ||
| network: | ||
| - name: net | ||
| input: OBSERVATIONS | ||
| layers: [256, 128, 64] | ||
| activations: elu | ||
| output: ACTIONS | ||
| value: # see deterministic_model parameters | ||
| class: DeterministicMixin | ||
| clip_actions: False | ||
| network: | ||
| - name: net | ||
| input: OBSERVATIONS | ||
| layers: [256, 128, 64] | ||
| activations: elu | ||
| output: ONE | ||
|
|
||
|
|
||
| # Rollout memory | ||
| # https://skrl.readthedocs.io/en/latest/api/memories/random.html | ||
| memory: | ||
| class: RandomMemory | ||
| memory_size: -1 # automatically determined (same as agent:rollouts) | ||
|
|
||
|
|
||
| # PPO agent configuration (field names are from PPO_DEFAULT_CONFIG) | ||
| # https://skrl.readthedocs.io/en/latest/api/agents/ppo.html | ||
| agent: | ||
| class: PPO | ||
| rollouts: 24 | ||
| learning_epochs: 8 | ||
| mini_batches: 4 | ||
| discount_factor: 0.99 | ||
| lambda: 0.95 | ||
| learning_rate: 1.0e-04 | ||
| learning_rate_scheduler: KLAdaptiveLR | ||
| learning_rate_scheduler_kwargs: | ||
| kl_threshold: 0.01 | ||
| state_preprocessor: RunningStandardScaler | ||
| state_preprocessor_kwargs: null | ||
| value_preprocessor: RunningStandardScaler | ||
| value_preprocessor_kwargs: null | ||
| random_timesteps: 0 | ||
| learning_starts: 0 | ||
| grad_norm_clip: 1.0 | ||
| ratio_clip: 0.2 | ||
| value_clip: 0.2 | ||
| clip_predicted_values: True | ||
| entropy_loss_scale: 0.001 | ||
| value_loss_scale: 2.0 | ||
| kl_threshold: 0.0 | ||
| rewards_shaper_scale: 0.01 | ||
| time_limit_bootstrap: False | ||
| # logging and checkpoint | ||
| experiment: | ||
| directory: "ur10sg_lift" | ||
| experiment_name: "" | ||
| write_interval: auto | ||
| checkpoint_interval: auto | ||
|
|
||
|
|
||
| # Sequential trainer | ||
| # https://skrl.readthedocs.io/en/latest/api/trainers/sequential.html | ||
| trainer: | ||
| class: SequentialTrainer | ||
| timesteps: 36000 | ||
| environment_info: log |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| from isaaclab.assets import RigidObjectCfg, SurfaceGripperCfg | ||
| from isaaclab.sensors import FrameTransformerCfg | ||
| from isaaclab.sensors.frame_transformer.frame_transformer_cfg import OffsetCfg | ||
| from isaaclab.sim.schemas.schemas_cfg import RigidBodyPropertiesCfg | ||
| from isaaclab.sim.spawners.from_files.from_files_cfg import UsdFileCfg | ||
| from isaaclab.utils import configclass | ||
| from isaaclab.utils.assets import ISAAC_NUCLEUS_DIR | ||
|
|
||
| from isaaclab_tasks.manager_based.manipulation.lift import mdp | ||
| from isaaclab_tasks.manager_based.manipulation.lift.lift_env_cfg import LiftEnvCfg | ||
|
|
||
| ## | ||
| # Pre-defined configs | ||
| ## | ||
| from isaaclab.markers.config import FRAME_MARKER_CFG # isort: skip | ||
| from isaaclab_assets.robots.universal_robots import UR10_SHORT_SUCTION_CFG | ||
|
|
||
| @configclass | ||
| class UR10SGCubeLiftEnvCfg(LiftEnvCfg): | ||
| def __post_init__(self): | ||
| # post init of parent | ||
| super().__post_init__() | ||
|
|
||
| # Set UR10 as robot | ||
| self.scene.robot = UR10_SHORT_SUCTION_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot") | ||
|
|
||
| # define the surface gripper | ||
| self.scene.surface_gripper = SurfaceGripperCfg( | ||
| prim_path="{ENV_REGEX_NS}/Robot/ee_link/SurfaceGripper", | ||
| max_grip_distance=0.05, | ||
| shear_force_limit=5000.0, | ||
| coaxial_force_limit=5000.0, | ||
| retry_interval=0.05, | ||
| ) | ||
|
|
||
| # Set actions for the specific robot type (UR10) | ||
| self.actions.arm_action = mdp.JointPositionActionCfg( | ||
| asset_name="robot", | ||
| joint_names=[".*_joint"], | ||
| scale=0.5, | ||
| use_default_offset=True | ||
| ) | ||
| self.actions.gripper_action = mdp.SurfaceGripperBinaryActionCfg( | ||
| asset_name="surface_gripper", | ||
| open_command=-1.0, | ||
| close_command=1.0, | ||
| ) | ||
| # Set the body name for the end effector | ||
| self.commands.object_pose.body_name = "ee_link" | ||
|
|
||
| # Set Cube as object | ||
| self.scene.object = RigidObjectCfg( | ||
| prim_path="{ENV_REGEX_NS}/Object", | ||
| init_state=RigidObjectCfg.InitialStateCfg(pos=[0.5, 0, 0.055], rot=[1, 0, 0, 0]), | ||
| spawn=UsdFileCfg( | ||
| usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/Blocks/DexCube/dex_cube_instanceable.usd", | ||
| scale=(0.8, 0.8, 0.8), | ||
| rigid_props=RigidBodyPropertiesCfg( | ||
| solver_position_iteration_count=16, | ||
| solver_velocity_iteration_count=1, | ||
| max_angular_velocity=1000.0, | ||
| max_linear_velocity=1000.0, | ||
| max_depenetration_velocity=5.0, | ||
| disable_gravity=False, | ||
| ), | ||
| ), | ||
| ) | ||
|
|
||
| # Listens to the required transforms | ||
| marker_cfg = FRAME_MARKER_CFG.copy() | ||
| marker_cfg.markers["frame"].scale = (0.1, 0.1, 0.1) | ||
| marker_cfg.prim_path = "/Visuals/FrameTransformer" | ||
|
|
||
| self.scene.ee_frame = FrameTransformerCfg( | ||
| prim_path="{ENV_REGEX_NS}/Robot/base_link", | ||
| debug_vis=True, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: debug visualization is enabled for production code - consider setting |
||
| visualizer_cfg=marker_cfg, | ||
| target_frames=[ | ||
| FrameTransformerCfg.FrameCfg( | ||
| prim_path="{ENV_REGEX_NS}/Robot/ee_link", | ||
| name="end_effector", | ||
| offset=OffsetCfg( | ||
| pos=[0.1585, 0.0, 0.0], | ||
| ), | ||
| ), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| @configclass | ||
| class UR10SGCubeLiftEnvCfg_PLAY(UR10SGCubeLiftEnvCfg): | ||
| def __post_init__(self): | ||
| # post init of parent | ||
| super().__post_init__() | ||
| # make a smaller scene for play | ||
| self.scene.num_envs = 50 | ||
| self.scene.env_spacing = 2.5 | ||
| # disable randomization for play | ||
| self.observations.policy.enable_corruption = False | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: changed wrist_2_joint from 1.5707 to -1.5707 (90° rotation). Check that this new pose is correct for the surface gripper orientation and doesn't cause collisions or unexpected behavior in existing environments using
UR10_LONG_SUCTION_CFG