isaaclab_mimic.envs#
Sub-package with environment wrappers for Isaac Lab Mimic.
Classes
Isaac Lab Mimic environment wrapper class for Franka Cube Stack IK Rel env. |
|
Isaac Lab Mimic environment config class for Franka Cube Stack IK Rel env. |
Franka Cube Stack IK Rel Mimic Env#
- class isaaclab_mimic.envs.FrankaCubeStackIKRelMimicEnv[source]#
Isaac Lab Mimic environment wrapper class for Franka Cube Stack IK Rel env.
Methods:
get_robot_eef_pose
(eef_name[, env_ids])Get current robot end effector pose.
target_eef_pose_to_action
(...[, noise, env_id])Takes a target pose and gripper action for the end effector controller and returns an action (usually a normalized delta pose action) to try and achieve that target pose.
action_to_target_eef_pose
(action)Converts action (compatible with env.step) to a target pose for the end effector controller.
actions_to_gripper_actions
(actions)Extracts the gripper actuation part from a sequence of env actions (compatible with env.step).
get_subtask_term_signals
([env_ids])Gets a dictionary of termination signal flags for each subtask in a task.
__init__
(cfg[, render_mode])Initialize the environment.
close
()Cleanup for the environment.
get_object_poses
([env_ids])Gets the pose of each object relevant to Isaac Lab Mimic data generation in the current scene.
get_wrapper_attr
(name)Gets the attribute name from the environment.
has_wrapper_attr
(name)Checks if the attribute name exists in the environment.
Load the managers for the environment.
render
([recompute])Run rendering without stepping through the physics.
reset
([seed, env_ids, options])Resets the specified environments and returns observations.
reset_to
(state, env_ids[, seed, is_relative])Resets specified environments to known states.
seed
([seed])Set the seed for the environment.
Save all information needed to re-instantiate this environment in a dictionary.
set_wrapper_attr
(name, value, *[, force])Sets the attribute name on the environment with value, see Wrapper.set_wrapper_attr for more info.
Creates live visualizers for manager terms.
step
(action)Execute one time-step of the environment's dynamics and reset terminated environments.
Attributes:
The device on which the environment is running.
Whether the environment is a vectorized environment.
Maximum episode length in environment steps.
Maximum episode length in seconds.
Metadata for the environment.
Returns the environment's internal
_np_random
that if not set will initialise with a random seed.Returns the environment's internal
_np_random_seed
that if not set will first initialise with a random int as seed.The number of instances of the environment that are running.
The physics time-step (in s).
The environment stepping time-step (in s).
Returns the base non-wrapped environment.
Configuration for the environment.
- get_robot_eef_pose(eef_name: str, env_ids: Sequence[int] | None = None) torch.Tensor [source]#
Get current robot end effector pose. Should be the same frame as used by the robot end-effector controller.
- Parameters:
eef_name – Name of the end effector.
env_ids – Environment indices to get the pose for. If None, all envs are considered.
- Returns:
A torch.Tensor eef pose matrix. Shape is (len(env_ids), 4, 4)
- target_eef_pose_to_action(target_eef_pose_dict: dict, gripper_action_dict: dict, noise: float | None = None, env_id: int = 0) torch.Tensor [source]#
Takes a target pose and gripper action for the end effector controller and returns an action (usually a normalized delta pose action) to try and achieve that target pose. Noise is added to the target pose action if specified.
- Parameters:
target_eef_pose_dict – Dictionary of 4x4 target eef pose for each end-effector.
gripper_action_dict – Dictionary of gripper actions for each end-effector.
noise – Noise to add to the action. If None, no noise is added.
env_id – Environment index to get the action for.
- Returns:
An action torch.Tensor that’s compatible with env.step().
- action_to_target_eef_pose(action: torch.Tensor) dict[str, torch.Tensor] [source]#
Converts action (compatible with env.step) to a target pose for the end effector controller. Inverse of @target_eef_pose_to_action. Usually used to infer a sequence of target controller poses from a demonstration trajectory using the recorded actions.
- Parameters:
action – Environment action. Shape is (num_envs, action_dim)
- Returns:
A dictionary of eef pose torch.Tensor that @action corresponds to
- actions_to_gripper_actions(actions: torch.Tensor) dict[str, torch.Tensor] [source]#
Extracts the gripper actuation part from a sequence of env actions (compatible with env.step).
- Parameters:
actions – environment actions. The shape is (num_envs, num steps in a demo, action_dim).
- Returns:
A dictionary of torch.Tensor gripper actions. Key to each dict is an eef_name.
- get_subtask_term_signals(env_ids: Sequence[int] | None = None) dict[str, torch.Tensor] [source]#
Gets a dictionary of termination signal flags for each subtask in a task. The flag is 1 when the subtask has been completed and 0 otherwise. The implementation of this method is required if intending to enable automatic subtask term signal annotation when running the dataset annotation tool. This method can be kept unimplemented if intending to use manual subtask term signal annotation.
- Parameters:
env_ids – Environment indices to get the termination signals for. If None, all envs are considered.
- Returns:
A dictionary termination signal flags (False or True) for each subtask.
- __init__(cfg: ManagerBasedRLEnvCfg, render_mode: str | None = None, **kwargs)#
Initialize the environment.
- Parameters:
cfg – The configuration for the environment.
render_mode – The render mode for the environment. Defaults to None, which is similar to
"human"
.
- close()#
Cleanup for the environment.
- property device#
The device on which the environment is running.
- get_object_poses(env_ids: Sequence[int] | None = None)#
Gets the pose of each object relevant to Isaac Lab Mimic data generation in the current scene.
- Parameters:
env_ids – Environment indices to get the pose for. If None, all envs are considered.
- Returns:
A dictionary that maps object names to object pose matrix (4x4 torch.Tensor)
- load_managers()#
Load the managers for the environment.
This function is responsible for creating the various managers (action, observation, events, etc.) for the environment. Since the managers require access to physics handles, they can only be created after the simulator is reset (i.e. played for the first time).
Note
In case of standalone application (when running simulator from Python), the function is called automatically when the class is initialized.
However, in case of extension mode, the user must call this function manually after the simulator is reset. This is because the simulator is only reset when the user calls
SimulationContext.reset_async()
and it isn’t possible to call async functions in the constructor.
- metadata: ClassVar[dict[str, Any]] = {'isaac_sim_version': isaacsim.core.version.get_version, 'render_modes': [None, 'human', 'rgb_array']}#
Metadata for the environment.
- property np_random: numpy.random.Generator#
Returns the environment’s internal
_np_random
that if not set will initialise with a random seed.- Returns:
Instances of np.random.Generator
- property np_random_seed: int#
Returns the environment’s internal
_np_random_seed
that if not set will first initialise with a random int as seed.If
np_random_seed
was set directly instead of throughreset()
orset_np_random_through_seed()
, the seed will take the value -1.- Returns:
the seed of the current np_random or -1, if the seed of the rng is unknown
- Return type:
- property physics_dt: float#
The physics time-step (in s).
This is the lowest time-decimation at which the simulation is happening.
- render(recompute: bool = False) np.ndarray | None #
Run rendering without stepping through the physics.
By convention, if mode is:
human: Render to the current display and return nothing. Usually for human consumption.
rgb_array: Return an numpy.ndarray with shape (x, y, 3), representing RGB values for an x-by-y pixel image, suitable for turning into a video.
- Parameters:
recompute – Whether to force a render even if the simulator has already rendered the scene. Defaults to False.
- Returns:
The rendered image as a numpy array if mode is “rgb_array”. Otherwise, returns None.
- Raises:
RuntimeError – If mode is set to “rgb_data” and simulation render mode does not support it. In this case, the simulation render mode must be set to
RenderMode.PARTIAL_RENDERING
orRenderMode.FULL_RENDERING
.NotImplementedError – If an unsupported rendering mode is specified.
- reset(seed: int | None = None, env_ids: Sequence[int] | None = None, options: dict[str, Any] | None = None) tuple[Dict[str, Union[torch.Tensor, Dict[str, torch.Tensor]]], dict] #
Resets the specified environments and returns observations.
This function calls the
_reset_idx()
function to reset the specified environments. However, certain operations, such as procedural terrain generation, that happened during initialization are not repeated.- Parameters:
seed – The seed to use for randomization. Defaults to None, in which case the seed is not set.
env_ids – The environment ids to reset. Defaults to None, in which case all environments are reset.
options –
Additional information to specify how the environment is reset. Defaults to None.
Note
This argument is used for compatibility with Gymnasium environment definition.
- Returns:
A tuple containing the observations and extras.
- reset_to(state: dict[str, dict[str, dict[str, torch.Tensor]]], env_ids: Sequence[int] | None, seed: int | None = None, is_relative: bool = False) None #
Resets specified environments to known states.
Note that this is different from reset() function as it resets the environments to specific states
- Parameters:
state – The state to reset the specified environments to.
env_ids – The environment ids to reset. Defaults to None, in which case all environments are reset.
seed – The seed to use for randomization. Defaults to None, in which case the seed is not set.
is_relative – If set to True, the state is considered relative to the environment origins. Defaults to False.
- static seed(seed: int = -1) int #
Set the seed for the environment.
- Parameters:
seed – The seed for random generator. Defaults to -1.
- Returns:
The seed used for random generator.
- serialize()#
Save all information needed to re-instantiate this environment in a dictionary. This is the same as @env_meta - environment metadata stored in hdf5 datasets, and used in utils/env_utils.py.
- set_wrapper_attr(name: str, value: Any, *, force: bool = True) bool #
Sets the attribute name on the environment with value, see Wrapper.set_wrapper_attr for more info.
- setup_manager_visualizers()#
Creates live visualizers for manager terms.
- step(action: torch.Tensor) tuple[Dict[str, Union[torch.Tensor, Dict[str, torch.Tensor]]], torch.Tensor, torch.Tensor, torch.Tensor, dict] #
Execute one time-step of the environment’s dynamics and reset terminated environments.
Unlike the
ManagerBasedEnv.step
class, the function performs the following operations:Process the actions.
Perform physics stepping.
Perform rendering if gui is enabled.
Update the environment counters and compute the rewards and terminations.
Reset the environments that terminated.
Compute the observations.
Return the observations, rewards, resets and extras.
- Parameters:
action – The actions to apply on the environment. Shape is (num_envs, action_dim).
- Returns:
A tuple containing the observations, rewards, resets (terminated and truncated) and extras.
- property step_dt: float#
The environment stepping time-step (in s).
This is the time-step at which the environment steps forward.
- property unwrapped: Env[ObsType, ActType]#
Returns the base non-wrapped environment.
- Returns:
The base non-wrapped
gymnasium.Env
instance- Return type:
Env
- cfg: ManagerBasedRLEnvCfg#
Configuration for the environment.
Franka Cube Stack IK Rel Mimic Env Cfg#
- class isaaclab_mimic.envs.FrankaCubeStackIKRelMimicEnvCfg[source]#
Bases:
FrankaCubeStackEnvCfg
,MimicEnvCfg
Isaac Lab Mimic environment config class for Franka Cube Stack IK Rel env.
Methods:
__init__
([datagen_config, subtask_configs, ...])Classes:
Attributes:
Viewer configuration.
Physics simulation configuration.
The seed for the random number generator.
Number of control action updates @ sim dt per policy dt.
Scene settings.
Recorder settings.
Observation space settings.
Action space settings.
Event settings.
Whether a render step is performed again after at least one environment has been reset.
True to wait for assets to be loaded completely, False otherwise.
Whether the learning task is treated as a finite or infinite horizon problem for the agent.
Duration of an episode (in seconds).
Reward settings.
Termination settings.
Curriculum settings.
Command settings.
- __init__(datagen_config: ~isaaclab.envs.mimic_env_cfg.DataGenConfig = <factory>, subtask_configs: dict[str, list[isaaclab.envs.mimic_env_cfg.SubTaskConfig]] = <factory>, viewer: ~isaaclab.envs.common.ViewerCfg = <factory>, sim: ~isaaclab.sim.simulation_cfg.SimulationCfg = <factory>, ui_window_class_type: type | None = <class 'isaaclab.envs.ui.manager_based_rl_env_window.ManagerBasedRLEnvWindow'>, seed: int | None = <factory>, decimation: int = <factory>, scene: ~isaaclab_tasks.manager_based.manipulation.stack.stack_env_cfg.ObjectTableSceneCfg = <factory>, recorders: object = <factory>, observations: ~isaaclab_tasks.manager_based.manipulation.stack.stack_env_cfg.ObservationsCfg = <factory>, actions: ~isaaclab_tasks.manager_based.manipulation.stack.stack_env_cfg.ActionsCfg = <factory>, events: object = <factory>, rerender_on_reset: bool = <factory>, wait_for_textures: bool = <factory>, is_finite_horizon: bool = <factory>, episode_length_s: float = <factory>, rewards: object = <factory>, terminations: ~isaaclab_tasks.manager_based.manipulation.stack.stack_env_cfg.TerminationsCfg = <factory>, curriculum: object | None = <factory>, commands: object | None = <factory>) None #
- ui_window_class_type#
alias of
ManagerBasedRLEnvWindow
- sim: SimulationCfg#
Physics simulation configuration. Default is SimulationCfg().
- seed: int | None#
The seed for the random number generator. Defaults to None, in which case the seed is not set.
Note
The seed is set at the beginning of the environment initialization. This ensures that the environment creation is deterministic and behaves similarly across different runs.
- decimation: int#
Number of control action updates @ sim dt per policy dt.
For instance, if the simulation dt is 0.01s and the policy dt is 0.1s, then the decimation is 10. This means that the control action is updated every 10 simulation steps.
- scene: ObjectTableSceneCfg#
Scene settings.
Please refer to the
isaaclab.scene.InteractiveSceneCfg
class for more details.
- recorders: object#
Recorder settings. Defaults to recording nothing.
Please refer to the
isaaclab.managers.RecorderManager
class for more details.
- observations: ObservationsCfg#
Observation space settings.
Please refer to the
isaaclab.managers.ObservationManager
class for more details.
- actions: ActionsCfg#
Action space settings.
Please refer to the
isaaclab.managers.ActionManager
class for more details.
- events: object#
Event settings. Defaults to the basic configuration that resets the scene to its default state.
Please refer to the
isaaclab.managers.EventManager
class for more details.
- rerender_on_reset: bool#
Whether a render step is performed again after at least one environment has been reset. Defaults to False, which means no render step will be performed after reset.
When this is False, data collected from sensors after performing reset will be stale and will not reflect the latest states in simulation caused by the reset.
When this is True, an extra render step will be performed to update the sensor data to reflect the latest states from the reset. This comes at a cost of performance as an additional render step will be performed after each time an environment is reset.
- wait_for_textures: bool#
True to wait for assets to be loaded completely, False otherwise. Defaults to True.
- is_finite_horizon: bool#
Whether the learning task is treated as a finite or infinite horizon problem for the agent. Defaults to False, which means the task is treated as an infinite horizon problem.
This flag handles the subtleties of finite and infinite horizon tasks:
Finite horizon: no penalty or bootstrapping value is required by the the agent for running out of time. However, the environment still needs to terminate the episode after the time limit is reached.
Infinite horizon: the agent needs to bootstrap the value of the state at the end of the episode. This is done by sending a time-limit (or truncated) done signal to the agent, which triggers this bootstrapping calculation.
If True, then the environment is treated as a finite horizon problem and no time-out (or truncated) done signal is sent to the agent. If False, then the environment is treated as an infinite horizon problem and a time-out (or truncated) done signal is sent to the agent.
Note
The base
ManagerBasedRLEnv
class does not use this flag directly. It is used by the environment wrappers to determine what type of done signal to send to the corresponding learning agent.
- episode_length_s: float#
Duration of an episode (in seconds).
Based on the decimation rate and physics time step, the episode length is calculated as:
episode_length_steps = ceil(episode_length_s / (decimation_rate * physics_time_step))
For example, if the decimation rate is 10, the physics time step is 0.01, and the episode length is 10 seconds, then the episode length in steps is 100.
- rewards: object#
Reward settings.
Please refer to the
isaaclab.managers.RewardManager
class for more details.
- terminations: TerminationsCfg#
Termination settings.
Please refer to the
isaaclab.managers.TerminationManager
class for more details.
- curriculum: object | None#
Curriculum settings. Defaults to None, in which case no curriculum is applied.
Please refer to the
isaaclab.managers.CurriculumManager
class for more details.
- commands: object | None#
Command settings. Defaults to None, in which case no commands are generated.
Please refer to the
isaaclab.managers.CommandManager
class for more details.